これを実行した後、レコードのコレクション ($arrRoleResources) から 5 番目のレコードを読み込む際に問題が発生しました。
$em = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('doctrine');
$arrRoleResources = $em->getRepository("AJFIT\Entities\UserRoleResources")->findAll();
これを実行すると:-
foreach($arrRoleResources as $roleResource) {
self::$_objAcl->allow($roleResource->getRoleFk()->getName(),$roleResource->getResourcesFk()->getModule() . '::' . $roleResource->getResourcesFk()->getController() . '::' . $roleResource->getResourcesFk()->getAction());
}
5回目の繰り返しで、関連するレコードクラスの1つをエンティティからプロキシに変更します。これはpressntで正しいですが、ロード関数に到達したときにプロキシ(AJFITEntityUserRoleResourcesProxy)をステップスルーした後:-
private function _load()
{
if (!$this->__isInitialized__ && $this->_entityPersister) {
$this->__isInitialized__ = true;
if ($this->_entityPersister->load($this->_identifier, $this) === null) {
throw new \Doctrine\ORM\EntityNotFoundException();
}
unset($this->_entityPersister, $this->_identifier);
}
}
EntityNotFoundException をスローします。
BasicEntityPersister.php の 581 行目で $this->_entityPersister->load() 関数を実行すると:-
$entities = $hydrator->hydrateAll($stmt, $this->_rsm, $hints);
$entities は null を返しますが、その理由はわかりません。
これが私の構成です:-
Root
|-----application
|-----library
|-----AJFIT
| |-----Entities (namespaces = AJFIT\Entities)
| | |-----UserResources.php
| | |-----UserRoleResources.php
| | |-----UserRoles.php
| |-----Proxies (namespaces = AJFIT\Proxies) <-auto generated
| |-----AJFITEntitiesUserResources.php
| |-----AJFITEntitiesUserRoleResources.php
| |-----AJFITEntitiesUserRoles.php
|-----Doctrine
|-----Zend
|-----ZendX
私のアプリケーション構成
[production]
autoloadernamespaces[] = "AJFIT"
autoloadernamespaces[] = "Doctrine"
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 1
resources.frontController.baseurl = "/"
resources.layout.layout = "layout"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.view.encoding = "UTF-8"
resources.view.basePath = APPLICATION_PATH "/views/"
; ------------------------------------------------------------------------------
; Doctrine Database Configuration
; ------------------------------------------------------------------------------
doctrine.conn.host = '127.0.0.1'
doctrine.conn.user = 'ajfit'
doctrine.conn.pass = '*****'
doctrine.conn.driv = 'pdo_mysql'
doctrine.conn.dbname = 'ajfit'
doctrine.path.entities = APPLICATION_PATH "../../library/AJFIT/Entities"
私のブートストラップ:-
/**
* Register namespace Default_
* @return Zend_Application_Module_Autoloader
*/
protected function _initAutoload()
{
$autoloader = new \Doctrine\Common\ClassLoader('Zend');
$autoloader->setNamespaceSeparator('_');
$autoloader->register();
return $autoloader;
}
/**
* Initialize Doctrine
* @return Doctrine_Manager
*/
public function _initDoctrine() {
$this->bootstrap('autoload');
// include and register Doctrine's class loader
require_once(APPLICATION_PATH . '/../library/Doctrine/Common/ClassLoader.php');
$classLoader = new \Doctrine\Common\ClassLoader(
'Doctrine',
APPLICATION_PATH . '/../library/Doctrine'
);
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader(
'Symfony',
APPLICATION_PATH . '/../library/Doctrine/Symfony'
);
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader(
'AJFIT',
APPLICATION_PATH . '/../library/AJFIT/'
);
$classLoader->register();
// create the Doctrine configuration
$config = new \Doctrine\ORM\Configuration();
// setting the cache ( to ArrayCache. Take a look at
// the Doctrine manual for different options ! )
$cache = new \Doctrine\Common\Cache\ArrayCache;
//$cache = new \Doctrine\Common\Cache\ApcCache;
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// choosing the driver for our database schema
// we'll use annotations
$driver = $config->newDefaultAnnotationDriver(
APPLICATION_PATH . '/../library/AJFIT/Entities'
);
//$driver = new Doctrine\ORM\Mapping\Driver\XmlDriver(
// APPLICATION_PATH . '/../library/AJFIT/Mappings/XML');
//$driver = new Doctrine\ORM\Mapping\Driver\YamlDriver(
// APPLICATION_PATH . '/../library/AJFIT/Mappings/YML');
$config->setMetadataDriverImpl($driver);
// set the proxy dir and set some options
$config->setProxyDir(APPLICATION_PATH . '/../library/AJFIT/Proxies');
$config->setAutoGenerateProxyClasses(true);
$config->setProxyNamespace('AJFIT\Proxies');
// now create the entity manager and use the connection
// settings we defined in our application.ini
$connectionSettings = $this->getOption('doctrine');
$conn = array(
'driver' => $connectionSettings['conn']['driv'],
'user' => $connectionSettings['conn']['user'],
'password' => $connectionSettings['conn']['pass'],
'dbname' => $connectionSettings['conn']['dbname'],
'host' => $connectionSettings['conn']['host']
);
$entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);
// push the entity manager into our registry for later use
$registry = Zend_Registry::getInstance();
$registry->em = $entityManager;
return $entityManager;
}
私はこれに数週間取り組んでいるので、誰かが助けてくれませんか。
お時間をいただきありがとうございます
アンドリュー