(on Wednesday, 28 October 2009, 01:20 PM -0700):
> Here's how I imagine this would look like:
>
> // Adding a custom helper
> $view = new Zend_View();
> $helper = new MyCustomHelper();
> $view->addHelper($helper, 'foo');
> $view->foo(); // calls MyCustomHelper#foo()
>
> // Overwriting a built-in helper
> $myUrlHelper = new MyUrlHelper();
> $view->addHelper($myUrlHelper, 'url');
> $view->url(); // calls MyUrlHelper#url();
>
> There's always a potential for a BC break when adding new methods to
> Zend_View_Abstract, but the chances are slim that someone created their own
> view helper named "AddHelper". Just something to keep in mind when picking the
> name for the method.
Please create a feature request in the tracker for this. Bonus points if
you attach a patch (including unit tests!), as I'll be more likely to
include it sooner. :)
> On Wed, Oct 28, 2009 at 6:04 AM, Matthew Weier O'Phinney <matthew@zend.com>
> wrote:
>
> -- Abraham Block <atblock@gmail.com> wrote
> (on Wednesday, 28 October 2009, 08:38 AM -0400):
> > Why is there no way of registering a helper that you've instantiate
> yourself
> > with an instance of Zend_View? Why is the only way to instantiate one
> through
> > the plugin loader? What if I wanted to control the instantiation of a
> view
> > helper (for DI purposes, let's say). Or what if I wanted to add a view
> helper
> > which didn't conform to the Zend\Pear naming standards (let's say it used
> php
> > 5.3 namespaces). Is there a reason the design is this way?
>
> There is not a way to do this currently; it was not a part of the
> original design specification.
>
> If you would like to see this in a future version, please put in a
> request on the issue tracker, or create a proposal indicating how you
> would envision this working.
>
> Thanks!
>
> --
> Matthew Weier O'Phinney
> Project Lead | matthew@zend.com
> Zend Framework | http://framework.zend.com/
>
>
>
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论