vendor/friendsofsymfony/ckeditor-bundle/src/Model/TemplateManager.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\TemplateManagerException;
  13. @trigger_error(
  14.     'The '.__NAMESPACE__.'TemplateManager 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 TemplateManager implements TemplateManagerInterface
  22. {
  23.     /**
  24.      * @var array
  25.      */
  26.     private $templates = [];
  27.     /**
  28.      * @param array $templates
  29.      */
  30.     public function __construct(array $templates = [])
  31.     {
  32.         $this->setTemplates($templates);
  33.     }
  34.     /**
  35.      * {@inheritdoc}
  36.      */
  37.     public function hasTemplates()
  38.     {
  39.         return !empty($this->templates);
  40.     }
  41.     /**
  42.      * {@inheritdoc}
  43.      */
  44.     public function getTemplates()
  45.     {
  46.         return $this->templates;
  47.     }
  48.     /**
  49.      * {@inheritdoc}
  50.      */
  51.     public function setTemplates(array $templates)
  52.     {
  53.         foreach ($templates as $name => $template) {
  54.             $this->setTemplate($name$template);
  55.         }
  56.     }
  57.     /**
  58.      * {@inheritdoc}
  59.      */
  60.     public function hasTemplate($name)
  61.     {
  62.         return isset($this->templates[$name]);
  63.     }
  64.     /**
  65.      * {@inheritdoc}
  66.      */
  67.     public function getTemplate($name)
  68.     {
  69.         if (!$this->hasTemplate($name)) {
  70.             throw TemplateManagerException::templateDoesNotExist($name);
  71.         }
  72.         return $this->templates[$name];
  73.     }
  74.     /**
  75.      * {@inheritdoc}
  76.      */
  77.     public function setTemplate($name, array $template)
  78.     {
  79.         $this->templates[$name] = $template;
  80.     }
  81. }