Skip to content

Instantly share code, notes, and snippets.

@radmiraal
Created April 20, 2012 15:05
Show Gist options
  • Save radmiraal/2429440 to your computer and use it in GitHub Desktop.
Save radmiraal/2429440 to your computer and use it in GitHub Desktop.
public function compile() {
// "driver" is used only for Doctrine, thus we (mis-)use it here
// additionally, when no path is set, skip this step, assuming no DB is needed
if ($this->settings['backendOptions']['driver'] !== NULL && $this->settings['backendOptions']['path'] !== NULL) {
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
///// Why this check?
if ($this->settings['backendOptions']['driver'] === 'pdo_sqlite') {
$schemaTool->createSchema($this->entityManager->getMetadataFactory()->getAllMetadata());
} else {
$schemaTool->updateSchema($this->entityManager->getMetadataFactory()->getAllMetadata());
}
$proxyFactory = $this->entityManager->getProxyFactory();
$proxyFactory->generateProxyClasses($this->entityManager->getMetadataFactory()->getAllMetadata());
$this->systemLogger->log('Doctrine 2 setup finished');
//// Isn't this now always returning true if nothing fatal happens?
return TRUE;
} else {
$this->systemLogger->log('Doctrine 2 setup skipped, driver and path backend options not set!', LOG_NOTICE);
return FALSE;
}
}
@radmiraal
Copy link
Author

public function compile() {
        // "driver" is used only for Doctrine, thus we (mis-)use it here
        // additionally, when no path is set, skip this step, assuming no DB is needed
    if ($this->settings['backendOptions']['driver'] !== NULL && $this->settings['backendOptions']['path'] !== NULL) {
        try {
            $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
            $schemaTool->createSchema($this->entityManager->getMetadataFactory()->getAllMetadata());

            $proxyFactory = $this->entityManager->getProxyFactory();
            $proxyFactory->generateProxyClasses($this->entityManager->getMetadataFactory()->getAllMetadata());

            $this->systemLogger->log('Doctrine 2 setup finished');
            return TRUE;
        } catch (\Exception $e) {
            $this->systemLogger->log('Doctrine 2 setup skipped, something fatal happened :p !', LOG_NOTICE);
            return FALSE;
        }
    } else {
        $this->systemLogger->log('Doctrine 2 setup skipped, driver and path backend options not set!', LOG_NOTICE);
        return FALSE;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment