/**
  * Parse the root condition.
  *
  * @param ModelRelationshipDefinitionInterface $definition The relationship definition.
  *
  * @return void
  *
  * @throws DcGeneralRuntimeException If no root data provider is defined.
  */
 protected function parseParentChildConditions(ModelRelationshipDefinitionInterface $definition)
 {
     if (($childConditions = $this->getFromDca('dca_config/childCondition')) !== null) {
         foreach ((array) $childConditions as $childCondition) {
             /** @var ParentChildConditionInterface $relationship */
             $relationship = $definition->getChildCondition($childCondition['from'], $childCondition['to']);
             if (!$relationship instanceof ParentChildConditionInterface) {
                 $relationship = new ParentChildCondition();
                 $relationship->setSourceName($childCondition['from'])->setDestinationName($childCondition['to']);
                 $definition->addChildCondition($relationship);
                 $setter = $childCondition['setOn'];
                 $inverse = $childCondition['inverse'];
             } else {
                 $setter = array_merge_recursive((array) $childCondition['setOn'], $relationship->getSetters());
                 $inverse = array_merge_recursive((array) $childCondition['inverse'], $relationship->getInverseFilterArray());
             }
             $relationship->setFilterArray(FilterBuilder::fromArray($relationship->getFilterArray())->getFilter()->append(FilterBuilder::fromArray((array) $childCondition['filter']))->getAllAsArray())->setSetters($setter)->setInverseFilterArray($inverse);
         }
     }
 }
Beispiel #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 void
  */
 protected function addParentCondition(IMetaModelDataDefinition $container, $definition)
 {
     $inputScreen = $this->getInputScreenDetails();
     if ($inputScreen->isStandalone()) {
         return;
     }
     $setter = array(array('to_field' => 'pid', 'from_field' => 'id'));
     $inverse = array();
     /** @var ParentChildConditionInterface $relationship */
     $relationship = $definition->getChildCondition($inputScreen->getParentTable(), $container->getName());
     if (!$relationship instanceof ParentChildConditionInterface) {
         $relationship = new ParentChildCondition();
         $relationship->setSourceName($inputScreen->getParentTable())->setDestinationName($container->getName());
         $definition->addChildCondition($relationship);
     } else {
         $setter = array_merge_recursive($setter, $relationship->getSetters());
         $inverse = array_merge_recursive($inverse, $relationship->getInverseFilterArray());
     }
     // For tl_ prefix, the only unique target can be the id?
     // maybe load parent dc and scan for unique in config then.
     $relationship->setFilterArray(FilterBuilder::fromArray($relationship->getFilterArray())->getFilter()->andRemotePropertyEquals('pid', 'id')->getAllAsArray())->setSetters($setter)->setInverseFilterArray($inverse);
 }