Skip to content
Browse files

refactor: cannot use Project public property to store zf Application …

…either; resort to storing only the bootstrap file string, and let each dependent Task initiate their own zf Application
  • Loading branch information...
1 parent 174c107 commit 899f2dccafe008d12a47ac6fdb2ceb72a49e2fe3 heartsentwined committed
View
15 src/task/DoctrineDropTask.php
@@ -54,9 +54,18 @@ public function main()
{
static $em;
if ($em === null) {
- $em = $this->project->zf
- //$em = $this->project->getProperty('zf')
- ->getServiceManager()->get($this->em);
+ $wd = getcwd();
+ $zf = $this->project->getProperty('zf');
+ $application = require $zf;
+ if (!$application instanceof Application) {
+ throw new BuildException(sprintf(
+ 'zf bootstrap file "%s" should return an instance of Zend\Mvc\Application',
+ $zf
+ ));
+ }
+ chdir($wd);
+
+ $em = $application->getServiceManager()->get($this->em);
}
$tool = new SchemaTool($em);
View
15 src/task/DoctrineEntityTask.php
@@ -92,9 +92,18 @@ public function main()
{
static $em;
if ($em === null) {
- $em = $this->project->zf
- //$em = $this->project->getProperty('zf')
- ->getServiceManager()->get($this->em);
+ $wd = getcwd();
+ $zf = $this->project->getProperty('zf');
+ $application = require $zf;
+ if (!$application instanceof Application) {
+ throw new BuildException(sprintf(
+ 'zf bootstrap file "%s" should return an instance of Zend\Mvc\Application',
+ $zf
+ ));
+ }
+ chdir($wd);
+
+ $em = $application->getServiceManager()->get($this->em);
}
$cmf = new DisconnectedClassMetadataFactory();
View
15 src/task/DoctrineProxyTask.php
@@ -90,9 +90,18 @@ public function main()
{
static $em;
if ($em === null) {
- $em = $this->project->zf
- //$em = $this->project->getProperty('zf')
- ->getServiceManager()->get($this->em);
+ $wd = getcwd();
+ $zf = $this->project->getProperty('zf');
+ $application = require $zf;
+ if (!$application instanceof Application) {
+ throw new BuildException(sprintf(
+ 'zf bootstrap file "%s" should return an instance of Zend\Mvc\Application',
+ $zf
+ ));
+ }
+ chdir($wd);
+
+ $em = $application->getServiceManager()->get($this->em);
}
$metadatas = $em->getMetadataFactory()->getAllMetadata();
View
15 src/task/DoctrineRepoTask.php
@@ -91,9 +91,18 @@ public function main()
{
static $em;
if ($em === null) {
- $em = $this->project->zf
- //$em = $this->project->getProperty('zf')
- ->getServiceManager()->get($this->em);
+ $wd = getcwd();
+ $zf = $this->project->getProperty('zf');
+ $application = require $zf;
+ if (!$application instanceof Application) {
+ throw new BuildException(sprintf(
+ 'zf bootstrap file "%s" should return an instance of Zend\Mvc\Application',
+ $zf
+ ));
+ }
+ chdir($wd);
+
+ $em = $application->getServiceManager()->get($this->em);
}
$metadatas = $em->getMetadataFactory()->getAllMetadata();
View
15 src/task/DoctrineUpdateTask.php
@@ -54,9 +54,18 @@ public function main()
{
static $em;
if ($em === null) {
- $em = $this->project->zf
- //$em = $this->project->getProperty('zf')
- ->getServiceManager()->get($this->em);
+ $wd = getcwd();
+ $zf = $this->project->getProperty('zf');
+ $application = require $zf;
+ if (!$application instanceof Application) {
+ throw new BuildException(sprintf(
+ 'zf bootstrap file "%s" should return an instance of Zend\Mvc\Application',
+ $zf
+ ));
+ }
+ chdir($wd);
+
+ $em = $application->getServiceManager()->get($this->em);
}
$metadatas = $em->getMetadataFactory()->getAllMetadata();
View
15 src/task/TwigTask.php
@@ -52,9 +52,18 @@ public function main()
static $environment;
if ($assetic === null || $environment === null) {
- $sm = $this->projct->zf->getServiceManager();
- //$sm = $this->project->getProperty('zf')
- // ->getServiceManager();
+ $wd = getcwd();
+ $zf = $this->project->getProperty('zf');
+ $application = require $zf;
+ if (!$application instanceof Application) {
+ throw new BuildException(sprintf(
+ 'zf bootstrap file "%s" should return an instance of Zend\Mvc\Application',
+ $zf
+ ));
+ }
+ chdir($wd);
+
+ $sm = $application->getServiceManager();
$assetic = $sm->get('assetwig-assetic');
$environment = $sm->get('assetwig-environment');
}
View
13 src/task/ZfTask.php
@@ -62,17 +62,6 @@ public function init()
*/
public function main()
{
- $wd = getcwd();
-
- $application = require $this->bootstrap;
- if (!$application instanceof Application) {
- throw new BuildException(
- 'bootstrap file should return an instance of Zend\Mvc\Application'
- );
- }
- $this->project->zf = $application;
- //$this->project->setProperty('zf', $application);
-
- chdir($wd);
+ $this->project->setProperty('zf', $this->bootstrap);
}
}

0 comments on commit 899f2dc

Please sign in to comment.
Something went wrong with that request. Please try again.