/**
  * Checks whether the translations table exists in the database
  *
  * @return bool
  */
 protected function checkDatabase()
 {
     if (null === $this->dbCheck) {
         $this->dbCheck = SafeDatabaseChecker::tablesExist($this->getEntityManager()->getConnection(), SafeDatabaseChecker::getTableName($this->doctrine, Translation::ENTITY_NAME));
     }
     return $this->dbCheck;
 }
 /**
  * @return bool
  */
 public function checkDatabase()
 {
     if (null !== $this->dbCheck) {
         return $this->dbCheck;
     }
     if ($this->lockObject->isLocked()) {
         return true;
     }
     $this->dbCheck = SafeDatabaseChecker::tablesExist($this->getEntityManager()->getConnection(), $this->requiredTables);
     return $this->dbCheck;
 }
 /**
  * @return string[]
  */
 protected function getSupportedEntityClasses()
 {
     $entities = [];
     $entityManagers = $this->entityManagerBag->getEntityManagers();
     foreach ($entityManagers as $em) {
         $allMetadata = SafeDatabaseChecker::getAllMetadata($em);
         foreach ($allMetadata as $metadata) {
             if ($metadata->isMappedSuperclass) {
                 continue;
             }
             if ($this->entityExclusionProvider->isIgnoredEntity($metadata->name)) {
                 continue;
             }
             $entities[] = $metadata->name;
         }
     }
     return $entities;
 }
 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition(self::SERVICE_KEY)) {
         return;
     }
     if (!$container->hasParameter('installed') || !$container->getParameter('installed')) {
         return;
     }
     // register event listeners
     // by performance reasons native SQL is used here rather than ORM
     // ORM usage leads unnecessary loading of Doctrine metadata and ORO entity configs which is not needed here
     /** @var Connection $connection */
     $connection = $container->get('doctrine.dbal.default_connection');
     if (SafeDatabaseChecker::tablesExist($connection, self::EVENT_TABLE_NAME)) {
         $dispatcher = $container->findDefinition(self::DISPATCHER_KEY);
         $rows = $connection->fetchAll('SELECT name FROM ' . self::EVENT_TABLE_NAME);
         foreach ($rows as $row) {
             $dispatcher->addMethodCall('addListenerService', [$row['name'], [self::SERVICE_KEY, 'process']]);
         }
     }
 }
 /**
  * Check if user table exists in db
  *
  * @return bool
  */
 protected function checkDatabase()
 {
     $className = $this->getOwnershipMetadataProvider()->getBasicLevelClass();
     return SafeDatabaseChecker::tablesExist($this->getManagerForClass($className)->getConnection(), SafeDatabaseChecker::getTableName($this->getContainer()->get('doctrine'), $className));
 }
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage unexpected
  */
 public function testGetAllMetadataShouldRethrowUnexpectedException()
 {
     $em = $this->getMock('Doctrine\\ORM\\EntityManagerInterface');
     $em->expects($this->once())->method('getMetadataFactory')->willThrowException(new \Exception('unexpected'));
     SafeDatabaseChecker::getAllMetadata($em);
 }
 /**
  * Makes sure that aliases for all entities are loaded
  */
 protected function ensureAllAliasesLoaded()
 {
     if ($this->allAliasesLoaded) {
         return;
     }
     $allMetadata = SafeDatabaseChecker::getAllMetadata($this->doctrine->getManager());
     foreach ($allMetadata as $metadata) {
         if (!$metadata->isMappedSuperclass && !isset($this->aliases[$metadata->name])) {
             $this->findEntityAlias($metadata->name);
         }
     }
     $this->allAliasesLoaded = true;
 }
Beispiel #8
0
 /**
  * Checks whether the translations table exists in the database
  *
  * @return bool
  */
 protected function checkDatabase()
 {
     if (null === $this->dbCheck) {
         $doctrine = $this->container->get('doctrine');
         $this->dbCheck = SafeDatabaseChecker::tablesExist($doctrine->getManagerForClass(Translation::ENTITY_NAME)->getConnection(), SafeDatabaseChecker::getTableName($doctrine, Translation::ENTITY_NAME));
     }
     return $this->dbCheck;
 }
Beispiel #9
0
 /**
  * Check if the given table exists in a database
  *
  * @param string $tableName
  * @return bool TRUE if a table exists; otherwise, FALSE
  */
 public function isTableExist($tableName)
 {
     return SafeDatabaseChecker::tablesExist($this->connection, $tableName);
 }