Development

Changeset 19862

You must first sign up to be able to contribute.

Changeset 19862

Show
Ignore:
Timestamp:
07/03/09 20:35:54 (9 months ago)
Author:
Stefan.Koopmanschap
Message:

fixing the same issues as was just done with the 1.2 version of this cookbook article (re #4701)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • doc/branches/1.1/cookbook/en/behaviors.txt

    r13948 r19862  
    4343------------ 
    4444 
    45 Now, imagine that you need to keep also the deleted records of the `comment` table. Instead of copying the two methods above in the `Comment` and `CommentPeer` classes, which would not be [D.R.Y.](http://en.wikipedia.org/wiki/Don't_repeat_yourself), you should refactor the code used more than once in a new class, and inject it via the *Mixins* system. You should be familiar with the concept of Mixins and the `sfMixer` class to understand the following, so refer to [Chapter 17](http://www.symfony-project.org/book/1_1/17-Extending-Symfony#Mixins) of the symfony book if you wonder what this is about. 
     45Now, imagine that you need to keep also the deleted records of the `comment` table. Instead of copying the two methods above in the `Comment` and `CommentPeer` classes, which would not be [D.R.Y.](http://en.wikipedia.org/wiki/Don't_repeat_yourself), you should refactor the code used more than once in a new class, and inject it via the *Mixins* system. You should be familiar with the concept of Mixins and the `sfMixer` class to understand the following, so refer to [Chapter 17](http://www.symfony-project.org/book/1_0/17-Extending-Symfony#Mixins) of the symfony 1.0 book if you wonder what this is about. 
    4646 
    4747The first step is to remove any code from the model classes, and to add hooks to allow them to be extended. 
     
    288288There is a non-written convention about behavior plugin names. They must be prefixed with 'Propel' since they work only for this ORM, and they must end with 'BehaviorPlugin'. So a good name for our Paranoid behavior could be 'myPropelParanoidBehaviorPlugin'. 
    289289 
    290 As of now, there are only two files to put in the plugin: the `ParanoidBehavior` class, and the code written in `config/config.php` to register the behavior methods and hooks. [Chapter 17](http://www.symfony-project.org/book/1_1/17-Extending-Symfony#Plug-Ins) explains how to organize these files in a plugin tree structure: 
     290As of now, there are only two files to put in the plugin: the `ParanoidBehavior` class, and the code written in `config/config.php` to register the behavior methods and hooks. [Chapter 17](http://www.symfony-project.org/book/1_1/17-Extending-Symfony#chapter_17_plug_ins) explains how to organize these files in a plugin tree structure: 
    291291 
    292292    plugins/ 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.