provides symfony with a *Decorator autoloader to ease decorating (core) classes
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


sfDecorator plugin

This plugin provides a tool to easily create decorator classes in Symfony. 


Decorator classes (see wikipedia about the [decorator pattern](
are a way to extend functionality at realtime. It's powerful when you want to slightly alter a core 
class of symfony.

The problem with decorator classes is that you have to 'mirror' all public methods. Most classes
inherit a lot of methods, most you don't even know about. With an api change your decorator might break,
this plugin ensures all decorators do work.

This plugin registers an autoloader. You can just write something like this (actually completely
useless) example:

    class divForm extends sfFormDecorator
      public function render($attributes = array())
        return '<div class="myform">'.$this->object->render($attributes)."</div>;

The *main point* in here is that the plugin will detect `sfFormDecorator` as a non existent class. By
the name it knows you want to decorate the sfForm class. So the plugin creates an abstract
`sfFormDecorator` in your cache directory.


  * Install the plugin
        > php symfony plugin:install sfDecoratorPlugin
  * Enable the plugin in your `config/ProjectConfiguration.class.php`
        class ProjectConfiguration extends sfProjectConfiguration
          public function setup()
  * Clear the cache

        > php symfony cc


You can either:

 *  Tell a class to extend `[yourClassToDecorate]Decorator`. The following code will work:
        class inputLabeledWidget extends sfWidgetFormDecorator
          public function getLabel()
            $widget = new sfWidgetFormInputText();
            return $object->getLabel();
    The plugin will automatically generate the `sfWidgetFormDecorator` in your cache
 *  Use the `symfony generate:decorator` task from the cli. Usage is very easy:
        > php symfony generate:decorator sfWidgetForm
    The above command will generate the `sfWidgetFormDecorator` class in your lib dir. The task has
    more options, use `symfony help plugin:decorator` to discover them.


No options are available.

TODO / Ideas
  * Add support for chaining. Check if a function returns the decorator object, then return the decorator.
  * Please let them know!


### 2009-12-15 | 1.0.2 stable

  * added support for method chaining

### 2009-12-12 | 1.0.1 stable

  * Removed conditionally enabling autoloading
### 2009-12-11 | 1.0.0 stable

  * Initial release