Zend Framework

Components (Symfony-like defenition) in MVC

Details

  • Type: Patch Patch
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 0.7.0
  • Fix Version/s: 1.5.0
  • Component/s: Zend_View
  • Labels:
    None
  • Fix Version Priority:
    Should Have

Description

I didn't found in ZFW future like component is Symfony.
I'm writen it.
http://rt.avlab.ru/wp-content/uploads/2007/01/loadcomponent.zip

For more information see http://rt.avlab.ru/2007/01/14/zend-framework-realizatsiya-komponent-v-shablone/ (russian)

If you know more right way, notify me, please.

Activity

Hide
Bill Karwin added a comment -

Assign to Matthew.

Show
Bill Karwin added a comment - Assign to Matthew.
Hide
Matthew Weier O'Phinney added a comment -

From reviewing the code, it looks like this is a Zend_View helper class designed to allow pulling in content from another controller action, and that it has some amount of caching included in the interface.

What I'm wondering is: why would you do this instead of using _forward() in the action controller? Can you give me some details on what prompted this particular design, and use cases?

Thanks!

Show
Matthew Weier O'Phinney added a comment - From reviewing the code, it looks like this is a Zend_View helper class designed to allow pulling in content from another controller action, and that it has some amount of caching included in the interface. What I'm wondering is: why would you do this instead of using _forward() in the action controller? Can you give me some details on what prompted this particular design, and use cases? Thanks!
Hide
Roman Tolkachyov added a comment -

That's right - this is a Zend_View helper.
Some code for example

Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
require_once 'Zend/Controller/Action.php';
       
      class IndexController extends Zend_Controller_Action
      {
      public function indexAction()
      {
      $View = new Zend_View();
      $View->addHelperPath('../application/helpers/', 'Avlab_View_Helper_');
      $View->addScriptPath('../application/views/');
       
      echo $View->render('indexView.php');
      }
       
      public function componentAction()
      {
      echo "It's work!!!";
      }
       
      public function noRouteAction()
      {
      $this->_redirect('/');
      }
      }

indexView.php

Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
There are 3 component call:
<?echo $this->loadComponent('index', 'component');?>
<?echo $this->loadComponent('index', 'component');?>
<?echo $this->loadComponent('index', 'component');?>

We don't need to controll call chain in controller by using _forward(). In other way we should notify next controller2 about what controller3 it must forward to and then notify controller 3 what controller4 must forward to etc.
It very hard.

In other way we should modify _forward() to allow constructions like that:

Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
$this->_forward('controller', 'component1');
$this->_forward('controller', 'component2');
$this->_forward('controller', 'component3');
// etc

it's means, that next action is 'component1' and after it will execute action component2 will start etc.

But it isn't right alternative. I can't say rightly why, because I have troubles in my english You may read symfony-book by this subject.

Show
Roman Tolkachyov added a comment - That's right - this is a Zend_View helper. Some code for example
Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
require_once 'Zend/Controller/Action.php';
       
      class IndexController extends Zend_Controller_Action
      {
      public function indexAction()
      {
      $View = new Zend_View();
      $View->addHelperPath('../application/helpers/', 'Avlab_View_Helper_');
      $View->addScriptPath('../application/views/');
       
      echo $View->render('indexView.php');
      }
       
      public function componentAction()
      {
      echo "It's work!!!";
      }
       
      public function noRouteAction()
      {
      $this->_redirect('/');
      }
      }
indexView.php
Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
There are 3 component call:
<?echo $this->loadComponent('index', 'component');?>
<?echo $this->loadComponent('index', 'component');?>
<?echo $this->loadComponent('index', 'component');?>
We don't need to controll call chain in controller by using _forward(). In other way we should notify next controller2 about what controller3 it must forward to and then notify controller 3 what controller4 must forward to etc. It very hard. In other way we should modify _forward() to allow constructions like that:
Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
$this->_forward('controller', 'component1');
$this->_forward('controller', 'component2');
$this->_forward('controller', 'component3');
// etc
it's means, that next action is 'component1' and after it will execute action component2 will start etc. But it isn't right alternative. I can't say rightly why, because I have troubles in my english You may read symfony-book by this subject.
Hide
Matthew Weier O'Phinney added a comment -

Please review the Zend_View_Helper_Action view helper in the incubator. This component will be available for the 1.1.0 release as part of the Zend_View Enhanced proposal, and accomplishes what you've outlined.

Show
Matthew Weier O'Phinney added a comment - Please review the Zend_View_Helper_Action view helper in the incubator. This component will be available for the 1.1.0 release as part of the Zend_View Enhanced proposal, and accomplishes what you've outlined.
Hide
Matthew Weier O'Phinney added a comment -

Action view helper merged to core.

Show
Matthew Weier O'Phinney added a comment - Action view helper merged to core.

People

Vote (1)
Watch (0)

Dates

  • Due:
    Created:
    Updated:
    Resolved: