/** * {@inheritdoc} */ public function match(ModelInterface $model = null, PropertyValueBag $input = null, PropertyInterface $property = null, LegendInterface $legend = null) { if ($property === null) { return false; } /** @var $model \MetaModels\DcGeneral\Data\Model */ $nativeItem = $model->getItem(); $metaModel = $nativeItem->getMetaModel(); if ($metaModel->hasVariants() && !$nativeItem->isVariantBase()) { return !in_array($property->getName(), array_keys($metaModel->getInVariantAttributes())); } return true; }
/** * Add a visible condition. * * @param PropertyInterface $property The property. * * @param ConditionInterface $condition The condition to add. * * @return void */ protected function addCondition(PropertyInterface $property, ConditionInterface $condition) { $chain = $property->getVisibleCondition(); if (!($chain && $chain instanceof PropertyConditionChain && $chain->getConjunction() == PropertyConditionChain::AND_CONJUNCTION)) { if ($property->getVisibleCondition()) { $previous = array($property->getVisibleCondition()); } else { $previous = array(); } $chain = new PropertyConditionChain($previous, PropertyConditionChain::AND_CONJUNCTION); $property->setVisibleCondition($chain); } $chain->addCondition($condition); }
/** * Add a condition to a property. * * @param PropertyInterface $property The property. * * @param ConditionInterface $condition The condition to add. * * @return void */ protected function addCondition($property, $condition) { $currentCondition = $property->getVisibleCondition(); if (!$currentCondition instanceof ConditionChainInterface || $currentCondition->getConjunction() != ConditionChainInterface::OR_CONJUNCTION) { if ($currentCondition === null) { $currentCondition = new PropertyConditionChain(array($condition)); } else { $currentCondition = new PropertyConditionChain(array($currentCondition, $condition)); } $currentCondition->setConjunction(ConditionChainInterface::OR_CONJUNCTION); $property->setVisibleCondition($currentCondition); } else { $currentCondition->addCondition($condition); } }