Sunday, October 27, 2013

Re: Defining Plugin

Yes, I guess you have been creating non-conventional links so far. Mainly because you are confusing framework internal naming schemes with URL naming scheme
The latter defines everything underscore_lowercased, even the plugin.
The first refers mainly to classes, which will always be named CamelCased.

You need to understand the difference in order to not write faulty code - which at some point can blow up (as it then did).


Am Samstag, 26. Oktober 2013 04:43:11 UTC+2 schrieb CrotchFrog:
I've noticed recently some strange behavior when it comes to naming conventions and Plugins.  

For example if I create a link somewhere within a plugin ie. $this->Html->link('Some Link', array('controller' => 'controller', 'action' => 'action')); 
Following the link would land you on the page app/plugin/controller/action unless a location is specified outside of the current plugin and controller. 

Links created this way and that have been working since they were created sometimes out of the blue throw an error along the lines of SomePluginController cannot be found. 
This is strange because the link has always worked in the past. When these links create an error I have to re-create the link and specify the plugin $this->Html->link('controller' => 'controller', 'action' => 'action', 'plugin' => 'some_plugin')
I have to use an underscore in the plugin name, using camel case results in the same error. 

It's possible that some, but not all, of the links were created only specifying the action and not the controller. With this being the case I could sort of understand the resulting error but not when I have specified both the controller and the action.

I created all of my custom routes with the plugin as camel case, it just seems to be links and redirects that display this behavior.  

I assumed that with sticking to naming conventions I could write it as SomePlugin or some_plugin and either one would be fine. 

Have I been creating my links incorrectly this entire time? 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: