public function testChildElementCreation() { $databaseElementConfig = (include __DIR__ . '/../conf-example/auth/database.php'); $entityWrapper = new EntityWrapper($databaseElementConfig); static::assertFalse($entityWrapper->isRootEntity()); static::assertSame($databaseElementConfig['parent'], $entityWrapper->getParentName()); static::assertSame($databaseElementConfig['parentProperty'], $entityWrapper->getParentPropertyName()); static::assertSame($databaseElementConfig['class'], $entityWrapper->getClassName()); static::assertInstanceOf($databaseElementConfig['class'], $entityWrapper->createConfigurationObject()); }
/** * @param EntityWrapper $entity */ private function triggerNewEntity(EntityWrapper $entity) { if ($entity->isRootEntity()) { $entityMapLink =& $this->rootEntities[$entity->getClassName()]; } else { $entityMapLink =& $this->entities[$entity->getParentName()][$entity->getClassName()][$entity->getParentPropertyName()]; } if (!$entity->isRootEntity() && array_key_exists($entity->getParentName(), $this->rootEntities)) { $this->rootEntities[$entity->getParentName()]['content'][] =& $entityMapLink; } if (array_key_exists($entity->getClassName(), $this->entities)) { foreach ($this->entities[$entity->getClassName()] as &$child) { foreach ($child as &$childProperty) { $entityMapLink['content'][] =& $childProperty; } unset($childProperty); } unset($child); } if (!$this->rootEntities) { foreach ($this->entities as &$parentRootElement) { if (array_key_exists($entity->getParentName(), $parentRootElement)) { foreach ($parentRootElement[$entity->getParentName()] as &$parent) { $parent['content'][] =& $entityMapLink; } unset($parent); } } unset($parentRootElement); } }