mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-27 06:29:19 +08:00
add plugin_assets() helper function
This commit is contained in:
parent
f0a76dad04
commit
d622e455c7
@ -16,12 +16,19 @@ use Illuminate\Contracts\Support\Arrayable;
|
||||
class Plugin implements Arrayable, ArrayAccess
|
||||
{
|
||||
/**
|
||||
* The directory of this plugin.
|
||||
* The full directory of this plugin.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* The directory name where the plugin installed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dirname;
|
||||
|
||||
/**
|
||||
* package.json of the package.
|
||||
*
|
||||
@ -115,6 +122,18 @@ class Plugin implements Arrayable, ArrayAccess
|
||||
return $this->installed;
|
||||
}
|
||||
|
||||
public function getDirname()
|
||||
{
|
||||
return $this->dirname;
|
||||
}
|
||||
|
||||
public function setDirname($dirname)
|
||||
{
|
||||
$this->dirname = $dirname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNameSpace()
|
||||
{
|
||||
return $this->namespace;
|
||||
|
@ -85,6 +85,7 @@ class PluginManager
|
||||
$plugin = new Plugin($this->getPluginsDir().'/'.$path, $package);
|
||||
|
||||
// Per default all plugins are installed if they are registered in composer.
|
||||
$plugin->setDirname($path);
|
||||
$plugin->setInstalled(true);
|
||||
$plugin->setNameSpace(Arr::get($package, 'namespace'));
|
||||
$plugin->setVersion(Arr::get($package, 'version'));
|
||||
|
@ -48,6 +48,18 @@ if (! function_exists('assets')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('plugin_assets')) {
|
||||
|
||||
function plugin_assets($id, $relative_uri)
|
||||
{
|
||||
if ($plugin = app('plugins')->getPlugin($id)) {
|
||||
return url("plugins/{$plugin->getDirname()}/$relative_uri");
|
||||
} else {
|
||||
throw new InvalidArgumentException("No such plugin.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('json')) {
|
||||
|
||||
function json()
|
||||
|
Loading…
Reference in New Issue
Block a user