/**
  * Parse the root condition.
  *
  * @param ContainerInterface                   $container  The container where the data shall be stored.
  *
  * @param ModelRelationshipDefinitionInterface $definition The relationship definition.
  *
  * @return void
  *
  * @throws DcGeneralRuntimeException If no root data provider is defined.
  */
 protected function parseRootCondition(ContainerInterface $container, ModelRelationshipDefinitionInterface $definition)
 {
     if (($rootCondition = $this->getFromDca('dca_config/rootEntries')) !== null) {
         $rootProvider = $container->getBasicDefinition()->getRootDataProvider();
         if (!$rootProvider) {
             throw new DcGeneralRuntimeException('Root data provider name not specified in DCA but rootEntries section specified.');
         }
         if (!$container->getDataProviderDefinition()->hasInformation($rootProvider)) {
             throw new DcGeneralRuntimeException('Unknown root data provider but rootEntries section specified.');
         }
         if (isset($rootCondition[$rootProvider])) {
             $rootCondition = $rootCondition[$rootProvider];
             $mySetter = $rootCondition['setOn'];
             if (($relationship = $definition->getRootCondition()) === null) {
                 $relationship = new RootCondition();
                 $setter = $mySetter;
                 $builder = FilterBuilder::fromArrayForRoot()->getFilter();
             } else {
                 /** @var RootConditionInterface $relationship */
                 if ($relationship->getSetters()) {
                     $setter = array_merge_recursive($mySetter, $relationship->getSetters());
                 } else {
                     $setter = $mySetter;
                 }
                 $builder = FilterBuilder::fromArrayForRoot($relationship->getFilterArray())->getFilter();
             }
             $builder->append(FilterBuilder::fromArrayForRoot((array) $rootCondition['filter']));
             $relationship->setSourceName($rootProvider)->setFilterArray($builder->getAllAsArray())->setSetters($setter);
             $definition->setRootCondition($relationship);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Parse the correct conditions for a MetaModel with variant support.
  *
  * @param IMetaModelDataDefinition             $container  The data container.
  *
  * @param ModelRelationshipDefinitionInterface $definition The relationship container.
  *
  * @return RootConditionInterface
  */
 protected function getRootCondition($container, $definition)
 {
     $rootProvider = $container->getName();
     if (($relationship = $definition->getRootCondition()) === null) {
         $relationship = new RootCondition();
         $relationship->setSourceName($rootProvider);
         $definition->setRootCondition($relationship);
     }
     return $relationship;
 }