У меня проблемы с загрузкой 5-й записи из моей коллекции ($ arrRoleResources) записей, после того, как я запустил это, что прекрасно работает: -
$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-й итерации он изменяет один из классов связанных записей с сущности на прокси, который является нажимным и корректным, однако после перехода через прокси (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.
Когда я выполняю шаг через функцию $ this -> _ entityPersister-> load () с помощью BasicEntityPersister.php в строке 581: -
$entities = $hydrator->hydrateAll($stmt, $this->_rsm, $hints);
$ entity возвращает 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"
My Bootstrap: -
/**
* 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;
}
Пожалуйста, кто-нибудь может помочьтак как я работаю над этим уже несколько недель, и я, кажется, ничего не получу с этим.
Спасибо за ваше время
Эндрю