src/Blocks/Block.php line 83

Open in your IDE?
  1. <?php
  2. namespace App\Blocks;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. class Block
  5. {
  6.     public function __construct(\App\Entity\Content\Block $blockEntityManagerInterface $entityManager\Twig\Environment $twig)
  7.     {
  8.         $this->block $block;
  9.         $this->em $entityManager;
  10.         $this->twig $twig;
  11.     }
  12.     public function getRequiresForm()
  13.     {
  14.         return false;
  15.     }
  16.     public function cleanData($data)
  17.     {
  18.         return $data;
  19.     }
  20.     public function getDirectory()
  21.     {
  22.         throw new \Exception("Block directory not defined!");
  23.     }
  24.     public function applyDataDefaults($data)
  25.     {
  26.         return $data;
  27.     }
  28.    
  29.     public function renderAdminPreviewContent()
  30.     {
  31.         return $this->twig->render('Blocks/' $this->getDirectory() . '/Admin/renderAdminPreviewContent.html.twig', array(
  32.             'block' => array(
  33.                 'identifier' => $this->block->getId(),
  34.                 'block' => $this->block,
  35.                 'instance' => $this
  36.             ),
  37.             'data' => $this->applyDataDefaults($this->block->getData())
  38.         ));
  39.     }
  40.     public function renderAdminBlockDataFields()
  41.     {
  42.         return $this->twig->render('Blocks/' $this->getDirectory() . '/Admin/renderAdminBlockDataFields.html.twig', array(
  43.             'block' => array(
  44.                 'identifier' => $this->block->getId(),
  45.                 'block' => $this->block,
  46.                 'instance' => $this
  47.             ),
  48.             'data' => $this->applyDataDefaults($this->block->getData())
  49.         ));
  50.     }
  51.     public function renderAdminEditBlockModal()
  52.     {
  53.         return $this->twig->render('Blocks/' $this->getDirectory() . '/Admin/renderAdminEditBlockModal.html.twig', array(
  54.             'block' => array(
  55.                 'identifier' => $this->block->getId(),
  56.                 'block' => $this->block,
  57.                 'instance' => $this
  58.             ),
  59.             'data' => $this->applyDataDefaults($this->block->getData())
  60.         ));
  61.     }
  62.     public function renderAdminJavascript()
  63.     {
  64.         return $this->twig->render('Blocks/' $this->getDirectory() . '/Admin/renderAdminJavascript.html.twig', array(
  65.             'block' => array(
  66.                 'identifier' => $this->block->getId(),
  67.                 'block' => $this->block,
  68.                 'instance' => $this
  69.             ),
  70.             'data' => $this->applyDataDefaults($this->block->getData())
  71.         ));
  72.     }
  73.     public function renderFrontend()
  74.     {
  75.         return $this->twig->render('Blocks/' $this->getDirectory() . '/Frontend/renderFrontend.html.twig', array(
  76.             'block' => array(
  77.                 'identifier' => $this->block->getId(),
  78.                 'block' => $this->block,
  79.                 'instance' => $this
  80.             ),
  81.             'data' => $this->applyDataDefaults($this->block->getData())
  82.         ));
  83.     }
  84. }