Processes a POST request to subscribe.

@param Block $block

@return Response
487750
public function subscribeAction(Block $block)
    {
        $response = $this->execute($block);
        $properties = $block->getProperties();

        if ($this->subscribed && isset($properties['responseType']) && $properties['responseType'] == 'redirect') {
            $content = $this->contentManager->getRepository()->find($properties['responseContent']);
            $response = new RedirectResponse($this->router->generate('_content', ['slug' => $content->getSlug()]));
        }
        
        return $response;
    }
1326085
public function setBlock($block)
    {
        $block = strtolower($block);
        if (!in_array($block, array('yes', 'no'))) {
            /**
             * @see Zend_Feed_Builder_Exception
             */
            require_once 'Zend/Feed/Builder/Exception.php';
            throw new Zend_Feed_Builder_Exception("you have to set yes or no to the itunes block property");
        }
        $this->offsetSet('block', $block);
        return $this;
    }
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');
		}
	}
186472
protected function createResponse(BlockContextInterface $blockContext, Response $response = null)
    {
        if (null === $response) {
            $response = new Response();
        }

        // set the ttl from the block instance, this can be changed by the BlockService
        if (($ttl = $blockContext->getBlock()->getTtl()) > 0) {
            $response->setTtl($ttl);
        }

        return $response;
    }
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;

    }
1368122
public function includeTranslations(Block $block)
    {
        $translations = $block->translations;
        return $this->collection($translations, new BlockTranslationTransformer());
    }
367715
private function createBlockCollectionsStatus(Block $block, int $newStatus): void
    {
        $collectionReferences = $this->loadCollectionReferences($block);

        foreach ($collectionReferences as $collectionReference) {
            $collection = $this->collectionHandler->loadCollection(
                $collectionReference->collectionId,
                $collectionReference->collectionStatus
            );

            $collection = $this->collectionHandler->createCollectionStatus(
                $collection,
                $newStatus
            );

            $newCollectionReference = CollectionReference::fromArray(
                [
                    'blockId' => $block->id,
                    'blockStatus' => $newStatus,
                    'collectionId' => $collection->id,
                    'collectionStatus' => $collection->status,
                    'identifier' => $collectionReference->identifier,
                ]
            );

            $this->queryHandler->createCollectionReference($newCollectionReference);
        }
    }
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;
    }
400191
public function handle(Block $block, Language $language)
    {
        $html = $this->getFromCache($block, $language);
        if ($html !== null) {
            return $html;
        }
        $html = view('gzero-cms::blocks.basic', [
            'block' => $block
        ])->render();
        $this->putInCache($block, $language, $html);
        return $html;
    }
980514
public function update(User $user, Block $block)
    {

        if ($user->canDo('block.block.update') && $user->isAdmin()) {
            return true;
        }

        return $user->id == $block->user_id;
    }
722278
private function convert(SirTrevorBlock $block)
    {
        foreach ($this->converters as $converter) {
            if ($converter->matches($block->getType())) {
                return $converter->toHtml($block->getData());
            }
        }
    }
609468
public function callBlock(string $block = '', ...$params): ?string
    {
        /** @var ModuleBlockInterface|null $module */
        $module = $this->module_service
            ->findByComponent(ModuleBlockInterface::class, $this->tree, Auth::user())
            ->first(static function (ModuleInterface $module) use ($block): bool {
                return $module->name() === $block && $module->name() !== 'html';
            });

        if ($module === null) {
            return '';
        }

        // Build the config array
        $cfg = [];
        foreach ($params as $config) {
            $bits = explode('=', $config);

            if (count($bits) < 2) {
                continue;
            }

            $v       = array_shift($bits);
            $cfg[$v] = implode('=', $bits);
        }

        return $module->getBlock($this->tree, 0, '', $cfg);
    }
98308
public function start($block)
    {
        if ($this->enabled) {
            if (!isset($this->blocks[$block])) {
                $this->blocks[$block] = array();
            }

            $this->blocks[$block]['start'] = microtime(true);
            $this->blocks[$block]['start-line'] = $this->getLineNumber();
        }
    }
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);
    }
451573
protected function compileNestedBlock(Block $block, $selectors)
    {
        $this->pushEnv($block);

        $this->scope = $this->makeOutputBlock($block->type, $selectors);
        $this->scope->parent->children[] = $this->scope;

        // wrap assign children in a block
        foreach ($block->children as $k => $child) {
            if ($child[0] === Type::T_ASSIGN) {
                $wrapped = new Block;
                $wrapped->sourceName   = $block->sourceName;
                $wrapped->sourceIndex  = $block->sourceIndex;
                $wrapped->sourceLine   = $block->sourceLine;
                $wrapped->sourceColumn = $block->sourceColumn;
                $wrapped->selectors    = [];
                $wrapped->comments     = [];
                $wrapped->parent       = $block;
                $wrapped->children     = [$child];
                $wrapped->selfParent   = $block->selfParent;

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

        $this->compileChildrenNoReturn($block->children, $this->scope);

        $this->scope = $this->scope->parent;

        $this->popEnv();
    }
310110
public function addChild(Block $block)
    {
        $type = get_class($block);
        if (!isset($this->children[$type])) {
            $this->children[$type] = array();
        }
        $this->children[$type][] = $block;
    }
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);
        }
    }