| | 903 | |
| | 904 | ++ Generating Files |
| | 905 | |
| | 906 | By default with behaviors the classes which are generated are evaluated at |
| | 907 | run-time and no files containing the classes are ever written to disk. This can |
| | 908 | be changed with a configuration option. Below is an example of how to configure |
| | 909 | the I18n behavior to generate the classes and write them to files instead of |
| | 910 | evaluating them at run-time. |
| | 911 | |
| | 912 | <code type="php"> |
| | 913 | class NewsArticle extends Doctrine_Record |
| | 914 | { |
| | 915 | public function setTableDefinition() |
| | 916 | { |
| | 917 | $this->hasColumn('title', 'string', 255); |
| | 918 | $this->hasColumn('body', 'string', 255); |
| | 919 | $this->hasColumn('author', 'string', 255); |
| | 920 | } |
| | 921 | |
| | 922 | public function setUp() |
| | 923 | { |
| | 924 | $this->actAs('I18n', array('fields' => array('title', 'body'), |
| | 925 | 'generateFiles' => true, |
| | 926 | 'generatePath' => '/path/to/generate')); |
| | 927 | } |
| | 928 | } |
| | 929 | </code> |
| | 930 | |
| | 931 | Now the behavior will generate a file instead of generating the code and using |
| | 932 | eval() to evaluate it at runtime. |