Neos\Flow\Property\PropertyMappingConfigurationBuilder::build PHP Метод

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

Builds the default property mapping configuration.
См. также: PropertyMapper::buildPropertyMappingConfiguration
Устаревший: fully replace by PropertyMapper::buildPropertyMappingConfiguration and removed in next major Flow version
public build ( string $type = PropertyMappingConfiguration::class ) : PropertyMappingConfiguration
$type string the implementation class name of the PropertyMappingConfiguration to instantiate; must be a subclass of PropertyMappingConfiguration
Результат PropertyMappingConfiguration
    public function build($type = PropertyMappingConfiguration::class)
    {
        $configuration = new $type();
        $configuration->setTypeConverterOptions(TypeConverter\PersistentObjectConverter::class, [TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED => true, TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED => true]);
        $configuration->allowAllProperties();
        return $configuration;
    }

Usage Example

 /**
  * Publishes or discards the given nodes
  *
  * @param array $nodes <\Neos\ContentRepository\Domain\Model\NodeInterface> $nodes
  * @param string $action
  * @param Workspace $selectedWorkspace
  * @throws \Exception
  * @throws \Neos\Flow\Property\Exception
  * @throws \Neos\Flow\Security\Exception
  */
 public function publishOrDiscardNodesAction(array $nodes, $action, Workspace $selectedWorkspace = null)
 {
     $propertyMappingConfiguration = $this->propertyMappingConfigurationBuilder->build();
     $propertyMappingConfiguration->setTypeConverterOption(NodeConverter::class, NodeConverter::REMOVED_CONTENT_SHOWN, true);
     foreach ($nodes as $key => $node) {
         $nodes[$key] = $this->propertyMapper->convert($node, NodeInterface::class, $propertyMappingConfiguration);
     }
     switch ($action) {
         case 'publish':
             foreach ($nodes as $node) {
                 $this->publishingService->publishNode($node);
             }
             $this->addFlashMessage($this->translator->translateById('workspaces.selectedChangesHaveBeenPublished', [], null, null, 'Modules', 'Neos.Neos'));
             break;
         case 'discard':
             $this->publishingService->discardNodes($nodes);
             $this->addFlashMessage($this->translator->translateById('workspaces.selectedChangesHaveBeenDiscarded', [], null, null, 'Modules', 'Neos.Neos'));
             break;
         default:
             throw new \RuntimeException('Invalid action "' . htmlspecialchars($action) . '" given.', 1346167441);
     }
     $this->redirect('show', null, null, ['workspace' => $selectedWorkspace]);
 }
PropertyMappingConfigurationBuilder