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);
}
}