@param ReadBlockInterface $block
@param array              $baseSubQuery

@return array
323946
public function generateSubQuery(ReadBlockInterface $block, array $baseSubQuery)
    {
        $subQueryGeneratorManager = $this->container->get('open_orchestra_front.sub_query.manager');

        return $subQueryGeneratorManager->generate($block, $baseSubQuery);
    }
464556
private function getMaxPages(Block $block): ?int
    {
        if (!$block->getDefinition()->hasPlugin(PagedCollectionsPlugin::class)) {
            return null;
        }

        if ($block->getParameter('paged_collections:enabled')->getValue() !== true) {
            return null;
        }

        return $block->getParameter('paged_collections:max_pages')->getValue();
    }
714147
public function execute(BlockInterface $block, Response $response = null, array $parameters = [])
    {
        $this->loadCollection($block);

        return parent::execute($block, $response, $parameters);
    }
576791
public function loadBlockCollectionIds(array $blockIds, ?int $status = null): array
    {
        $query = $this->connection->createQueryBuilder();
        $query->select('DISTINCT bc.collection_id')
            ->from('ngbm_block_collection', 'bc')
            ->where(
                $query->expr()->in('bc.block_id', [':block_id'])
            )
            ->setParameter('block_id', $blockIds, Connection::PARAM_INT_ARRAY);

        if ($status !== null) {
            $this->applyStatusCondition($query, $status, 'bc.block_status', 'block_status');
        }

        $result = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        return array_column($result, 'collection_id');
    }
553545
function blockSet(BlockInterface $block, $templateFile) {
		$this->_blockStack[]= $block;
		$this->_templateFileStack[]= $templateFile;
	}
632440
public function show(ReadBlockInterface $block)
    {
        $contents = $this->getContents($block->getAttribute('contentSearch'));

        if (!is_null($contents)) {

            $parameters = array(
                'contents' => $contents,
                'class' => $block->getStyle(),
                'id' => $block->getId(),
                'characterNumber' => $block->getAttribute('characterNumber')
            );

            if ('' != $block->getAttribute('contentNodeId')) {
                $language = $this->currentSiteManager->getSiteLanguage();
                $siteId = $this->currentSiteManager->getSiteId();
                $node = $this->nodeRepository->findOnePublished($block->getAttribute('contentNodeId'), $language, $siteId);
                $parameters['contentNodeId'] = $node->getId();

                if (!$this->isGrantedNode($node)) {
                    unset($parameters['contentNodeId']);
                }
            }

            return $this->render('OpenOrchestraDisplayBundle:Block/ContentList:show.html.twig', $parameters);
        }

        throw new ContentNotFoundException();
    }
596787
public function show(ReadBlockInterface $block)
    {
        $nodes = $this->getNodes();

        return $this->render(
            'OpenOrchestraDisplayBundle:Block/Menu:tree.html.twig',
            array(
                'tree' => $nodes,
                'id' => $block->getId(),
                'class' => $block->getStyle(),
            )
        );
    }
491250
public function getCacheTags(ReadBlockInterface $block)
    {
        $strategy = $this->getStrategy($block);
        if (null === $strategy) {
            throw new DisplayBlockStrategyNotFoundException($block->getComponent());
        }

        $cacheTags = $strategy->getCacheTags($block);
        $cacheTags[] = $this->tagManager->formatBlockTypeTag($block->getComponent());

        return $cacheTags;
    }
10216
protected function getStrategy(ReadBlockInterface $block)
    {
        if (isset($this->cachedStrategies[$block->getId()])) {
            return $this->cachedStrategies[$block->getId()];
        }

        foreach ($this->strategies as $strategy) {
            if ($strategy->support($block)) {
                if ($block->getId()) {
                    $this->cachedStrategies[$block->getId()] = $strategy;
                }

                return $strategy;
            }
        }

        return null;
    }
99117
public function getViewParameters(BlockInterface $block)
    {
        $authErrorKey = Security::AUTHENTICATION_ERROR;
        $lastUsernameKey = Security::LAST_USERNAME;

        // get the error if any (works with forward and redirect -- see below)
        if ($this->getRequest()->attributes->has($authErrorKey)) {
            $error = $this->getRequest()->attributes->get($authErrorKey);
        } elseif (null !== $this->session && $this->session->has($authErrorKey)) {
            $error = $this->session->get($authErrorKey);
            $this->session->remove($authErrorKey);
        } else {
            $error = null;
        }

        if (!$error instanceof AuthenticationException) {
            $error = null; // The value does not come from the security component.
        }

        // last username entered by the user
        $lastUsername = (null === $this->session) ? '' : $this->session->get($lastUsernameKey);
        $csrfToken = $this->csrfTokenManager->getToken('authenticate')->getValue();
        $parameters = [
            'block_service' => $this,
            'block' => $block,
            'last_username' => $lastUsername,
            'error' => $error,
            'csrf_token' => $csrfToken
        ];

        return $parameters;
    }
481641
public function getBlockById(int $blockId, int $siteId = null)
    {
        /** @var SuperTableBlock|null $block */
        $block = Craft::$app->getElements()->getElementById($blockId, SuperTableBlockElement::class, $siteId);

        return $block;
    }
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;
    }
891573
public static function updateBlockPoolByBlockID( $block, $publishedBeforeOrAt = false )
    {
        $db = eZDB::instance();
        $blockINI = eZINI::instance( 'block.ini' );

        if ( !$publishedBeforeOrAt )
        {
            $publishedBeforeOrAt = time();
        }

        if ( !$blockINI->hasVariable( $block['block_type'], 'FetchClass' ) )
        {
            // Pure manual block, nothing is going to be fetched, but we need to update last_update as it is used for rotations
            if ( $block['rotation_type'] != self::ROTATION_NONE )
                $db->query( "UPDATE ezm_block SET last_update=$publishedBeforeOrAt WHERE id='" . $block['id'] . "'" );
            return 0;
        }

        $fetchClassOptions = new ezpExtensionOptions();
        $fetchClassOptions->iniFile = 'block.ini';
        $fetchClassOptions->iniSection = $block['block_type'];
        $fetchClassOptions->iniVariable = 'FetchClass';

        $fetchInstance = eZExtension::getHandlerClass( $fetchClassOptions );

        if ( !( $fetchInstance instanceof eZFlowFetchInterface ) )
        {
            eZDebug::writeWarning( "Can't create an instance of the $fetchClass class", "eZFlowOperations::updateBlockPoolByBlockID('" . $block['id'] . "')" );
            return false;
        }

        $fetchFixedParameters = array();
        if ( $blockINI->hasVariable( $block['block_type'], 'FetchFixedParameters' ) )
        {
            $fetchFixedParameters = $blockINI->variable( $block['block_type'], 'FetchFixedParameters' );
        }
        $fetchParameters = unserialize( $block['fetch_params'] );
        if ( !is_array( $fetchParameters ) )
        {
            // take care of blocks existing in db where ini definition changed
            eZDebug::writeWarning( "Found existing block which has no necessary parameters serialized in the db (block needs updating)", "eZFlowOperations::updateBlockPoolByBlockID('" . $block['id'] . "')" );
            $fetchParameters = array();
        }
        $parameters = array_merge( $fetchFixedParameters, $fetchParameters );

        $newItems = array();

        foreach ( $fetchInstance->fetch( $parameters, $block['last_update'], $publishedBeforeOrAt ) as $item )
        {
            $newItems[] = array(
                'blockID' => $block['id'],
                'objectID' => $item['object_id'],
                'nodeID' => $item['node_id'],
                'priority' => 0,
                'timestamp' => $item['ts_publication'],
            );
        }

        $itemsToRemove = 0;
        if ( isset( $parameters['Limit'] ) ) {
            $count = $db->arrayQuery( "SELECT count(*) as count FROM ezm_pool WHERE block_id='".$block['id']."'" );
            $itemsToRemove = (int)$count[0]['count'] + count($newItems) - (int)$parameters['Limit'];
        }

        if ( !empty( $newItems ) || ( $itemsToRemove > 0 ) )
        {
            $db->begin();

            if ( $itemsToRemove > 0 )
                $db->query( "DELETE FROM ezm_pool WHERE block_id='".$block['id']."' ORDER BY ts_publication ASC LIMIT " . $itemsToRemove);
            if ( !empty( $newItems ) )
                eZFlowPool::insertItems( $newItems );

            $db->query( "UPDATE ezm_block SET last_update=$publishedBeforeOrAt WHERE id='" . $block['id'] . "'" );
            $db->commit();
        }

        return count( $newItems );
    }
1074650
public function getBlockTypesByFieldId(int $fieldId): array
    {
        if (!empty($this->_fetchedAllBlockTypesForFieldId[$fieldId])) {
            return $this->_blockTypesByFieldId[$fieldId];
        }

        $this->_blockTypesByFieldId[$fieldId] = [];

        $results = $this->_createBlockTypeQuery()
            ->where(['fieldId' => $fieldId])
            ->all();

        foreach ($results as $result) {
            $blockType = new SuperTableBlockTypeModel($result);
            $this->_blockTypesById[$blockType->id] = $blockType;
            $this->_blockTypesByFieldId[$fieldId][] = $blockType;
        }

        $this->_fetchedAllBlockTypesForFieldId[$fieldId] = true;

        return $this->_blockTypesByFieldId[$fieldId];
    }
332991
private function _readBIFF8CellRangeAddressB($subData, $baseCell = 'A1')
	{
		list($baseCol, $baseRow) = PHPExcel_Cell::coordinateFromString($baseCell);
		$baseCol = PHPExcel_Cell::columnIndexFromString($baseCol) - 1;

		// TODO: if cell range is just a single cell, should this funciton
		// not just return e.g. 'A1' and not 'A1:A1' ?

		// offset: 0; size: 2; first row
		$frIndex = self::_GetInt2d($subData, 0); // adjust below

		// offset: 2; size: 2; relative index to first row (0... 65535) should be treated as offset (-32768... 32767)
		$lrIndex = self::_GetInt2d($subData, 2); // adjust below

		// offset: 4; size: 2; first column with relative/absolute flags

		// bit: 7-0; mask 0x00FF; column index
		$fcIndex = 0x00FF & self::_GetInt2d($subData, 4);

		// bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
		if (!(0x4000 & self::_GetInt2d($subData, 4))) {
			// absolute column index
			$fc = PHPExcel_Cell::stringFromColumnIndex($fcIndex);
			$fc = '$' . $fc;
		} else {
			// column offset
			$fcIndex = ($fcIndex <= 127) ? $fcIndex : $fcIndex - 256;
			$fc = PHPExcel_Cell::stringFromColumnIndex($baseCol + $fcIndex);
		}

		// bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
		if (!(0x8000 & self::_GetInt2d($subData, 4))) {
			// absolute row index
			$fr = $frIndex + 1;
			$fr = '$' . $fr;
		} else {
			// row offset
			$frIndex = ($frIndex <= 32767) ? $frIndex : $frIndex - 65536;
			$fr = $baseRow + $frIndex;
		}

		// offset: 6; size: 2; last column with relative/absolute flags

		// bit: 7-0; mask 0x00FF; column index
		$lcIndex = 0x00FF & self::_GetInt2d($subData, 6);
		$lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256;
		$lc = PHPExcel_Cell::stringFromColumnIndex($baseCol + $lcIndex);

		// bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index)
		if (!(0x4000 & self::_GetInt2d($subData, 6))) {
			// absolute column index
			$lc = PHPExcel_Cell::stringFromColumnIndex($lcIndex);
			$lc = '$' . $lc;
		} else {
			// column offset
			$lcIndex = ($lcIndex <= 127) ? $lcIndex : $lcIndex - 256;
			$lc = PHPExcel_Cell::stringFromColumnIndex($baseCol + $lcIndex);
		}

		// bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index)
		if (!(0x8000 & self::_GetInt2d($subData, 6))) {
			// absolute row index
			$lr = $lrIndex + 1;
			$lr = '$' . $lr;
		} else {
			// row offset
			$lrIndex = ($lrIndex <= 32767) ? $lrIndex : $lrIndex - 65536;
			$lr = $baseRow + $lrIndex;
		}

		return "$fc$fr:$lc$lr";
	}
230758
private function filterActiveBlocks(Collection $blocks, Collection $active_blocks): Collection
    {
        return $blocks->map(static function (string $block_name) use ($active_blocks): ?ModuleBlockInterface {
            return $active_blocks->filter(static function (ModuleInterface $block) use ($block_name): bool {
                return $block->name() === $block_name;
            })->first();
        })->filter();
    }
1338831
public function getCacheTags(ReadBlockInterface $block)
    {
        $tags = array();

        $contents = $this->getContents($block->getAttribute('contentSearch'));;

        if ($contents) {

            foreach ($contents as $content) {
                $tags[] = $this->tagManager->formatContentIdTag($content->getContentId());

                $contentTypeTag = $this->tagManager->formatContentTypeTag($content->getContentType());
                if (!in_array($contentTypeTag, $tags)) {
                    $tags[] = $contentTypeTag;
                }
            }
        }

        return $tags;
    }