Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Make ZF1 bootstrap lazy? #8

Open
croensch opened this issue May 18, 2015 · 1 comment
Open

Make ZF1 bootstrap lazy? #8

croensch opened this issue May 18, 2015 · 1 comment

Comments

@croensch
Copy link

The basic features mention

  • Makes ZF1 application config and bootstrap object available to ServiceManager

What if my ZF2 modules don't need this? I thought about bootstrapping zf2 first and all remaining resources only in the case that it makes a fallback to ZF1. To do that i had to make some modifications.

index.php

$application->bootstrap('Zf2')->run();

\Zf2for1_Resource_Zf2 called a blank bootstrap() before the fallback, based on a triggered zf2 event.

    public function onBootstrap()
    {
        return;
    }

\Zf2for1\Application\Zf2Bootstrap so i put it into the other event (and also moved the part with the frontcontroller).

    public function run()
    {
        $application = $this->getResource('zf2');
        $config = $application->getServiceManager()->get('Config');

        if ($config['zf2_for_1']['silent_zf1_fallback'] === true) {
            $application->getEventManager()->attach('zf1', array($this, 'parentRun'));
        }

        return $application->run();
    }

    public function parentRun($event)
    {
        $this->bootstrap();
        $front = $this->getResource('frontcontroller');
        $front->setParam('bootstrap', $this);
        return Zend_Application_Bootstrap_Bootstrap::run();
    }

I guess now even if a ZF2 module would need ZF1 resources it could just chain the call bootstrap('X')->getResource('X') while ZF1 modules can work as they were.

Any good reasons against this?

@Xerkus
Copy link
Contributor

Xerkus commented May 18, 2015

Due to heavy use of singletons and statics in ZF1 the only way to achieve consistent state is to bootstrap everything before running application. Same holds true if Zf2for1 is used.

Idea of this package is to provide refactoring path to zf2 instead of complete rewrite. That means that zf1 model and various resources must be made available to zf2 application and that means zf1 must be bootstrapped.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants