src/Blocks/Block.php line 90

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