/** * @return int */ public function createWindowsState() { /** @var AbstractWindowsState $state */ $state = $this->doctrineHelper->createEntityInstance($this->className); $state->setData($this->requestStateManager->getData()); $state->setUser($this->getUser()); $em = $this->doctrineHelper->getEntityManagerForClass($this->className); $em->persist($state); $em->flush($state); return $state->getId(); }
/** * Finds parent doctrine entities for given entity class name * * @param string $className * * @return string[] */ protected function loadParents($className) { $result = []; $reflection = new \ReflectionClass($className); $parentClass = $reflection->getParentClass(); while ($parentClass) { $parentClassName = $parentClass->getName(); // a parent class should be: // - not extended entity proxy // - registered in Doctrine, for example Entity or MappedSuperclass if (strpos($parentClassName, ExtendHelper::ENTITY_NAMESPACE) !== 0) { $em = $this->doctrineHelper->getEntityManagerForClass($className, false); if ($em && !$em->getMetadataFactory()->isTransient($parentClassName)) { $result[] = $parentClassName; } } $reflection = new \ReflectionClass($parentClassName); $parentClass = $reflection->getParentClass(); } return $result; }
public function testGetEntityManagerForClassNotManageableEntityWithoutThrowException() { $class = 'ItemStub'; $this->registry->expects($this->once())->method('getManagerForClass')->with($class)->will($this->returnValue(null)); $this->assertNull($this->doctrineHelper->getEntityManagerForClass($class, false)); }