Ok, done.

Now I have converted most of the methods in my base controllers as action
helpers, plugins or just moved them to views.

I have the final challenge:

I declare "blocks" to my sidebar with my new action helper "Block".

Example, $this->_helper->block($block, "left_sidebar", 0); // renders $block
object to left sidebar as first block

BUT. I want to add some blocks in every module/controller/action or in every
action/somecontroller.

Before I added these helper calls to my base controller but now I don't have
base controllers.

So, next I tried plugins. Well, I can't access current controller.
Ok, I could use action helpers. BUT, then I need to add these helper calls
to every controller...

I was thinking about following:

Somekind of Hook system.
-should go through $frontController->getModuleDirectory() to get every
module
-should check if some file exists in the moduledir
-if file exits, it should be loaded, and if the class "Module_Hook" exists,
it should make new Module_Hook();
-Now it gets tricky...
-where to add event calls ? Hook:someEvent($args);
-Can this Hook class have access to needed resources, for example action
helpers

what, where, why o why!!

br, Marko (drinking beer)



Matthew Weier O'Phinney-3 wrote:
> 
> -- Marko Korhonen <marko.korho...@datafisher.com> wrote
> (on Monday, 16 February 2009, 05:04 AM -0800):
>> I'm pretty sure that others have done the same as me:
>> 
>> Base Controllers like My_BaseController and used as follows:
>> Module_SomeController extends MyLibrary_Controller_Base
>> 
>> Well, if so, you probably have done some methods just to shorten things a
>> bit.
>> 
>> I'll share some of my "convienience" methods and I hope you got some
>> ideas/feedback/bugs noticed and maybe some great convienience methods to
>> share...
>> 
>> I still would like to get Module Base Controller, but it does not
>> autoload
>> itself =(
>> Module_SomeController extends Module_BaseController
> 
> This is what action helpers were designed for -- to allow for common
> functionality between action controllers, and also for distributing
> functionality to use in different projects. If I may, I'd recommend
> rewriting these as action helpers.
> 
> One change I'm going to add before 1.8 is the addition of a
> "getHelperBroker()" method to both the action controller and abstract
> action helper (this latter will proxy to the action controller). This
> will allow your action helpers to have access to other action helpers
> trivially. For example:
> 
>     $this->getHelperBroker()->json($data);
> 
> This should help with re-use, and further eliminate reasons for "base"
> controllers in your projects.
> 
>> -------------------------------------------------------------------
>> 
>> // output json without rendering any layouts/templates
>> protected function json($data)
>> {
>>      $this->_helper->json($data);
>> }
>> 
>> // Is the current action frontpage
>> protected function isFrontpage()
>> {
>>      $front = $this->getFrontController();
>> 
>>      return (boolean) $this->_module == $front->getDefaultModule() &&
>> $this->_controller == $front->getDefaultControllerName() &&
>> $this->_action
>> == $front->getDefaultAction();
>> }
>> 
>> // Disable layout and/or viewRenderer
>> protected function disableUI($layout = true, $viewRenderer = true)
>> {
>>      if ($layout) $this->_helper->layout->disableLayout();
>>              
>>      if ($viewRenderer) $this->_helper->viewRenderer->setNoRender();
>> }
>> 
>> // Set layout
>> protected function setLayout($layout)
>> {
>>      $this->_helper->layout->setLayout($layout);
>> }
>> 
>> // Set template
>> protected function setTemplate($template)
>> {
>>      $this->_helper->viewRenderer($template);
>> }
>> 
>> // Change the response segment (default is being $this->layout()->content
>> protected function setResponseSegment($segment)
>> {
>>      $this->_helper->viewRenderer->setResponseSegment($segment);
>> }
>> 
>> // Set page title
>> public function setTitle($title)
>> {
>>      $this->view->headTitle($this->view->page_title);
>> }
>> 
>> // Get Url by default route
>> public function url($module, $controller, $action, array $urlOptions =
>> array(), $reset = false, $encode = true)
>> {
>>      $urlOptions["module"] = $module;
>>      $urlOptions["controller"] = $controller;
>>      $urlOptions["action"] = $action;
>>              
>>      return $this->view->url($urlOptions, "default", $reset, $encode);
>> }
>> 
>> // Get Url by named route
>> public function urlByName($name, array $urlOptions = array(), $reset =
>> false, $encode = true)
>> {
>>      return $this->view->url($urlOptions, $name, $reset, $encode);
>> }
>> -- 
>> View this message in context:
>> http://www.nabble.com/Base-Controller-convienience-methods-tp22036897p22036897.html
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>> 
> 
> -- 
> Matthew Weier O'Phinney
> Software Architect       | matt...@zend.com
> Zend Framework           | http://framework.zend.com/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Base-Controller-convienience-methods-tp22036897p22108968.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to