{"_id":"57b80485f442340e00b01717","category":{"_id":"57b80485f442340e00b01708","version":"57b80485f442340e00b01701","__v":0,"project":"56363c690441020d0000e9da","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-11-01T16:28:32.608Z","from_sync":false,"order":6,"slug":"extending","title":"Extending"},"user":"55d48e9283130a250029b3cd","__v":0,"parentDoc":null,"project":"56363c690441020d0000e9da","version":{"_id":"57b80485f442340e00b01701","project":"56363c690441020d0000e9da","__v":1,"createdAt":"2016-08-20T07:19:33.761Z","releaseDate":"2016-08-20T07:19:33.761Z","categories":["57b80485f442340e00b01702","57b80485f442340e00b01703","57b80485f442340e00b01704","57b80485f442340e00b01705","57b80485f442340e00b01706","57b80485f442340e00b01707","57b80485f442340e00b01708","57b80485f442340e00b01709","57b80485f442340e00b0170a","57b80485f442340e00b0170b"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.0.0-dev","version":"1.0.0-dev"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-11-01T17:39:12.056Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"A plugin should extend **Mascame\\Artificer\\Plugin\\AbstractPlugin** \n\nLets review an extension in depth:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php namespace NamespaceHere;\\n\\nuse Mascame\\\\Artificer\\\\Plugin\\\\AbstractPlugin;\\n\\nclass MyPlugin extends AbstractPlugin {\\n\\n    /**\\n     * Automatically filled.\\n     *\\n     * Namespace will automatically be set if empty (will usually be the class itself).\\n     * Example: \\\"Mascame\\\\Artificer\\\\Extension\\\\Extension\\\"\\n     *\\n     * :::at:::var string\\n     */\\n    public $namespace;\\n\\n    /**\\n     * Automatically filled.\\n     *\\n     * Which package is this part of.\\n     * Example: \\\"mascame/artificer-widgets\\\"\\n     *\\n     * @var string\\n     */\\n    public $package = null;\\n\\n    /**\\n     * Automatically filled.\\n     *\\n     * @var array\\n     */\\n    public $authors = [];\\n\\n    /**\\n     * Automatically filled.\\n     *\\n     * @var string\\n     */\\n    public $slug;\\n\\n    /**\\n     * Name that will be shown on extensions page. Example: \\\"My great extension\\\".\\n     *\\n     * @var string\\n     */\\n    public $name = null;\\n\\n    /**\\n     * @var string\\n     */\\n    public $description = 'No description provided';\\n\\n    /**\\n     * @var string\\n     */\\n    public $thumbnail = null;\\n\\n    /**\\n     * @var PluginOption\\n     */\\n    protected $option;\\n\\n    /**\\n     * @var ResourceCollector\\n     */\\n    public $resources;\\n\\n    /**\\n     * This will be called if the plugin is installed\\n     */\\n    abstract public function boot();\\n\\n    /**\\n     * @return string\\n     */\\n    public function getSlug()\\n    {\\n        return $this->slug;\\n    }\\n\\n    /**\\n     * Artificer does not know about your constructor so you\\n     * can inject any dependecy you need\\n     */\\n    abstract function __construct();\\n\\n    /**\\n     * @return Manager\\n     */\\n    abstract protected function getManager();\\n\\n    /**\\n     * @return bool\\n     */\\n    final public function isInstalled()\\n    {\\n        return $this->getManager()->isInstalled($this->namespace);\\n    }\\n\\n    /**\\n     * The assets manager will request the desired assets.\\n     *\\n     * Plugin assets: Will always be requested\\n     * Widget assets: Will only be requested when needed\\n     *\\n     * Note: If you are using local assets they should be published (only happens if the extension is installed)\\n     *\\n     * Example: [ $this->assetsPath . 'css/my-style.css' ]\\n     *\\n     * @param AssetsManagerInterface $manager\\n     * @return AssetsManagerInterface\\n     */\\n    public function assets(AssetsManagerInterface $manager)\\n    {\\n        return $manager;\\n    }\\n\\n    /**\\n     * Refers to the resources that you would usually place in the ServiceProvider:\\n     * https://laravel.com/docs/5.3/packages#resources\\n     *\\n     * Keep in mind that extension config is not available until boot\\n     *\\n     * @param ResourceCollector $collector\\n     * @return ResourceCollector\\n     */\\n    public function resources(ResourceCollector $collector)\\n    {\\n        return $collector;\\n    }\\n}\",\n      \"language\": \"php\",\n      \"name\": \"MyPlugin.php\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"adding-a-plugin","type":"basic","title":"Plugin in detail"}
A plugin should extend **Mascame\Artificer\Plugin\AbstractPlugin** Lets review an extension in depth: [block:code] { "codes": [ { "code": "<?php namespace NamespaceHere;\n\nuse Mascame\\Artificer\\Plugin\\AbstractPlugin;\n\nclass MyPlugin extends AbstractPlugin {\n\n /**\n * Automatically filled.\n *\n * Namespace will automatically be set if empty (will usually be the class itself).\n * Example: \"Mascame\\Artificer\\Extension\\Extension\"\n *\n * @var string\n */\n public $namespace;\n\n /**\n * Automatically filled.\n *\n * Which package is this part of.\n * Example: \"mascame/artificer-widgets\"\n *\n * @var string\n */\n public $package = null;\n\n /**\n * Automatically filled.\n *\n * @var array\n */\n public $authors = [];\n\n /**\n * Automatically filled.\n *\n * @var string\n */\n public $slug;\n\n /**\n * Name that will be shown on extensions page. Example: \"My great extension\".\n *\n * @var string\n */\n public $name = null;\n\n /**\n * @var string\n */\n public $description = 'No description provided';\n\n /**\n * @var string\n */\n public $thumbnail = null;\n\n /**\n * @var PluginOption\n */\n protected $option;\n\n /**\n * @var ResourceCollector\n */\n public $resources;\n\n /**\n * This will be called if the plugin is installed\n */\n abstract public function boot();\n\n /**\n * @return string\n */\n public function getSlug()\n {\n return $this->slug;\n }\n\n /**\n * Artificer does not know about your constructor so you\n * can inject any dependecy you need\n */\n abstract function __construct();\n\n /**\n * @return Manager\n */\n abstract protected function getManager();\n\n /**\n * @return bool\n */\n final public function isInstalled()\n {\n return $this->getManager()->isInstalled($this->namespace);\n }\n\n /**\n * The assets manager will request the desired assets.\n *\n * Plugin assets: Will always be requested\n * Widget assets: Will only be requested when needed\n *\n * Note: If you are using local assets they should be published (only happens if the extension is installed)\n *\n * Example: [ $this->assetsPath . 'css/my-style.css' ]\n *\n * @param AssetsManagerInterface $manager\n * @return AssetsManagerInterface\n */\n public function assets(AssetsManagerInterface $manager)\n {\n return $manager;\n }\n\n /**\n * Refers to the resources that you would usually place in the ServiceProvider:\n * https://laravel.com/docs/5.3/packages#resources\n *\n * Keep in mind that extension config is not available until boot\n *\n * @param ResourceCollector $collector\n * @return ResourceCollector\n */\n public function resources(ResourceCollector $collector)\n {\n return $collector;\n }\n}", "language": "php", "name": "MyPlugin.php" } ] } [/block]