The the group of a block based on the block object.

@param BlockInterface $blockObject
@return integer
559016
protected function getBlockGroupId(BlockInterface $blockObject)
    {
        $groupClassName = $blockObject->blockGroup();
        
        $groupClassName = '\\'  . ltrim($groupClassName, '\\');
        
        $groupObject = Yii::createObject(['class' => $groupClassName]);
        
        $group = BlockGroup::findOne(['identifier' => $groupObject->identifier()]);
        
        if ($group) {
            $group->updateAttributes([
                'name' => $groupObject->label(),
                'class' => $groupClassName,
                'is_deleted' => false,
            ]);
            
            return $group->id;
        } else {
            $model = new BlockGroup();
            $model->name = $groupObject->label();
            $model->identifier = $groupObject->identifier();
            $model->created_timestamp = time();
            $model->class = $groupClassName;
            if ($model->save()) {
                $this->addLog("Insert new block group {$model->name}.");
                return $model->id;
            }
        }
        
        return 0;
    }
923654
public function show(ReadBlockInterface $block)
    {
        $nodes = $this->getNodes($block);

        if (!is_null($nodes)) {
            return $this->render(
                'OpenOrchestraDisplayBundle:Block/Menu:tree.html.twig',
                array(
                    'tree' => $nodes,
                    'id' => $block->getId(),
                    'class' => $block->getStyle(),
                )
            );
        }

        throw new NodeNotFoundException($block->getAttribute('nodeName'));
    }
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(),
            )
        );
    }
1101528
public static function getParentForm(BlockInterface $block)
    {
        $form = $block->getForm();

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

        return null !== $block->getParent()
            ? static::getParentForm($block->getParent())
            : null;
    }
794573
public function getLastValidBlockItem(Block $block)
    {
        $dbHandler = $this->getConnection();
        $q = $dbHandler->createSelectQuery();
        $q
            ->select('object_id, node_id, priority, ts_publication, ts_visible, rotation_until, moved_to')
            ->from($dbHandler->quoteTable('ezm_pool'))
            ->where(
                $q->expr->eq('block_id', $q->bindValue($block->id)),
                $q->expr->gt('ts_visible', $q->bindValue(0, null, PDO::PARAM_INT)),
                $q->expr->eq('ts_hidden', $q->bindValue(0, null, PDO::PARAM_INT))
            )
            ->orderBy('ts_visible', SelectQuery::DESC)
            ->limit(1);

        $stmt = $q->prepare();
        $stmt->execute();
        $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
        if (empty($rows)) {
            return;
        }

        return $this->buildBlockItem(
            $rows[0] + array(
                'block_id' => $block->id,
                'ts_hidden' => 0,
            )
        );
    }
588184
public function getRootVersions(BlockInterface $block)
    {
        $rootId = ($block instanceof BlockOwnerInterface) ? $block->getId() : $block->getOwner()->getId();

        /** @var BlockLogEntryRepository $repo */
        $repo = $this->em->getRepository('OpiferContentBundle:BlockLogEntry');
        $versions = $repo->findDistinctByRootId($rootId);

        return $versions;
    }
132506
public function getGutterClasses(BlockInterface $block)
    {
        $gutterStyles = array();

        if ($block->getColumnCount()) {
            $properties = $block->getProperties();
            if (isset($properties['gutters']) && count($properties['gutters']) > 0) {
                foreach ($properties['gutters'] as $screen => $cols) {
                    if (!$cols) {
                        continue;
                    }
                    foreach ($cols as $col => $span) {
                        if ($span === null) {
                            continue;
                        }
                        $gutterStyles[$col][] = "px-$screen-$span";
                    }
                }
            }
        }

        return $gutterStyles;
    }
391274
public function getSampleBlock($blockNum)
    {
        // check preconditions
        if (!$this->_dataSize_valid) {
            $this->setDataSize();  // implicit setSize(), setActualSize(), setNumBlocks()
        }

        $offset = $blockNum * $this->_blockAlign;
        if ($offset + $this->_blockAlign > $this->_dataSize || $offset < 0) {
            return null;
        }


        // read data
        return substr($this->_samples, $offset, $this->_blockAlign);
    }
994023
public function canDelete(BlockInterface $block, array $parameters)
    {
        return !$block->isTransverse() || 0 == $this->nodeRepository->countBlockUsed($block->getId());
    }
125804
public function execute(BlockInterface $block, Response $response = null, array $parameters = [])
    {
        $collection = $this->contentManager->getRepository()->findOrderedByIds(json_decode($block->getValue()));

        if ($collection) {
            $block->setCollection($collection);
        }

        return parent::execute($block, $response, $parameters);
    }
683910
protected function _getEsiData($blockObject, $esiOptions) {
        Varien_Profiler::start('turpentine::observer::esi::_getEsiData');
        $esiHelper = Mage::helper('turpentine/esi');
        $cacheTypeParam = $esiHelper->getEsiCacheTypeParam();
        $scopeParam = $esiHelper->getEsiScopeParam();
        $methodParam = $esiHelper->getEsiMethodParam();
        $esiData = new Varien_Object();
        $esiData->setStoreId(Mage::app()->getStore()->getId());
        $esiData->setDesignPackage(Mage::getDesign()->getPackageName());
        $esiData->setDesignTheme(Mage::getDesign()->getTheme('layout'));
        $esiData->setNameInLayout($blockObject->getNameInLayout());
        $esiData->setBlockType(get_class($blockObject));
        $esiData->setLayoutHandles($this->_getBlockLayoutHandles($blockObject));
        $esiData->setEsiMethod($esiOptions[$methodParam]);
        if ($esiOptions[$cacheTypeParam] == 'private' || $esiOptions[$cacheTypeParam] == 'customer_group') {
            if (is_array(@$esiOptions['flush_events'])) {
                $esiData->setFlushEvents(array_merge(
                    $esiHelper->getDefaultCacheClearEvents(),
                    array_keys($esiOptions['flush_events']) ));
            } else {
                $esiData->setFlushEvents(
                    $esiHelper->getDefaultCacheClearEvents() );
            }
        }
        if ($esiOptions[$scopeParam] == 'page') {
            $esiData->setParentUrl(Mage::app()->getRequest()->getRequestString());
        }
        if (is_array($esiOptions['dummy_blocks'])) {
            $dummyBlocks = array();
            foreach ($esiOptions['dummy_blocks'] as $key => $value) {
                $dummyBlocks[] = (empty($value) && ! is_numeric($key)) ? $key : $value;
            }
            $esiData->setDummyBlocks($dummyBlocks);
        } else {
            Mage::helper('turpentine/debug')->logWarn(
                'Invalid dummy_blocks for block: %s',
                $blockObject->getNameInLayout() );
        }
        $simpleRegistry = array();
        $complexRegistry = array();
        if (is_array($esiOptions['registry_keys'])) {
            foreach ($esiOptions['registry_keys'] as $key => $options) {
                $value = Mage::registry($key);
                if ($value) {
                    if (is_object($value) &&
                            $value instanceof Mage_Core_Model_Abstract) {
                        $complexRegistry[$key] =
                            $this->_getComplexRegistryData($options, $value);
                    } else {
                        $simpleRegistry[$key] = $value;
                    }
                }
            }
        } else {
            Mage::helper('turpentine/debug')->logWarn(
                'Invalid registry_keys for block: %s',
                $blockObject->getNameInLayout() );
        }
        $esiData->setSimpleRegistry($simpleRegistry);
        $esiData->setComplexRegistry($complexRegistry);
        Varien_Profiler::stop('turpentine::observer::esi::_getEsiData');
        return $esiData;
    }
906357
public function getCacheTags(ReadBlockInterface $block)
    {
        return array(
            $this->tagManager->formatContentTypeTag($block->getAttribute('contentTypeId')),
            $this->tagManager->formatContentIdTag($block->getAttribute('contentId'))
        );
    }
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();
    }
1044897
public function show(ReadBlockInterface $block)
    {
        $strategy = $this->getStrategy($block);
        if (null === $strategy) {
            throw new DisplayBlockStrategyNotFoundException($block->getComponent());
        }

        $this->dispatcher->dispatch(
            BlockEvents::PRE_BLOCK_RENDER,
            new BlockEvent($block)
        );

        $response = $strategy->show($block);

        $cacheStatus = CacheableInterface::CACHE_PRIVATE;
        if ($strategy->isPublic($block)) {
            $cacheStatus = CacheableInterface::CACHE_PUBLIC;
        }

        $response = $this->cacheableManager->setResponseCacheParameters(
            $response,
            $block->getMaxAge(),
            $cacheStatus
        );

        $this->dispatcher->dispatch(
            BlockEvents::POST_BLOCK_RENDER,
            new BlockEvent($block, $response)
        );

        return $response;

    }
1274160
public function show(ReadBlockInterface $block)
    {
        $contentSearch = $block->getAttribute('contentSearch');

        if (!isset($contentSearch['contentId'])) {
            throw new \InvalidArgumentException();
        }

        $contentId = $contentSearch['contentId'];
        $language = $this->currentSiteManager->getSiteLanguage();
        $content = $this->contentRepository->findPublishedVersion($contentId, $language);

        if ($content) {
            $parameters = array(
                'class' => $block->getStyle(),
                'id' => $block->getId(),
                'content' => $content
            );

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

        throw new ContentNotFoundException($contentId);
    }
393163
public function blockAccess(AccountInterface $account) {
    $current_user = \Drupal::currentUser();
    $route_user_id = \Drupal::routeMatch()->getParameter('user');

    // Show this block only on current user Groups page.
    $can_create_groups = FALSE;
    foreach (GroupType::loadMultiple() as $group_type) {
      $permissions = 'create ' . $group_type->id() . ' group';
      if ($account->hasPermission($permissions)) {
        $can_create_groups = TRUE;
        break;
      }
    }
    if ($current_user->id() == $route_user_id && $can_create_groups) {
      return AccessResult::allowed();
    }

    // By default, the block is not visible.
    return AccessResult::forbidden();
  }
356597
public function getCacheKeys(BlockInterface $block)
    {
        $settings = $block->getSettings();

        $keys = parent::getCacheKeys($block);

        $keys['environment'] = $this->getContainer()->get('kernel')->getEnvironment();

        if (isset($settings['template'])) {
            $keys['template'] = $settings['template'];
        }

        if (isset($settings['id'])) {
            $key = $this->getName() . ':' . $settings['id'];

            if (isset($settings['template'])) {
                $key = $key . ':' . $settings['template'];
            }

            $keys['block_id'] = $key;
        }

        $keys['updated_at'] = '';

        return $keys;
    }