= sfPropelTextOutputBehaviorPlugin plugin = == Overview == This plugin enhance Propel objects for different output formats: - XML - JSON == Installation == 1. Install the plugin from the repository {{{ symfony plugin-install http://plugins.symfony-project.com/sfPropelTextOutputBehaviorPlugin }}} or install from local file. {{{ symfony plugin-install sfPropelTextOutputBehaviorPlugin-0.0.3.tgz }}} 2. Enable Propel behavior support in propel.ini {{{ propel.builder.AddBehaviors = true }}} 3. Rebuild your model and clean the cache {{{ symfony propel-build-model symfony cc }}} 4. Enable your module to use enhanced methods {{{ #!php // lib/model/Article.php class Article extends BaseArticle { } sfPropelBehavior::add('Article', array('text_output')); }}} == Uninstallation == 1. Uninstall the plugin {{{ symfony plugin-uninstall symfony/sfPropelTextOutputBehaviorPlugin }}} 2. Remove the sfProbleBehavior from model {{{ #!php // lib/model/Article.php class Article extends BaseArticle { } // delete this line sfPropelBehavior::add('Article', array('text_output')); }}} == Usage == {{{ // config/schema.yml propel: article: _attributes: { phpName: Article } id: title: varchar(255) content: longvarchar created_at: }}} {{{ #!php <Articles> <?php foreach ($articles as $article) { echo ' ', $article->asXML(), "\n"; } ?> </Articles> // output <Articles> <article><id>1</id><title>Lorem ipsum dolor</title><content>Habitasse quam Nulla justo dolor malesuada...</content></article> <article><id>2</id><title>Lorem ipsum dolor</title><content>Habitasse quam Nulla justo dolor malesuada...</content></article> </Articles> }}} {{{ #!php <Articles> <?php $mapping = array( 'element' => 'article', 'elements' => array( 'id' => array('element'=>'id', 'format'=>'%s'), 'title' => array('element'=>'t', 'format'=>'<![CDATA[%s]]>'), 'content' => array('element'=>'c', 'format'=>'<![CDATA[%s]]>') ) ); foreach ($articles as $article) { echo ' ', article->asXML($mappgin), "\n"; } ?> </Articles> // output <Articles> <article><id>1</id><t>Lorem ipsum dolor</t><c><![CDATA[Habitasse quam Nulla justo dolor malesuada...]]></c></article> <article><id>2</id><t>Lorem ipsum dolor</t><c><![CDATA[Habitasse quam Nulla justo dolor malesuada...]]></c></article> </Articles> }}} {{{ #!php {Articles:[ <?php $i=0; foreach ($articles as $article) { echo ' ', $article->asJSON(),(++$i < count($articles) ? ',' : ''), "\n"; } ?> ]} // output {Articles:[ {"id":"1", "title": "Lorem ipsum dolor", content: "Habitasse quam Nulla justo dolor malesuada..."}, {"id":"2", "title": "Lorem ipsum dolor", content: "Habitasse quam Nulla justo dolor malesuada..."} ]} }}} {{{ #!php {Articles:[ <?php $i=0; $mapping = array( 'element' => 'article', 'elements' => array( 'id' => array('element'=>'id', 'format'=>'%s'), 'title' => array('element'=>'t', 'format'=>'<![CDATA[%s]]>'), 'content' => array('element'=>'c', 'format'=>'<![CDATA[%s]]>') ) ); foreach ($articles as $article) { echo ' ', $article->asJSON($mapping),(++$i < count($articles) ? ',' : ''), "\n"; } ?> ]} // output {Articles:[ {"id":"1", "t": "Lorem ipsum dolor", "c": "<![CDATA[Habitasse quam Nulla justo dolor malesuada...]]>"}, {"id":"2", "t": "Lorem ipsum dolor", "c": "<![CDATA[Habitasse quam Nulla justo dolor malesuada...]]>"} ]} }}} === 2007-08-25 | 0.0.3 Beta === - Documentation overworked - Source regarding coding and naming convention overworked === 2007-08-25 | 0.0.2 Beta === - Making plugin a behavior for Proble objects - Method obj2XML renamed to asXML - Method obj2JSON renamed to asJSON - Documentation overworked === 2007-08-23 | 0.0.1 Beta === - created == Active tickets == [[TicketQuery(component=sfPropelTextOutputBehaviorPlugin&status!=closed)]] ---- see also : SymfonyPlugins