doctrine 2 prevent LifecycleCallbacks caching of methods (or similar problem)
I'm using doctrine2 (2.0.3) with codeigniter, and I noticed that when I add, change or even remove some methods that are anotaded as lifecycle, sometimes doctrine just ignores the开发者_如何转开发 change. For example, I add
/*
* @PostLoad
*/
private function setUpObj() {
echo('in');
}
To the Model (entity) that @HasLifecycleCallbacks, function sometimes is called on postload, sometimes it is ignored, sometimes it accept one change, then ignores any other changes...
In bootstrap file I use some of the config options, here is sample of them, if more needed I will update my post
$cache = new \Doctrine\Common\Cache\ArrayCache;
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Set up driver
$Doctrine_AnnotationReader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
$Doctrine_AnnotationReader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
$driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($Doctrine_AnnotationReader, APPPATH.'models');
$config->setMetadataDriverImpl($driver);
// Proxy configuration
$config->setProxyDir(APPPATH.'/models/proxies');
$config->setProxyNamespace('Proxies');
$config->setAutoGenerateProxyClasses( TRUE );
After some time, (usually when I give up changing the method, take a walk and come back) it starts to work normally, it accepts my last change and then I usually create what my intention was and stop changing that method. My server is standard/default xampp on win7, and I never noticed anything similar to any other php files so far. This is not related only to @PostLoad, but it happens with @PrePersist and @PreUpdate as well
Is this normal behavior, or am I missing something?
Thanks in advance, Dalibor
It seems that notation and comment MUST be like this
/**
* @PostLoad
*/
function setUpObj() {
$this->mainObjName = 'models\Page';
$this->defaultSortingField = 'ordering';
}
Meaning, first comment line must start with /** (two stars) and function cannot be private. Or at least this is how it works for me, hopefully it helps someone else
精彩评论