protected function addProperties(array $properties) { $path = $this->lookupPath(self::class, FALSE); $delimiter = strpos($path, '-'); if ($delimiter !== FALSE) { $path = substr($path, 0, $delimiter); } $parent = $this->lookup(self::class, FALSE); if ($path && $parent instanceof self) { $parentProperty = $parent->getMetadata()->getProperty($path); if ($parentProperty->relationship && !$parentProperty->relationship->property) { $parent->relations[$path] = $this->getEntity(); } } foreach ($properties as $metadata) { if (in_array($metadata->name, $this->metadata->getPrimaryKey())) { continue; } if ($path && $parent instanceof self && is_subclass_of($metadata->container, Nextras\Orm\Relationships\HasOne::class)) { if ($metadata->relationship && $metadata->relationship->property === $path && $metadata->relationship->repository === get_class($parent->getRepository())) { $this->relations[$metadata->name] = $parent->getEntity(); continue; } } $this->addProperty($metadata); } }
protected function getterId() { $keys = $this->metadata->getPrimaryKey(); if (count($keys) === 1) { return $this->getRawValue($keys[0]); } else { $primary = []; foreach ($keys as $key) { $primary[] = $this->getRawValue($key); } return $primary; } }
private function setterPrimaryProxy($value, PropertyMetadata $metadata) { $keys = $this->metadata->getPrimaryKey(); if (!$metadata->isVirtual) { return $value; } if (count($keys) !== count($value)) { $class = get_class($this); throw new InvalidStateException("Value for {$class}::\$id has insufficient number of parameters."); } $value = (array) $value; foreach ($keys as $key) { $this->setRawValue($key, array_shift($value)); } return IEntity::SKIP_SET_VALUE; }