/** * Builds the block * * @param string $id */ protected function buildBlock($id) { $blockType = $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE, true); $options = $this->rawLayout->getProperty($id, RawLayout::OPTIONS, true); $types = $this->typeHelper->getTypes($blockType); // resolve options $resolvedOptions = $this->optionsResolver->resolveOptions($blockType, $options); $this->rawLayout->setProperty($id, RawLayout::RESOLVED_OPTIONS, $resolvedOptions); // point the block builder state to the current block $this->blockBuilder->initialize($id); // iterate from parent to current foreach ($types as $type) { $type->buildBlock($this->blockBuilder, $resolvedOptions); $this->registry->buildBlock($type->getName(), $this->blockBuilder, $resolvedOptions); } }
public function testResolveOptionsForBaseTypeByAlreadyCreatedBlockTypeObject() { $this->registry->expects($this->never())->method('getType'); $result = $this->blockOptionsResolver->resolveOptions(new BaseType(), ['translation_domain' => 'test']); $this->assertEquals('test', $result['translation_domain']); }
/** * Asks the given block type to resolve options * * @param string|BlockTypeInterface $blockType * @param array $options * * @return array The resolved options */ protected function resolveOptions($blockType, array $options) { $blockOptionsResolver = new BlockOptionsResolver($this->layoutFactory->getRegistry()); return $blockOptionsResolver->resolveOptions($blockType, $options); }