/**
  * @param string|BlockTypeInterface $blockType
  *
  * @return OptionsResolverInterface
  */
 protected function getOptionResolver($blockType)
 {
     if ($blockType instanceof BlockTypeInterface) {
         $name = $blockType->getName();
         $type = $blockType;
     } else {
         $name = $blockType;
         $type = null;
     }
     if (!isset($this->resolvers[$name])) {
         if (!$type) {
             $type = $this->registry->getType($name);
         }
         $parentName = $type->getParent();
         $optionsResolver = $parentName ? clone $this->getOptionResolver($parentName) : new OptionsResolver();
         $type->setDefaultOptions($optionsResolver);
         $this->registry->setDefaultOptions($name, $optionsResolver);
         $this->resolvers[$name] = $optionsResolver;
     }
     return $this->resolvers[$name];
 }
Exemple #2
0
 /**
  * Finishes the building of the block view
  *
  * @param BlockView $view
  * @param string    $id
  */
 protected function finishBlockView(BlockView $view, $id)
 {
     $blockType = $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE, true);
     $options = $this->rawLayout->getProperty($id, RawLayout::RESOLVED_OPTIONS, true);
     $types = $this->typeHelper->getTypes($blockType);
     // point the block view state to the current block
     $this->block->initialize($id);
     // finish the view
     foreach ($types as $type) {
         $type->finishView($view, $this->block, $options);
         $this->registry->finishView($type->getName(), $view, $this->block, $options);
     }
 }
Exemple #3
0
 /**
  * @param string                  $blockTypeName
  * @param LayoutRegistryInterface $registry
  *
  * @return DebugOptionsResolver
  */
 protected function getBlockTypeOptionsResolver($blockTypeName, LayoutRegistryInterface $registry)
 {
     $type = $registry->getType($blockTypeName);
     $parentName = $type->getParent();
     $optionsResolver = $parentName ? clone $this->getBlockTypeOptionsResolver($parentName, $registry) : new DebugOptionsResolver();
     $type->setDefaultOptions($optionsResolver);
     $registry->setDefaultOptions($blockTypeName, $optionsResolver);
     return $optionsResolver;
 }