{"id":727,"date":"2011-05-02T20:38:02","date_gmt":"2011-05-02T19:38:02","guid":{"rendered":"http:\/\/www.dotmana.com\/index.php\/?p=727"},"modified":"2011-05-02T20:38:02","modified_gmt":"2011-05-02T19:38:02","slug":"add-simple-behavior-with-propel-symfony","status":"publish","type":"post","link":"https:\/\/www.dotmana.com\/weblog\/2011\/05\/add-simple-behavior-with-propel-symfony\/","title":{"rendered":"Add simple behavior with Propel \/ Symfony"},"content":{"rendered":"<p>Add your behavior in a new file in :<\/p>\n<p>lib\/vendor\/symfony\/lib\/plugins\/sfPropelPlugin\/lib\/behavior\/SfPropelBehaviorMyBehavior.php<\/p>\n<p>Edit SfPropelBehaviorSymfony.php and add a loader for your new Behavior. Example :<\/p>\n<blockquote><p>public function modifyDatabase()<br \/>\n{<br \/>\nforeach ($this-&gt;getDatabase()-&gt;getTables() as $table)<br \/>\n{<br \/>\n$behaviors = $table-&gt;getBehaviors();<\/p>\n<p>[&#8230;&#8230;&#8230;&#8230;]<\/p>\n<p>\/\/ MyBehavior<br \/>\nif (!isset($behaviors[&#8216;symfony_mybehavior&#8217;]))<br \/>\n{<\/p>\n<p>$class = Propel::importClass($this-&gt;getBuildProperty(&#8216;propel.behavior.symfony_mybehavior.class&#8217;));<br \/>\n$behavior = new $class();<br \/>\n$behavior-&gt;setName(&#8216;symfony_mybehavior&#8217;);<br \/>\n$behavior-&gt;setParameters($parameters);<br \/>\n$table-&gt;addBehavior($behavior);<\/p>\n<p>}<\/p><\/blockquote>\n<p>Edit config\/propel.ini and add a new line with your new behavior<\/p>\n<p>Rebuild your full models and enjoy !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Add your behavior in a new file in : lib\/vendor\/symfony\/lib\/plugins\/sfPropelPlugin\/lib\/behavior\/SfPropelBehaviorMyBehavior.php Edit SfPropelBehaviorSymfony.php and add a loader for your new Behavior. Example : public function modifyDatabase() { foreach ($this-&gt;getDatabase()-&gt;getTables() as $table) { $behaviors = $table-&gt;getBehaviors(); [&#8230;&#8230;&#8230;&#8230;] \/\/ MyBehavior if (!isset($behaviors[&#8216;symfony_mybehavior&#8217;])) { &hellip; <a href=\"https:\/\/www.dotmana.com\/weblog\/2011\/05\/add-simple-behavior-with-propel-symfony\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-727","post","type-post","status-publish","format-standard","hentry","category-symfony"],"_links":{"self":[{"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/posts\/727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/comments?post=727"}],"version-history":[{"count":1,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/posts\/727\/revisions"}],"predecessor-version":[{"id":728,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/posts\/727\/revisions\/728"}],"wp:attachment":[{"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/media?parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/categories?post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dotmana.com\/weblog\/wp-json\/wp\/v2\/tags?post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}