2

I have created custom aplication resource:

class Custom_Entitymanager extends Zend_Application_Resource_ResourceAbstract{
    //...
    public function init (){
        //...
        $em = \Doctrine\ORM\EntityManager::create($options['connection'],  $config);
        return $em;
    }
}

and I put it in MyProject\library\Custom\Entitymanager.php file.

When I want to retrieve Entitymanager using:

$em = $this->getInvokeArg('bootstrap')->getResource('entityManager');

I get null object.

How can I register my custom application resource in application.ini file?

pixel
  • 24,905
  • 36
  • 149
  • 251

1 Answers1

7

In application/configs/application.ini:

pluginpaths.Custom_ =  APPLICATION_PATH "/../library/Custom"
resources.EntityManager[] =

Side note: I'd probably push the EntityManager class down a little deeper into my own custom library, perhaps something like Custom_Application_Resource_EntityManager. In this case, the path mapping above would change to:

pluginpaths.Custom_Application_Resource_ =  APPLICATION_PATH "/../library/Custom/Application/Resource"
resources.EntityManager[] =
David Weinraub
  • 14,144
  • 4
  • 42
  • 64