cakephp-annotation-control-list
cakephp-annotation-control-list copied to clipboard
Getting ReflectionException errors trying to use this plugin
@josegonzalez this is a brilliant idea. I am trying to implement it in my application, but I have encountered an issue. To start with, I am trying to load the homepage at PagesController\display, but I encounter the following error:
The parameter class is expected to be either a string or an object
If in AppController I add $this->Auth->allow(['display']) inside beforeFilter(), then the page works, but obviously that is now how this is intended to work.
This is how I have loaded it
$this->loadComponent('Auth', [
'authenticate' => [
'Josegonzalez/AnnotationControlList.AnnotationForm' => [
'passwordHasher' => 'Blowfish',
'roleField' => 'role', // `roleField` is `role` by default
]
],
'authorize' => [
'Josegonzalez/AnnotationControlList.Annotation',
'roleField' => 'role', // `roleField` is `role` by default
],
]);
and my display annotation looks like this
/**
* Displays a view
*
* @roles all
*
* @return void|\Cake\Network\Response
* @throws \Cake\Network\Exception\NotFoundException When the view file could not
* be found or \Cake\View\Exception\MissingTemplateException in debug mode.
*/
public function display() {}
I have done several tests, but I am not sure if this is a bug or an error on my part.
Can you gist the entire stacktrace of the error?
@josegonzalez thanks for your reply. Please review here: https://gist.github.com/akkaweb/32015f96687ad389f36f
- Can you gist the entire controller?
- What happens if you make that
@throwsa single line? - What happens if you remove the non-acl plugin annotations?
@josegonzalez this is the gist for my AppController.php and PagesController.php https://gist.github.com/akkaweb/7b3b72b4f70dad41cfca
While debugging, I noticed getController() was not returning anything, so I made the following change which caused the ERROR to go away, but Authentication/Authorization is not working. File src/Lib/AnnotationParserTrait.php, I replaced this:
public function getController() {
if (!empty($this->ComponentRegistry)) {
return $this->ComponentRegistry->getController();
}
return $this->_Controller;
}
With this:
public function getController() {
if (!empty($this->_registry)) {
return $this->_registry->getController();
}
return $this->_Controller;
}
As you will see in the AppController.php file, I commented out my original Auth code. However, if I comment out your Annotation's Auth and uncomment my original Auth requests to display() is redirected to users/login
Note: @throws in a single line did not make a difference on the result and removing the non-acl plugin annotations did not make a difference either.
I'll take a look. I fixed the registry bit, wonder how I missed that in the first place. Probably was mocking things...
Great! Thanks for taking a look
Seems like I have the same issue with the Model version... except there is no getController method...