Get the value of a property on the entity
public getPropertyValue ( string $name ) : mixed | ||
$name | string | |
return | mixed |
/** * Serialise the entity * * @param Entity $metadata * @param object $entity * @return SerialisedData */ public function serialise(Entity $metadata, $entity) { $data = new \stdClass(); $reader = new Reader($metadata, $entity); foreach ($metadata->getColumns() as $column) { $this->assignValue($data, $column, $reader->getPropertyValue($column->getProperty())); } return new SerialisedData(self::SERIALISER_CODE, json_encode($data, self::ENCODE_OPTIONS, self::ENCODE_DEPTH)); }
/** * 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); } } }