Skip to content

Instantly share code, notes, and snippets.

@tleilax
Created March 19, 2019 08:25
Show Gist options
  • Save tleilax/3d4d42596b5af4c51ffc3950780c48f0 to your computer and use it in GitHub Desktop.
Save tleilax/3d4d42596b5af4c51ffc3950780c48f0 to your computer and use it in GitHub Desktop.
<?php
trait PluginAssetsTrait
{
protected function getPluginVersion()
{
static $manifest = null;
if ($manifest === null) {
$manifest = $this->getMetadata();
}
return $manifest['version'];
}
protected function addScript($asset)
{
$asset = ltrim($asset, '/');
PageLayout::addScript("{$this->getPluginURL()}/{$asset}?v={$this->getPluginVersion()}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment