Converts the given $block into a plain hash format.

@param \eZ\Publish\Core\FieldType\Page\Parts\Block $block

@return array
488601
protected function convertBlockToHash(Block $block)
    {
        $hash = array();

        foreach ($block->getState() as $propName => $propValue) {
            switch ($propName) {
                case 'id':
                case 'name':
                case 'type':
                case 'view':
                case 'overflowId':
                case 'customAttributes':
                case 'action':
                case 'rotation':
                case 'zoneId':
                    if ($propValue !== null) {
                        $hash[$propName] = $propValue;
                    }
                    break;
                case 'attributes':
                    if ($propValue !== null && $propValue !== array()) {
                        $hash['attributes'] = $propValue;
                    }
                    break;
                case 'items':
                    foreach ($propValue as $item) {
                        $hash['items'][] = $this->convertItemToHash($item);
                    }
                    break;
            }
        }

        return $hash;
    }
688726
public function generateBlock($block)
    {
        try {
            $generator = new AdminGenerator;
            $generator->MakeDirectory();
            $generator->makeBlock($block);
            return 'Блок сгенерирован  ' . $block . '</br>';
        } catch (\Exception $exception) {
            return 'Что то пошло не так' . $exception->getMessage();
        }

    }
936497
public function toString(ReadBlockInterface $block)
    {
        /** @var DisplayBlockInterface $strategy */
        foreach ($this->strategies as $strategy) {
            if ($strategy->support($block)) {
                return $strategy->toString($block);
            }
        }

        return $this->defaultStrategy->toString($block);
    }
1305444
public function writeBlocks( $blocks )
	{
		foreach( $blocks as $name => $content )
		{
			$list[]	= str_replace( "{#name#}", $name, $this->patternSection );
			$list[]	= $content;
			$list[]	= "";
		}
		$file	= new FS_File_Writer( $this->fileName );
		return $file->writeArray( $list );
	}
1108573
public function getArchivedBlockItems(Block $block)
    {
        if (isset($this->archivedBlockItems[$block])) {
            return $this->archivedBlockItems[$block];
        }

        return $this->archivedBlockItems[$block] = $this->getStorageGateway()->getArchivedBlockItems($block);
    }
127402
private function upgrade(BlockInterface $block)
    {
        $data = array_replace(self::DEFAULT_DATA, $block->getData());

        $translation = $block->translate($this->localeProvider->getFallbackLocale());

        $translationData = array_replace(self::DEFAULT_TRANSLATION_DATA, $translation->getData());

        if (isset($data['url'])) {
            $translationData['url'] = $data['url'];
            unset($data['url']);
        }
        foreach (['image', 'hover'] as $key) {
            if (isset($data[$key]) && isset($data[$key]['media'])) {
                $translationData[$key]['media'] = $data[$key]['media'];
                unset($data[$key]['media']);
            }
        }

        $block->setData($data);
        $translation->setData($translationData);
    }
324162
protected function getDefinedPredicatesInSpecBlock(array $block)
    {
        $predicates = [];
        // If the spec has a "type" property, include rdf:type
        if(isset($block['type']))
        {
            $predicates[] = $this->getLabeller()->uri_to_alias(RDF_TYPE);
        }
        if(isset($block['filter']))
        {
            foreach($block['filter'] as $filter)
            {
                if(isset($filter['condition']))
                {
                    $predicates = array_merge($predicates, $this->getPredicatesFromFilterCondition($filter['condition']));
                }
            }
        }
        // Get the predicates out of the defined fields
        if(isset($block['fields']))
        {
            foreach($block['fields'] as $field)
            {
                if(isset($field['predicates']))
                {
                    foreach($field['predicates'] as $p)
                    {
                        if(!empty($p))
                        {
                            // The actual predicate strings may be buried in predicate function blocks
                            $predicates = array_merge($predicates, $this->getPredicateAliasesFromPredicateProperty($p));
                        }
                    }
                }
            }
        }

        // Loop through the joins and pass the objects back to this method
        if(isset($block['joins']))
        {
            foreach($block['joins'] as $predicate=>$join)
            {
                // Joins are keyed on the predicate, so save that
                $predicates[] = $this->getLabeller()->uri_to_alias($predicate);
                $predicates = array_merge($predicates, $this->getDefinedPredicatesInSpecBlock($join));
            }
        }

        // Loop through the counts blocks
        if(isset($block['counts']))
        {
            foreach($block['counts'] as $property)
            {
                // counts use the redundant property 'property', which behaves exactly like a predicate and needs to be deprecated
                if(isset($property['property']))
                {
                    $predicates[] = $this->getLabeller()->uri_to_alias($property['property']);
                }

                // This is here so we can easily deprecate 'property' in favor of 'predicates'
                if(isset($property['predicates']))
                {
                    foreach($property['predicates'] as $p)
                    {
                        if(!empty($p))
                        {
                            // The actual predicate strings may be buried in predicate function blocks
                            $predicates = array_merge($predicates, $this->getPredicateAliasesFromPredicateProperty($p));
                        }
                    }
                }
            }
        }

        // Loop through the indices: these should be more or less identical to 'fields'
        if(isset($block['indices']))
        {
            foreach($block['indices'] as $index)
            {
                if(isset($index['predicates']))
                {
                    foreach($index['predicates'] as $p)
                    {
                        if(!empty($p))
                        {
                            $predicates = array_merge($predicates, $this->getPredicateAliasesFromPredicateProperty($p));
                        }
                    }
                }
            }
        }
        return $predicates;
    }
1219059
protected function createBlocks(BlockInterface $block)
    {
        $content = [];
        $content['id'] = $block->getId();
        $content['name'] = $block->getName();
        $content['enabled'] = $block->getEnabled();
        $content['position'] = $block->getPosition();
        $content['settings'] = $block->getSettings();
        $content['type'] = $block->getType();
        $content['created_at'] = $block->getCreatedAt()->format('U');
        $content['updated_at'] = $block->getUpdatedAt()->format('U');
        $content['blocks'] = [];

        foreach ($block->getChildren() as $child) {
            $content['blocks'][] = $this->createBlocks($child);
        }

        return $content;
    }
1154258
private function get_tags(string $block){
    preg_match_all($this->pattern['tag'], $block, $tags, PREG_OFFSET_CAPTURE);
    if ( !empty($tags[0]) ){
      return $tags[0];
    }
    return [];
  }
80465
public function addBlock(Block $block)
	{
		if ($this->lock('block')) {
			$this->matchDiscriminator($block);
			if ($this->addUnique($this->blocks, $block)) {
				$block->setPlaceHolder($this);
			}
			$this->unlock('block');
		}
	}
642885
public function parse_docblock(string $block){
    $b = [
			'description' => '',
			'tags' => []
		];
    // Remove start pattern
    //$block = trim(substr($block, 3));
		// Remove end pattern
		$block = trim(substr($block, 0, strlen($block) - 2));
		// Tags
    $tags = $this->get_tags($block);
    foreach ( $tags as $i => $tag ){
			if (
				(
					isset($tags[$i+1]) &&
					($t = $this->parse_tag(substr($block, $tag[1], $tags[$i+1][1] - $tag[1])))
        ) ||
				($t = $this->parse_tag(substr($block, $tag[1])))
			){
				$b['tags'][] = $t;
			}
    }
    // Get Description
    $b['description'] = $this->clear_text(isset($tags[0]) ? substr($block, 3, $tags[0][1]-1) : substr($block, 3));
    return $b;
  }
23280
protected function _filterBlock(Block $block)
    {
        $cacheKey = "allowed_{$block->id}";
        $cache = static::cache($cacheKey);

        if ($cache !== null) {
            return $cache;
        }

        if (!empty($block->locale) &&
            !in_array(I18n::locale(), (array)$block->locale)
        ) {
            return static::cache($cacheKey, false);
        }

        if (!$block->isAccessibleByUser()) {
            return static::cache($cacheKey, false);
        }

        $allowed = false;
        switch ($block->visibility) {
            case 'except':
                // Show on all pages except listed pages
                $allowed = !$this->_urlMatch($block->pages);
                break;
            case 'only':
                // Show only on listed pages
                $allowed = $this->_urlMatch($block->pages);
                break;
            case 'php':
                // Use custom PHP code to determine visibility
                $allowed = php_eval($block->pages, [
                    'view' => &$this->_View,
                    'block' => &$block
                ]) === true;
                break;
        }

        if (!$allowed) {
            return static::cache($cacheKey, false);
        }

        return static::cache($cacheKey, true);
    }
1331524
protected function compileAtRoot(Block $block)
    {
        $env     = $this->pushEnv($block);
        $envs    = $this->compactEnv($env);
        $without = isset($block->with) ? $this->compileWith($block->with) : static::WITH_RULE;

        // wrap inline selector
        if ($block->selector) {
            $wrapped = new Block;
            $wrapped->sourceName   = $block->sourceName;
            $wrapped->sourceIndex  = $block->sourceIndex;
            $wrapped->sourceLine   = $block->sourceLine;
            $wrapped->sourceColumn = $block->sourceColumn;
            $wrapped->selectors    = $block->selector;
            $wrapped->comments     = [];
            $wrapped->parent       = $block;
            $wrapped->children     = $block->children;
            $wrapped->selfParent   = $block->selfParent;

            $block->children = [[Type::T_BLOCK, $wrapped]];
            $block->selector = null;
        }

        $selfParent = $block->selfParent;

        if (! $block->selfParent->selectors && isset($block->parent) && $block->parent && isset($block->parent->selectors) && $block->parent->selectors) {
            $selfParent = $block->parent;
        }

        $this->env = $this->filterWithout($envs, $without);

        $saveScope   = $this->scope;
        $this->scope = $this->filterScopeWithout($saveScope, $without);

        // propagate selfParent to the children where they still can be useful
        $this->compileChildrenNoReturn($block->children, $this->scope, $selfParent);

        $this->scope = $this->completeScope($this->scope, $saveScope);
        $this->scope = $saveScope;
        $this->env   = $this->extractEnv($envs);

        $this->popEnv();
    }
679843
public function includeBlockabale(Block $block)
    {
        $blockable = $block->blockable;
        if (!empty($blockable)) {
            $entityClassName  = (new ReflectionClass($blockable))->getShortName();
            $transformerClass = 'Gzero\\Api\\Transformer\\' . $entityClassName . 'Transformer';
            return $this->item($blockable, new $transformerClass());
        }
        return null;
    }
1078073
public function setBlock($block)
    {
        if (!empty($block) && $block <= 4 && $block !== 0 && !($block < 0)) {
            $this->block = $block;
        }
    }
1005428
final public function blockCreate(array $block)
    {
        $result = [];
        foreach ($block as $k => $pointer) {
            $result[$k] = $this->create($pointer);
        }
        return $result;
    }
1035362
public function processBlock(BlockDocument $block)
    {
        $hasMethods = false;

        $form = $this->formContainerService->getForm();
        if (!is_null($form) && $form->isSubmitted()) {
            $formBlockMethods = $block->getFormBlockMethods();

            /** @var FormBlockMethodArgumentDocument $formBlockMethod */
            foreach ($formBlockMethods as $formBlockMethod) {
                if ($method = $formBlockMethod->getMethodArgument()) {
                    $this->methodService->call($method);

                    if (!$hasMethods) {
                        $hasMethods = true;
                    }
                }
            }
        }

        return $hasMethods;
    }