#5935: Helpers should always be addressed by $this->Helper->func() instead of
$helper->func()
--------------------------+-------------------------------------------------
    Reporter:  euromark   |          Type:  Enhancement
      Status:  new        |      Priority:  Medium     
   Milestone:  1.3.x.x    |     Component:  Helpers    
     Version:  1.2 Final  |      Severity:  Normal     
    Keywords:             |   Php_version:  n/a        
Cake_version:             |  
--------------------------+-------------------------------------------------
 Helpers that are included via $helpers = array(...) in AppController
 should always be addressed by $this->Helper->func() instead of
 $helper->func()
 in the view.
 [[BR]]
 [[BR]]

 This prevents multiple conflicts with either already defined $vars in the
 view itself
 or with baked views via console, which you can as well set up manually now
 due to the naming conflict..
 [[BR]]
 [[BR]]

 problem a:[[BR]]

 if you add a new (lets call it "poll_helper.php") helper afterwards in
 order to get some polls to the index() method (and view "index.ctp), you
 might accidently crash the other views without knowing it, as the $poll
 could have been used there as a normal variable.
 [[BR]]
 [[BR]]

 problem b:[[BR]]

 if you bake a model "poll" from the DB table "polls" and the controller
 "polls" with its views, the console baking will bake the index view like
 the following:
 {{{
 ...
 echo $poll['Poll']['modified'];
 ...
 }}}
 which conflicts again with our $poll helper[[BR]]

 this would not be happening if we would address the helpers differently.
 [[BR]]
 [[BR]]

 its cleaner - and both problems (and probably some others as well) would
 be solved with this approach.
 [[BR]]
 Besides the fact that inside other helpers this is already done this way:
 {{{
 // inside Poll Helper
 $this->Html->doSomething();
 }}}

 [[BR]]
 [[BR]]

 if you dont like that one (for whatever reason), you could use $nameHelper
 (in my example $pollHelper) as variable for all helpers with the filename
 "name_helper.php".

-- 
Ticket URL: <https://trac.cakephp.org/ticket/5935>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to tickets-cakephp@googlegroups.com
To unsubscribe from this group, send email to 
tickets-cakephp+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

  • [CakePHP : The Rapid Dev... CakePHP : The Rapid Development Framework for PHP

Reply via email to