/** * Returns an array of constraints created from a given demand object. * * @param Tx_Extbase_Persistence_QueryInterface $query * @param Tx_News_Domain_Model_DemandInterface $demand * @return array<Tx_Extbase_Persistence_QOM_Constrain> */ protected function createConstraintsFromDemand(Tx_Extbase_Persistence_QueryInterface $query, Tx_News_Domain_Model_DemandInterface $demand) { $constraints = array(); // Storage page if ($demand->getStoragePage() != 0) { $pidList = t3lib_div::intExplode(',', $demand->getStoragePage(), TRUE); $constraints[] = $query->in('pid', $pidList); } // Clean not used constraints foreach ($constraints as $key => $value) { if (is_null($value)) { unset($constraints[$key]); } } return $constraints; }
/** * Builds and returns the constraint for multi value properties. * * @param Tx_Extbase_Persistence_QueryInterface $query * @param Tx_Extbase_DomainObject_DomainObjectInterface $parentObject * @param string $propertyName * @param string $fieldValue * @param array $relationTableMatchFields * @return Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint */ protected function getConstraint(Tx_Extbase_Persistence_QueryInterface $query, Tx_Extbase_DomainObject_DomainObjectInterface $parentObject, $propertyName, $fieldValue = '', $relationTableMatchFields = array()) { $columnMap = $this->getDataMap(get_class($parentObject))->getColumnMap($propertyName); if ($columnMap->getParentKeyFieldName() !== NULL) { $constraint = $query->equals($columnMap->getParentKeyFieldName(), $parentObject); if ($columnMap->getParentTableFieldName() !== NULL) { $constraint = $query->logicalAnd($constraint, $query->equals($columnMap->getParentTableFieldName(), $this->getDataMap(get_class($parentObject))->getTableName())); } } else { $constraint = $query->in('uid', t3lib_div::intExplode(',', $fieldValue)); } if (count($relationTableMatchFields) > 0) { foreach ($relationTableMatchFields as $relationTableMatchFieldName => $relationTableMatchFieldValue) { $constraint = $query->logicalAnd($constraint, $query->equals($relationTableMatchFieldName, $relationTableMatchFieldValue)); } } return $constraint; }