/**
  * {@inheritdoc}
  */
 protected function copy(array $values)
 {
     unset($values['Id']);
     unset($values['CreatedAt']);
     $values['Content'] = $this->configurePermalinkForNewLanguage($values['Content']);
     $values['LanguageId'] = $this->languageManager->get()->getId();
     $result = $this->blockManager->set(null)->save($values);
     return $result;
 }
 public function __construct(ContainerInterface $container, ParametersValidatorInterface $validator = null)
 {
     $this->container = $container;
     $eventsHandler = $container->get('red_kite_cms.events_handler');
     $factoryRepository = $container->get('red_kite_cms.factory_repository');
     $this->translator = $this->container->get('red_kite_cms.translator');
     parent::__construct($eventsHandler, $factoryRepository, $validator);
 }
 /**
  * Constructor
  *
  * @param null|EventsHandlerInterface       $eventsHandler
  * @param null|FactoryRepositoryInterface   $factoryRepository
  * @param null|ParametersValidatorInterface $validator
  * @param null|TranslatorInterface          $translator
  */
 public function __construct(EventsHandlerInterface $eventsHandler = null, FactoryRepositoryInterface $factoryRepository = null, ParametersValidatorInterface $validator = null, TranslatorInterface $translator = null)
 {
     parent::__construct($eventsHandler, $factoryRepository, $validator);
     $this->translator = $translator;
 }
 public function getExecuteInternalJavascript()
 {
     return null === $this->executeInternalJavascript ? parent::getExecuteInternalJavascript() : $this->executeInternalJavascript;
 }
 public function renderIncludedBlock($key, BlockManager $parent = null, $type = "Text", $addWhenEmpty = false, $defaultContent = "", $editorExtraAttributes = "", $blockExtraOptions = array())
 {
     $blocksRepository = $this->container->get('red_kite_cms.factory_repository');
     $repository = $blocksRepository->createRepository('Block');
     $blocks = $repository->retrieveContents(null, null, $key);
     $blockManagerFactory = $this->container->get('red_kite_cms.block_manager_factory');
     $extraOptions = array('parent_slot_name' => $key);
     if (null !== $parent && preg_match('/' . $parent->get()->getId() . '\\-([0-9]+)/', $key, $matches)) {
         $extraOptions['parent_block_id'] = $parent->get()->getId();
         $extraOptions['key'] = $matches[1];
     }
     if (count($blocks) > 0) {
         $alBlock = $blocks[0];
         $type = $alBlock->getType();
         $blockManager = $blockManagerFactory->createBlockManager($type);
         if (null !== $blockManager) {
             $blockManager->set($alBlock);
             $blockManager->setBlockExtraOptions($blockExtraOptions);
             if (null !== $parent) {
                 $blockManager->setEditorDisabled($parent->getEditorDisabled());
             }
             return $this->renderBlock($blockManager, '_included_block.html.twig', true, $editorExtraAttributes, $extraOptions);
         }
         // @codeCoverageIgnoreStart
     }
     // @codeCoverageIgnoreEnd
     if (true === $addWhenEmpty) {
         if (null === $parent) {
             throw new RuntimeException($this->translator->translate('twig_extension_valid_block_manager_required', array(), 'RedKiteCmsBundle'));
         }
         $blockManager = $blockManagerFactory->createBlockManager($type);
         if (null !== $blockManager) {
             $blockManager->setEditorDisabled($parent->getEditorDisabled());
             $blockManager->setBlockExtraOptions($blockExtraOptions);
             $parentBlock = $parent->get();
             $values = array("PageId" => $parentBlock->getPageId(), "LanguageId" => $parentBlock->getLanguageId(), "SlotName" => $key, "Type" => $type, "ContentPosition" => 1);
             if (!empty($defaultContent)) {
                 $values["Content"] = $defaultContent;
             }
             $blockManager->save($values);
             return $this->renderBlock($blockManager, '_included_block.html.twig', true, $editorExtraAttributes, $extraOptions);
         }
         // @codeCoverageIgnoreStart
     }
     // @codeCoverageIgnoreEnd
     return sprintf('<div data-editor="enabled" data-block-id="0" data-slot-name="%s" data-included="1">%s</div>', $key, $this->translator->translate('twig_extension_empty_slot', array(), 'RedKiteCmsBundle'));
 }