vendor/pimcore/pimcore/lib/Extension/Document/Areabrick/AbstractAreabrick.php line 167

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Commercial License (PCL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  13.  */
  14. namespace Pimcore\Extension\Document\Areabrick;
  15. use Pimcore\Extension\Document\Areabrick\Exception\ConfigurationException;
  16. use Pimcore\Model\Document\Editable;
  17. use Pimcore\Model\Document\Editable\Area\Info;
  18. use Pimcore\Model\Document\PageSnippet;
  19. use Pimcore\Templating\Renderer\EditableRenderer;
  20. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  21. use Symfony\Component\DependencyInjection\ContainerAwareTrait;
  22. abstract class AbstractAreabrick implements AreabrickInterfaceTemplateAreabrickInterfaceContainerAwareInterface
  23. {
  24.     use ContainerAwareTrait;
  25.     /**
  26.      * @var EditableRenderer
  27.      */
  28.     protected $editableRenderer;
  29.     /**
  30.      * Called in AreabrickPass
  31.      *
  32.      * @param EditableRenderer $editableRenderer
  33.      */
  34.     public function setEditableRenderer(EditableRenderer $editableRenderer)
  35.     {
  36.         $this->editableRenderer $editableRenderer;
  37.     }
  38.     /**
  39.      * @var string
  40.      */
  41.     protected $id;
  42.     /**
  43.      * {@inheritdoc}
  44.      */
  45.     public function setId($id)
  46.     {
  47.         // make sure ID is only set once
  48.         if (null !== $this->id) {
  49.             throw new ConfigurationException(sprintf(
  50.                 'Brick ID is immutable (trying to set ID %s for brick %s)',
  51.                 $id,
  52.                 $this->id
  53.             ));
  54.         }
  55.         $this->id $id;
  56.     }
  57.     /**
  58.      * {@inheritdoc}
  59.      */
  60.     public function getId()
  61.     {
  62.         return $this->id;
  63.     }
  64.     /**
  65.      * {@inheritdoc}
  66.      */
  67.     public function getName()
  68.     {
  69.         return $this->id ucfirst($this->id) : '';
  70.     }
  71.     /**
  72.      * {@inheritdoc}
  73.      */
  74.     public function getDescription()
  75.     {
  76.         return '';
  77.     }
  78.     /**
  79.      * {@inheritdoc}
  80.      */
  81.     public function getVersion()
  82.     {
  83.         return '';
  84.     }
  85.     /**
  86.      * {@inheritdoc}
  87.      */
  88.     public function getIcon()
  89.     {
  90.         return null;
  91.     }
  92.     /**
  93.      * {@inheritdoc}
  94.      */
  95.     public function hasTemplate()
  96.     {
  97.         return true;
  98.     }
  99.     /**
  100.      * {@inheritdoc}
  101.      */
  102.     public function action(Info $info)
  103.     {
  104.         // noop - implement as needed
  105.         return null;
  106.     }
  107.     /**
  108.      * {@inheritdoc}
  109.      */
  110.     public function postRenderAction(Info $info)
  111.     {
  112.         // noop - implement as needed
  113.         return null;
  114.     }
  115.     /**
  116.      * {@inheritdoc}
  117.      */
  118.     public function getHtmlTagOpen(Info $info)
  119.     {
  120.         return '<div class="pimcore_area_' $info->getId() . ' pimcore_area_content '$this->getOpenTagCssClass($info) .'">';
  121.     }
  122.     /**
  123.      * @param Info $info
  124.      *
  125.      * @return string|null
  126.      */
  127.     protected function getOpenTagCssClass(Info $info)
  128.     {
  129.         return null;
  130.     }
  131.     /**
  132.      * {@inheritdoc}
  133.      */
  134.     public function getHtmlTagClose(Info $info)
  135.     {
  136.         return '</div>';
  137.     }
  138.     /**
  139.      * @param PageSnippet $document
  140.      * @param string $type
  141.      * @param string $inputName
  142.      * @param array $options
  143.      *
  144.      * @return Editable\EditableInterface
  145.      */
  146.     protected function getDocumentEditable(PageSnippet $document$type$inputName, array $options = [])
  147.     {
  148.         return $this->editableRenderer->getEditable($document$type$inputName$options);
  149.     }
  150.     public function needsReload(): bool
  151.     {
  152.         return false;
  153.     }
  154. }