Issue Type: Bug Created: 2009-09-21T08:13:49.000+0000 Last Updated: 2011-05-30T21:21:57.000+0000 Status: Resolved Fix version(s): Reporter: Anselm Föhr (anselm) Assignee: Bart McLeod (firstname.lastname@example.org) Tags: - Zend_Form
Related issues: Attachments:
Trying to call getDecorator with the full decorator name is not working until we call getDecorators() first:
$e = new Zend_Form_Element_Text("test"); $x = $e->getDecorator("Zend_Form_Decorator_Description"); // $x is false
$e = new Zend_Form_Element_Text("test"); $e->getDecorators(); $x = $e->getDecorator("Zend_Form_Decorator_Description"); // $x is the decorator
However, calling getDecorator("Description") returns the right decorator in both cases. I am not exactly sure if this behaviour is intended, at least it is very confusing.
Posted by Bart McLeod (email@example.com) on 2011-05-23T22:12:29.000+0000
This behavior is by design. The decorator plugins are lazy loaded. That means they are loaded based on how the plugin loader for the decorator is configured by the user or by default. The loading mechanism works with the short name and the prefix. Together with the path, these form a valid class to load. If a full class name is provided there is simply no point in trying to match it against a shortname, therefore the lazy loading process will not be invoked on such a call. After getDecorators() has been called, all decorators are loaded as instances and will be registered by their full name. From that moment on, you can get them by their full name. You can also register your own decorator instances by their full name. Default decorators are registered by their shortname and can only be retrieved by there shortname, unless they have already been loaded. You can override them, by providing a path and a prefix and make sure a decorator with the same shortname, such as 'Errors' can be found on that path with that prefix. This explains that lazy loading has to have taken place, before you can retrieve a decorator that was registered as a string only, by its fullname. The fullname will in fact only be known when the stack of prefix paths has been searched down far enough to find a matching decorator.
Have you found an issue?
See the Overview section for more details.