vendor/friendsofsymfony/ckeditor-bundle/src/Model/PluginManager.php line 20

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the FOSCKEditor Bundle.
  4.  *
  5.  * (c) 2018 - present  Friends of Symfony
  6.  * (c) 2009 - 2017     Eric GELOEN <geloen.eric@gmail.com>
  7.  *
  8.  * For the full copyright and license information, please read the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace FOS\CKEditorBundle\Model;
  12. use FOS\CKEditorBundle\Exception\PluginManagerException;
  13. @trigger_error(
  14.     'The '.__NAMESPACE__.'PluginManager is deprecated since 1.x '.
  15.     'and will be removed with the 2.0 release.',
  16.     E_USER_DEPRECATED
  17. );
  18. /**
  19.  * @author GeLo <geloen.eric@gmail.com>
  20.  */
  21. class PluginManager implements PluginManagerInterface
  22. {
  23.     /**
  24.      * @var array
  25.      */
  26.     private $plugins = [];
  27.     /**
  28.      * @param array $plugins
  29.      */
  30.     public function __construct(array $plugins = [])
  31.     {
  32.         $this->setPlugins($plugins);
  33.     }
  34.     /**
  35.      * {@inheritdoc}
  36.      */
  37.     public function hasPlugins()
  38.     {
  39.         return !empty($this->plugins);
  40.     }
  41.     /**
  42.      * {@inheritdoc}
  43.      */
  44.     public function getPlugins()
  45.     {
  46.         return $this->plugins;
  47.     }
  48.     /**
  49.      * {@inheritdoc}
  50.      */
  51.     public function setPlugins(array $plugins)
  52.     {
  53.         foreach ($plugins as $name => $plugin) {
  54.             $this->setPlugin($name$plugin);
  55.         }
  56.     }
  57.     /**
  58.      * {@inheritdoc}
  59.      */
  60.     public function hasPlugin($name)
  61.     {
  62.         return isset($this->plugins[$name]);
  63.     }
  64.     /**
  65.      * {@inheritdoc}
  66.      */
  67.     public function getPlugin($name)
  68.     {
  69.         if (!$this->hasPlugin($name)) {
  70.             throw PluginManagerException::pluginDoesNotExist($name);
  71.         }
  72.         return $this->plugins[$name];
  73.     }
  74.     /**
  75.      * {@inheritdoc}
  76.      */
  77.     public function setPlugin($name, array $plugin)
  78.     {
  79.         $this->plugins[$name] = $plugin;
  80.     }
  81. }