Get list of relative properties that this relationship can be sorted by
public getSortableBy ( ) : |
||
Результат |
/** * Re-test and update inverted sort-by columns for maintained relationship entities * * Entities in a relationship that are not maintained (added or removed) will be updated when the entire * relationship is added/removed * * @param Relationship $inverse_relationship Inverted relationship * @param string[] $maintain Array of foreign ID's that are the maintained part of the relationship * @param Reader $reader Local entity reader * @param string $local_id Local ID */ private function updateMaintainedRelationshipSortIndices(Relationship $inverse_relationship, $maintain, Reader $reader, $local_id) { if (!$inverse_relationship->getSortableBy()) { return; } // Update unchanged relationships, as the sort-by column or conditions may have changed foreach ($maintain as $foreign_id) { foreach ($inverse_relationship->getSortableBy() as $sortable) { $index_key = $this->getSortIndexKey($inverse_relationship, $sortable->getName(), $foreign_id); // Test conditions foreach ($sortable->getConditions() as $condition) { if ($condition->getColumn()) { if (!$condition->test($reader->getPropertyValue($condition->getColumn()))) { // Condition failed, remove index $this->getDriver()->removeSortedIndex($index_key, $local_id); continue 2; } } elseif ($condition->getMethod()) { if (!$condition->test($reader->getMethodValue($condition->getMethod()))) { // Condition failed, remove index $this->getDriver()->removeSortedIndex($index_key, $local_id); continue 2; } } } // Add/update inverse index $this->getDriver()->addSortedIndex($index_key, $reader->getPropertyValue($sortable->getColumn()), $local_id); } } }