Neos\Flow\Http\Component\ComponentChainFactory::create PHP Метод

create() публичный Метод

public create ( array $chainConfiguration ) : ComponentChain
$chainConfiguration array
Результат ComponentChain
    public function create(array $chainConfiguration)
    {
        if (empty($chainConfiguration)) {
            return null;
        }
        $arraySorter = new PositionalArraySorter($chainConfiguration);
        $sortedChainConfiguration = $arraySorter->toArray();
        $chainComponents = [];
        foreach ($sortedChainConfiguration as $componentName => $configuration) {
            $componentOptions = isset($configuration['componentOptions']) ? $configuration['componentOptions'] : [];
            if (isset($configuration['chain'])) {
                $component = $this->create($configuration['chain']);
            } else {
                if (!isset($configuration['component'])) {
                    throw new Exception(sprintf('Component chain could not be created because no component class name is configured for component "%s"', $componentName), 1401718283);
                }
                $component = $this->objectManager->get($configuration['component'], $componentOptions);
                if (!$component instanceof ComponentInterface) {
                    throw new Exception(sprintf('Component chain could not be created because the class "%s" does not implement the ComponentInterface, in component "%s" does not implement', $configuration['component'], $componentName), 1401718283);
                }
            }
            $chainComponents[] = $component;
        }
        return new ComponentChain(['components' => $chainComponents]);
    }

Usage Example

 /**
  * @test
  * @expectedException \Neos\Flow\Http\Component\Exception
  */
 public function createThrowsExceptionIfComponentClassNameDoesNotImplementComponentInterface()
 {
     $chainConfiguration = ['foo' => ['component' => 'Foo\\Component\\ClassName']];
     $this->mockObjectManager->expects($this->at(0))->method('get')->with('Foo\\Component\\ClassName')->will($this->returnValue(new \stdClass()));
     $this->componentChainFactory->create($chainConfiguration);
 }
ComponentChainFactory