@TODO: this should be moved to editable configuration.

@param Editable\Editable $editable
@param BlockProperty $property
764212
protected function configureValueTransformers(Editable\Editable $editable, BlockProperty $property)
	{
		$transformers = array();

		if ($editable instanceof Editable\Html) {
			$transformers[] = new Transformer\HtmlEditorValueTransformer();
		} elseif ($editable instanceof Editable\Link) {
			$transformers[] = new Transformer\LinkEditorValueTransformer();
		} else if ($editable instanceof Editable\Image) {
			$transformers[] = new Transformer\ImageEditorValueTransformer();
		} else if ($editable instanceof Editable\Gallery) {
			$transformers[] = new Transformer\GalleryEditorValueTransformer();
		} else if ($editable instanceof Editable\InlineMap) {
			$transformers[] = new Transformer\ArrayValueTransformer();
		} elseif ($editable instanceof Editable\Video) {
			$transformers[] = new Transformer\VideoEditorValueTransformer();
		} elseif ($editable instanceof Editable\InlineMedia) {
			$transformers[] = new Transformer\InlineMediaEditorValueTransformer();
		}

		foreach ($transformers as $transformer) {
			if ($transformer instanceof ContainerAware) {
				$transformer->setContainer($this->container);
			}
			if ($transformer instanceof BlockPropertyAware) {
				$transformer->setBlockProperty($property);
			}

			$editable->addEditorValueTransformer($transformer);
		}
	}
535175
protected function setCurrentBlockProperty(Model\BlockInterface $block, $property, $current)
    {
        $layout = $block->getLayout();

        // Update the current device layout
        $currentDevice = $this->resolveCurrentDevice();
        $layout = array_replace_recursive($layout, [
            $currentDevice => [
                $property => $current,
            ],
        ]);

        // Clear the property for upper devices layouts if equals
        foreach ($this->resolveGreaterDevices() as $d) {
            if (isset($layout[$d]) && isset($layout[$d][$property]) && $layout[$d][$property] == $current) {
                unset($layout[$d][$property]);
            }
        }

        $block->setLayout($layout);
    }
730231
public function moveDown(Model\BlockInterface $block)
    {
        $row = $block->getRow();
        if (null === $row || $row->isLast()) {
            throw new InvalidOperationException(
                "This block can't be moved to the top."
            );
        }

        $sibling = $this->editor->getRepository()->findSiblingRow($row, true);
        if (null === $sibling) {
            throw new InvalidOperationException(
                "The block can't be moved to the bottom as no sibling row has been found."
            );
        }

        $row->removeBlock($block);
        $sibling->addBlock($block);

        $this->editor
            ->getRowManager()
            ->fixBlocksPositions($row)
            ->fixBlocksPositions($sibling);

        return $sibling;
    }
974891
public function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
    {
        $this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);
    }
1163920
private function updateBlockTranslations(Block $block, array $translationsData): void
    {
        $mainLocale = $block->getMainLocale();

        foreach ($block->getAvailableLocales() as $locale) {
            if ($locale === $mainLocale) {
                continue;
            }

            if (!array_key_exists($locale, $translationsData)) {
                throw new RuntimeException(
                    sprintf('Could not find locale "%s" in the given block data', $locale)
                );
            }

            $this->updateBlockTranslation($block, $translationsData[$locale], $locale);
        }
    }
147378
protected function updateBlocksStructure(
        array &$structureArray,
        BlockMetadata $property,
        $localeSource,
        $localeDestination
    ) {
        if (!array_key_exists($property->getName(), $structureArray) || !$structureArray[$property->getName()]) {
            return;
        }

        foreach ($structureArray[$property->getName()] as &$structure) {
            /** @var ItemMetadata $component */
            $component = $property->getComponentByName($structure['type']);
            /** @var PropertyMetadata $child */
            foreach ($component->getChildren() as $child) {
                if ($structure[$child->getName()]) {
                    $this->processContentType(
                        $child,
                        $structure,
                        $localeSource,
                        $localeDestination
                    );
                }
            }
        }
    }
80255
public function add($name, $editableType, array $editableOptions = array())
	{
		$this->config->addProperty(
				$this->createProperty($name, $editableType, $editableOptions)
		);
		
		return $this;
	}
813346
public function validateBlockUpdateStruct(Block $block, BlockUpdateStruct $blockUpdateStruct): void
    {
        $this->validate(
            $blockUpdateStruct,
            [
                new BlockUpdateStructConstraint(
                    [
                        'payload' => $block,
                    ]
                ),
            ]
        );

        $this->validate(
            $blockUpdateStruct,
            new ConfigAwareStructConstraint(
                [
                    'payload' => $block->getDefinition(),
                    'allowMissingFields' => true,
                ]
            )
        );
    }
1280813
public function editBlockConfiguration(Tree $tree, int $block_id): void
    {
        $title          = $this->getBlockSetting($block_id, 'title', '');
        $html           = $this->getBlockSetting($block_id, 'html', '');
        $show_timestamp = $this->getBlockSetting($block_id, 'show_timestamp', '0');
        $languages      = explode(',', $this->getBlockSetting($block_id, 'languages'));
        $all_trees      = Tree::getNameList();

        $templates = [
            $html                                    => I18N::translate('Custom'),
            view('modules/html/template-keywords')   => I18N::translate('Keyword examples'),
            view('modules/html/template-narrative')  => I18N::translate('Narrative description'),
            view('modules/html/template-statistics') => I18N::translate('Statistics'),
        ];

        echo view('modules/html/config', [
            'all_trees'      => $all_trees,
            'html'           => $html,
            'languages'      => $languages,
            'show_timestamp' => $show_timestamp,
            'templates'      => $templates,
            'title'          => $title,
        ]);
    }
25622
public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void
    {
        $this->setBlockSetting($block_id, 'type', $request->get('type', 'pedigree'));
        $this->setBlockSetting($block_id, 'pid', $request->get('pid', ''));
    }
567011
public function updateBlock(Block $block): void
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->update('ngbm_block')
            ->set('layout_id', ':layout_id')
            ->set('depth', ':depth')
            ->set('path', ':path')
            ->set('parent_id', ':parent_id')
            ->set('placeholder', ':placeholder')
            ->set('position', ':position')
            ->set('definition_identifier', ':definition_identifier')
            ->set('view_type', ':view_type')
            ->set('item_view_type', ':item_view_type')
            ->set('name', ':name')
            ->set('translatable', ':translatable')
            ->set('main_locale', ':main_locale')
            ->set('always_available', ':always_available')
            ->set('config', ':config')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $block->id, Type::INTEGER)
            ->setParameter('layout_id', $block->layoutId, Type::INTEGER)
            ->setParameter('depth', $block->depth, Type::STRING)
            ->setParameter('path', $block->path, Type::STRING)
            ->setParameter('parent_id', $block->parentId, Type::INTEGER)
            ->setParameter('placeholder', $block->placeholder, Type::STRING)
            ->setParameter('position', $block->position, Type::INTEGER)
            ->setParameter('definition_identifier', $block->definitionIdentifier, Type::STRING)
            ->setParameter('view_type', $block->viewType, Type::STRING)
            ->setParameter('item_view_type', $block->itemViewType, Type::STRING)
            ->setParameter('name', $block->name, Type::STRING)
            ->setParameter('translatable', $block->isTranslatable, Type::BOOLEAN)
            ->setParameter('main_locale', $block->mainLocale, Type::STRING)
            ->setParameter('always_available', $block->alwaysAvailable, Type::BOOLEAN)
            ->setParameter('config', $block->config, Type::JSON_ARRAY);

        $this->applyStatusCondition($query, $block->status);

        $query->execute();
    }
251785
public function addPropertyConstraint($property, Constraint $constraint)
    {
        if (!isset($this->properties[$property])) {
            $this->properties[$property] = new PropertyMetadata($this->getClassName(), $property);

            $this->addPropertyMetadata($this->properties[$property]);
        }

        $constraint->addImplicitGroupName($this->getDefaultGroup());

        $this->properties[$property]->addConstraint($constraint);

        return $this;
    }
664518
public function setOriginalDocumentProperty(string $oid, string $property, $value) : void
    {
        $this->originalDocumentData[$oid][$property] = $value;
    }
474860
private function addBlock($blockType, $blockOptions = null)
    {
        //====================================================================//
        // Commit Last Created if not already done
        if (!empty($this->new)) {
            $this->commit();
        }
        //====================================================================//
        // Unset Current
        $this->new = null;
        //====================================================================//
        // Create new empty block
        $this->new = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
        //====================================================================//
        // Set Block Type
        $this->new->type = $blockType;
        //====================================================================//
        // Set Block Options
        $this->new->options = $blockOptions;
        //====================================================================//
        // Set Block Data
        $this->new->data = array();

        return $this;
    }
1076099
public function setEditable(string $editable = "F") : CNabuDataObject
    {
        if ($editable === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$editable")
            );
        }
        $this->setValue('nb_site_lang_editable', $editable);
        
        return $this;
    }
996195
static public function addStyle(\DOMElement $element, $property, $value)
    {
        $s = static::explodeStyles((string)$element->getAttribute('style'));

        $s[$property] = $value;

        $element->setAttribute('style', static::implodeStyles($s));
    }
533672
public function editBlockAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('AmulenPageBundle:Block')->find($id);
        $availableEntityLangs = $em->getRepository('AmulenPageBundle:Block')->findBy(array('page' => $entity->getPage(), 'name' => $entity->getName()));

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Block entity.');
        }

        $editForm = $this->createBlockEditForm($entity);
        $deleteForm = $this->createBlockDeleteForm($id);

        return array(
            'entity' => $entity,
            'availableEntityLangs' => $availableEntityLangs,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }