2

カスタム アプリケーション リソースを作成しました。

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

MyProject\library\Custom\Entitymanager.phpそしてファイルに入れました。

次を使用して取得したい場合Entitymanager:

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

null オブジェクトを取得します。

application.iniカスタム アプリケーション リソースをファイルに登録するにはどうすればよいですか?

4

1 に答える 1

7

application/configs/application.ini

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

補足: EntityManager クラスを、おそらくCustom_Application_Resource_EntityManager. この場合、上記のパス マッピングは次のように変更されます。

pluginpaths.Custom_Application_Resource_ =  APPLICATION_PATH "/../library/Custom/Application/Resource"
resources.EntityManager[] =
于 2011-07-24T12:14:37.423 に答える