public function onBlock(BlockEvent $event)
    {
        $context = $event->getSetting('context', null);

        if (null === $context) {
            return;
        }

        foreach ($this->blockServices as $type => $blockService) {
            if ($blockService->handleContext($context)) {
                $block = new Block();
                $block->setId(uniqid());
                $block->setSettings($event->getSettings());
                $block->setType($type);

                $event->addBlock($block);

                return;
            }
        }
    }
public function onBlock(BlockEvent $event)
    {
        $context = $event->getSetting('context', null);

        if (null === $context) {
            return;
        }

        foreach ($this->blockServices as $type => $blockService) {
            if ($blockService->handleContext($context)) {
                $block = new Block();
                $block->setId(uniqid());
                $block->setSettings($event->getSettings());
                $block->setType($type);

                $event->addBlock($block);

                return;
            }
        }
    }
public function onBlock ( BlockEvent $ event ) { $ context = $ event -> getSetting ( 'context' , null ) ; if ( null === $ context ) { return ; } foreach ( $ this -> blockServices as $ type => $ blockService ) { if ( $ blockService -> handleContext ( $ context ) ) { $ block = new Block ( ) ; $ block -> setId ( uniqid ( ) ) ; $ block -> setSettings ( $ event -> getSettings ( ) ) ; $ block -> setType ( $ type ) ; $ event -> addBlock ( $ block ) ; return ; } } }
Add context related BlockService, if found.

@param BlockEvent $event
Add context related BlockService if found .