<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog Symfony2 - Lexik Montpellier &#187; Bérenger</title>
	<atom:link href="http://www.lexik.fr/blog/symfony/author/berenger/feed" rel="self" type="application/rss+xml" />
	<link>http://www.lexik.fr/blog/symfony</link>
	<description>Blog sur le développement Web PHP avec Symfony 2</description>
	<lastBuildDate>Thu, 02 Feb 2012 14:00:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Symfony2: création d&#8217;un service</title>
		<link>http://www.lexik.fr/blog/symfony/symfony2/symfony2-creation-dun-service-1690</link>
		<comments>http://www.lexik.fr/blog/symfony/symfony2/symfony2-creation-dun-service-1690#comments</comments>
		<pubDate>Tue, 06 Sep 2011 12:20:50 +0000</pubDate>
		<dc:creator>Bérenger</dc:creator>
				<category><![CDATA[Symfony2]]></category>
		<category><![CDATA[callback]]></category>
		<category><![CDATA[création]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[lifecycle]]></category>
		<category><![CDATA[service]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/blog/symfony/?p=1690</guid>
		<description><![CDATA[Bonjour, Nous allons voir dans cet article la mise en place d&#8217;un callback sur une entité dans symfony2. Contexte Nous allons ici prendre l&#8217;exemple d&#8217;un site de commande. Chaque commande a un statut et nous souhaitons enregistrer dans la base &#8230;<p class="more aright"><a href="http://www.lexik.fr/blog/symfony/symfony2/symfony2-creation-dun-service-1690">...</a></p>]]></description>
			<content:encoded><![CDATA[<p>Bonjour,</p>
<p>Nous allons voir dans cet article la mise en place d&#8217;un callback sur une entité dans symfony2.</p>
<h2>Contexte</h2>
<p>Nous allons ici prendre l&#8217;exemple d&#8217;un site de commande. Chaque commande a un statut et nous souhaitons enregistrer dans la base de données chaque changement de statut afin de conserver un historique.</p>
<p>Pour cela, Symfony2 et Doctrine fournissent un ensemble d&#8217;actions pouvant être appelées à chaque étapes du cycle de vie d&#8217;une entité (&laquo;&nbsp;lifecycle&nbsp;&raquo;).<br />
<span id="more-1690"></span><br />
Vous trouverez à cette adresse l&#8217;ensemble des événements disponibles: <a href="http://www.doctrine-project.org/docs/orm/2.0/en/reference/events.html#lifecycle-events" target="_blank">Lifecycle Events</a></p>
<p>Dans notre cas, nous avons choisi d&#8217;effectuer la sauvegarde du statut après chaque mise à jour de notre entité Order (qui gère les commandes du site). Pour cela nous allons utiliser l’événement postUpdate qui sera appelé après chaque update de l&#8217;entité.</p>
<p>Voici, les deux objets concernés par ce service:</p>
<p>L&#8217;objet commande</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1690code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p16906"><td class="code" id="p1690code6"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Projet\OrderBundle\Entity\Order
 *
 * @ORM\Entity(repositoryClass=&quot;Projet\OrderBundle\Repository\OrderRepository&quot;)
 * @ORM\Table(name=&quot;Projet_order_order&quot;)
 * @ORM\HasLifecycleCallbacks
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Order
<span style="color: #009900;">&#123;</span>
     <span style="color: #009933; font-style: italic;">/**
     * @var integer $id
     *
     * @ORM\Column(name=&quot;id&quot;, type=&quot;integer&quot;)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy=&quot;AUTO&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @var Yatoo\UserBundle\Entity\User $user
     *
     * @ORM\ManyToOne(targetEntity=&quot;Yatoo\UserBundle\Entity\User&quot;, inversedBy=&quot;orders&quot;)
     * @ORM\JoinColumn(name=&quot;user_id&quot;, referencedColumnName=&quot;id&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$user</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @var string $comment
     *
     * @ORM\Column(name=&quot;title&quot;, type=&quot;string&quot;, length=255)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$title</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @var decimal $price
     *
     * @ORM\Column(name=&quot;price&quot;, type=&quot;decimal&quot;, length=&quot;7&quot;, scale=&quot;2&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$price</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @var integer $quantity
     *
     * @ORM\Column(name=&quot;quantity&quot;, type=&quot;integer&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$quantity</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @var Yatoo\CardBundle\Entity\Pricing $pricing
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$pricing</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #009933; font-style: italic;">/**
     * @var smallint $status
     *
     * @ORM\Column(name=&quot;status&quot;, type=&quot;smallint&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$status</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @var text $comment
     *
     * @ORM\Column(name=&quot;comment&quot;, type=&quot;text&quot;, nullable=&quot;true&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$comment</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @ORM\OneToMany(targetEntity=&quot;HistoricalStatus&quot;, mappedBy=&quot;order&quot;, cascade={&quot;all&quot;})
     * @ORM\JoinColumn(name=&quot;order_id&quot;, referencedColumnName=&quot;id&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$historicalStatus</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @Gedmo\Timestampable(on=&quot;create&quot;)
     * @ORM\Column(name=&quot;created_at&quot;, type=&quot;datetime&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$createdAt</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$statusOld</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #339933;">...</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p> Et HistoricalStatus qui servira à stocker l&#8217;historique des changements de statut des commandes.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1690code7'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p16907"><td class="code" id="p1690code7"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Projet\OrderBundle\Entity\HistoricalStatus
 *
 * @ORM\Entity(repositoryClass=&quot;Projet\OrderBundle\Repository\HistoricalStatusRepository&quot;)
 * @ORM\Table(name=&quot;Projet_order_historical_status&quot;)
 * @ORM\HasLifecycleCallbacks
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> HistoricalStatus
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * @var integer $id
     *
     * @ORM\Column(name=&quot;id&quot;, type=&quot;integer&quot;)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy=&quot;AUTO&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @var object $order
     *
     * @ORM\ManyToOne(targetEntity=&quot;Order&quot;, inversedBy=&quot;files&quot;)
     * @ORM\JoinColumn(name=&quot;order_id&quot;, referencedColumnName=&quot;id&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$order</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @var smallint $status
     *
     * @ORM\Column(name=&quot;status&quot;, type=&quot;smallint&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$status</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @var text $comment
     *
     * @ORM\Column(name=&quot;comment&quot;, type=&quot;text&quot;, nullable=&quot;true&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$comment</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * @Gedmo\Timestampable(on=&quot;create&quot;)
     * @ORM\Column(name=&quot;created_at&quot;, type=&quot;datetime&quot;)
     */</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$createdAt</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #339933;">...</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>Mise en place</h2>
<p>Dans un premier temps, il faut créer le dossier Listener dans votre bundle.Dans notre exemple ce dossier se trouvera à l&#8217;adresse : repSite/src/Projet/OrderBundle/Listener puis créer le fichier OrderListener.php.</p>
<p>Voici pour exemple le code de notre service:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1690code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p16908"><td class="code" id="p1690code8"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">namespace</span> Projet\OrderBundle\Listener<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> Projet\OrderBundle\Entity\HistoricalStatus<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Projet\OrderBundle\Entity\Order<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> Doctrine\ORM\Event\LifecycleEventArgs<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> OrderListener
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> postUpdate<span style="color: #009900;">&#40;</span>LifecycleEventArgs <span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000088;">$entity</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$args</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getEntity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$entityManager</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$args</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getEntityManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$entity</span> instanceof Order<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entity</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOldStatus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$entity</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getStatus<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$historicalStatus</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HistoricalStatus<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$historicalStatus</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOrder</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entity</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$historicalStatus</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setComment</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entity</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getComment<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$historicalStatus</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setStatus</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$entity</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getStatus<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$entityManager</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">persist</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$historicalStatus</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$entityManager</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Pour expliquer rapidement ce que fait ce bout de code :</p>
<p>Si le statut de la commande a changé, on crée un nouveau statut historique et on l&#8217;enregistre.</p>
<p>La fonction $entity->getOldStatus() permet de récupérer l&#8217;ancien statut de la commande avant sa mise à jour. La valeur est initialisée à la création de l&#8217;objet dans le constructeur.</p>
<h2>Configuration</h2>
<p>Une fois votre listener écrit, il faut le configurer pour qu&#8217;il soit appelé. Pour cela, éditer simplement le fichier : Projet\OrderBundle\Ressources\config\services.xml et ajoutez y ces lignes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1690code9'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p16909"><td class="code" id="p1690code9"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;order.postUpdate&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;Projet\OrderBundle\Listener\OrderListener&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;tag</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;doctrine.event_listener&quot;</span> <span style="color: #000066;">event</span>=<span style="color: #ff0000;">&quot;postUpdate&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Vous pouvez aussi le déclarer en yml :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1690code10'); return false;">View Code</a> YML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p169010"><td class="code" id="p1690code10"><pre class="yml" style="font-family:monospace;">services:
    order.postUpdate :
        class: Projet\OrderBundle\Listener\OrderListener
        tags:
            - { name: doctrine.event_listener, event: postUpdate }</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/symfony2/symfony2-creation-dun-service-1690/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Stofcplugin : faire de bien jolis graphiques avec symfony</title>
		<link>http://www.lexik.fr/blog/symfony/non-classe/stofcplugin-faire-de-bien-jolis-graphiques-avec-symfony-692</link>
		<comments>http://www.lexik.fr/blog/symfony/non-classe/stofcplugin-faire-de-bien-jolis-graphiques-avec-symfony-692#comments</comments>
		<pubDate>Thu, 18 Jun 2009 16:32:17 +0000</pubDate>
		<dc:creator>Bérenger</dc:creator>
				<category><![CDATA[Non classé]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[graphique]]></category>
		<category><![CDATA[Stofcplugin]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/sfblog/?p=692</guid>
		<description><![CDATA[Aujourd&#8217;hui , nous allons découvrir un plugin symfony permettant de réaliser simplement des graphiques en flash à partir d&#8217;un tableau de donnée. Il gère les : Histogrammes Graphique en courbes Graphiques en secteurs Graphiques en barres Graphiques en aires Les &#8230;<p class="more aright"><a href="http://www.lexik.fr/blog/symfony/non-classe/stofcplugin-faire-de-bien-jolis-graphiques-avec-symfony-692">...</a></p>]]></description>
			<content:encoded><![CDATA[<p>Aujourd&#8217;hui , nous allons découvrir un plugin symfony permettant de réaliser simplement des graphiques en flash à partir d&#8217;un tableau de donnée.</p>
<p>Il gère les :</p>
<ul>
<li>Histogrammes</li>
<li>Graphique en courbes</li>
<li>Graphiques en secteurs</li>
<li>Graphiques en barres</li>
<li>Graphiques en aires</li>
</ul>
<p><span id="more-692"></span><br />
Les graphiques générés sont entièrement paramétrables : choix des couleurs , des titres .</p>
<p>L&#8217;installation du plugin est très simple :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p692code16'); return false;">View Code</a> YML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69216"><td class="code" id="p692code16"><pre class="yml" style="font-family:monospace;">symfony plugin:install stOfcPlugin</pre></td></tr></table></div>

<p>puis</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p692code17'); return false;">View Code</a> YML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69217"><td class="code" id="p692code17"><pre class="yml" style="font-family:monospace;">symfony cc</pre></td></tr></table></div>

<p>Ensuite , dans le template où l&#8217;on veut afficher le graphique on copie la ligne suivante :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p692code18'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69218"><td class="code" id="p692code18"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>code<span style="color: #339933;">&gt;</span>
stOfc<span style="color: #339933;">::</span><span style="color: #004000;">createChart</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">300</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'quiz_sondage/pieChartData?slug='</span><span style="color: #339933;">.</span><span style="color: #000088;">$quiz</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getSlug<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> fal
<span style="color: #339933;">&lt;/</span>code<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Les premiers paramètres correspondent à la taille du graphique tandis que le second correspond à la route qui appelle la fonction qui génèrera le graphique.</p>
<p>Si vous ne voulez pas définir une route supplémentaire vous pouvez appelez la fonction comme ceci : module/action</p>
<p>Le readme du contient des exemples pour bien commencé :</p>
<p>http://www.symfony-project.org/plugins/stOfcPlugin</p>
<p>Ce plugin est basé sur un projet open-source, voici l&#8217;adresse :</p>
<p>http://teethgrinder.co.uk/open-flash-chart/</p>
<p>Le site contient toute la doc nécessaire</p>
<p>Et voici l&#8217;adresse du forum d&#8217;aide : ( ça peut toujours servir )</p>
<p>http://forums.openflashchart.com/</p>
<h2>Autre solution pour faire des graphique sans flash : jpgraph</h2>
<p>Pour télécharger la libraire jpgraph : http://www.aditus.nu/jpgraph</p>
<p>On va donc voir comment l&#8217;utiliser avec sympfony :</p>
<p>Télécharger la dernière realease pour <strong>PHP5</strong></p>
<p>Dans un premier temps copier le dossier jpgraph obtenu après la décompression de l&#8217;archive dans le dossier lib de votre projet</p>
<p>Faites un symfony cc</p>
<p>dans le template voulu copier la ligne suivante :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p692code19'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69219"><td class="code" id="p692code19"><pre class="html" style="font-family:monospace;">&lt;code&gt;
&lt;img class=&quot;graph&quot; src=&quot;&amp;lt;?php echo url_for('@actionSouhaité'); ?&amp;gt;&quot; alt=&quot;&quot; /&gt;
&lt;/code&gt;</pre></td></tr></table></div>

<p>&nbsp;&raquo; /&gt;</p>
<p>@actionSouhaité = la route appelant l&#8217;action qui va générer l&#8217;image.</p>
<p>Maintenant on va voir un modèle d&#8217;action pour génèrer l&#8217;image :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p692code20'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p69220"><td class="code" id="p692code20"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> executeGraph<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
&nbsp;
      <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$ydata</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Tableau des valeurs</span>
      <span style="color: #000088;">$xdata</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Tableau axis ( légénde des valeurs )</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Code pour remplir les tableau comme vous voulez    </span>
&nbsp;
     <span style="color: #666666; font-style: italic;">// Création du graph type courbe</span>
      <span style="color: #000088;">$graph</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Graph<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1300</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">400</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;auto&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$graph</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>SetScale<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;textlin&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$graph</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>title<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Set<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Evolution du nombre d\'inscription'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$graph</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>title<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>SetFont<span style="color: #009900;">&#40;</span>FF_FONT1<span style="color: #339933;">,</span>FS_BOLD<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$line</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> LinePlot<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ydata</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$graph</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Add<span style="color: #009900;">&#40;</span><span style="color: #000088;">$line</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$line</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>SetColor<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#36393D&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$line</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>SetWeight<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$graph</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>xaxis<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setTickLabels<span style="color: #009900;">&#40;</span><span style="color: #000088;">$xdata</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Output graph</span>
      <span style="color: #000088;">$graph</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Stroke<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #b1b100;">return</span> sfView<span style="color: #339933;">::</span><span style="color: #004000;">NONE</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Important pour que l'action retourne que le code de l'image</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/non-classe/stofcplugin-faire-de-bien-jolis-graphiques-avec-symfony-692/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Une infobulle pour l&#8217;admin générator</title>
		<link>http://www.lexik.fr/blog/symfony/symfony/admingenerator-12x/utilisation-admin-generator-astuce-457</link>
		<comments>http://www.lexik.fr/blog/symfony/symfony/admingenerator-12x/utilisation-admin-generator-astuce-457#comments</comments>
		<pubDate>Thu, 09 Apr 2009 13:39:54 +0000</pubDate>
		<dc:creator>Bérenger</dc:creator>
				<category><![CDATA[Admingenerator 1.2.x]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[generator]]></category>

		<guid isPermaLink="false">http://www.lexik.fr/sfblog/?p=457</guid>
		<description><![CDATA[Voici quelques astuces pour rendre le backend d&#8217;un site généré par symfony accessible au plus grand nombre et de faciliter la compréhension pour l&#8217;administrateur du site Web. Petit rappel, les formulaires sont placés dans le dossier : votre-projet/lib/form et un &#8230;<p class="more aright"><a href="http://www.lexik.fr/blog/symfony/symfony/admingenerator-12x/utilisation-admin-generator-astuce-457">...</a></p>]]></description>
			<content:encoded><![CDATA[<p>Voici quelques astuces pour rendre le backend d&#8217;un site généré par symfony accessible au plus grand nombre et de faciliter la compréhension pour l&#8217;administrateur du site Web.</p>
<p>Petit rappel, les formulaires sont placés dans le dossier : votre-projet/lib/form<br />
et un tuto pour apprendre à les utiliser :<a title="Formulaires symfony 1.2" href="http://www.symfony-project.org/forms/1_2/"> Formualires symfony 1.2</a></p>
<p><strong>Voici deux  petites astuces :</strong></p>
<p><span id="more-457"></span></p>
<p>Lors de la création d&#8217;un formulaire , il est possible de rajouter une zone html en dessous d&#8217;un champs.<br />
La ligne suivante permet de faire ça :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p457code26'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p45726"><td class="code" id="p457code26"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>widgetSchema<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setHelp<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'champs'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'code html'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Résulat :</p>
<p><img class="alignnone size-full wp-image-471" title="help" src="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/04/help.jpg" alt="help" width="522" height="54" /></p>
<p>Il est aussi possible d&#8217;injecter du code html dans le label d&#8217;un champs. Partant de ce constat , j&#8217;ai alors créé une petite classe qui va générer une image avec une info-bulle.</p>
<p>On crée en suite le fichier bulle.js dans le dossier web/js. Ce code permet de générer l&#8217;info-bulle.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p457code27'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p45727"><td class="code" id="p457code27"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> GetId<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">return</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// La variable i nous dit si la bulle est visible ou non</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> move<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  <span style="color: #006600; font-style: italic;">// Si la bulle est visible, on calcul en temps reel sa position ideale</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">appName</span><span style="color: #339933;">!=</span><span style="color: #3366CC;">&quot;Microsoft Internet Explorer&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// Si on est pas sous IE</span>
GetId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;curseur&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">left</span><span style="color: #339933;">=</span>e.<span style="color: #660066;">pageX</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">;</span>
GetId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;curseur&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">top</span><span style="color: #339933;">=</span>e.<span style="color: #660066;">pageY</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// Modif proposé par TeDeum, merci à lui</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">documentElement</span>.<span style="color: #660066;">clientWidth</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
GetId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;curseur&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">left</span><span style="color: #339933;">=</span><span style="color: #CC0000;">20</span><span style="color: #339933;">+</span>event.<span style="color: #660066;">x</span><span style="color: #339933;">+</span>document.<span style="color: #660066;">documentElement</span>.<span style="color: #660066;">scrollLeft</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">;</span>
GetId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;curseur&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">top</span><span style="color: #339933;">=</span><span style="color: #CC0000;">10</span><span style="color: #339933;">+</span>event.<span style="color: #660066;">y</span><span style="color: #339933;">+</span>document.<span style="color: #660066;">documentElement</span>.<span style="color: #660066;">scrollTop</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
GetId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;curseur&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">left</span><span style="color: #339933;">=</span><span style="color: #CC0000;">20</span><span style="color: #339933;">+</span>event.<span style="color: #660066;">x</span><span style="color: #339933;">+</span>document.<span style="color: #660066;">body</span>.<span style="color: #660066;">scrollLeft</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">;</span>
GetId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;curseur&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">top</span><span style="color: #339933;">=</span><span style="color: #CC0000;">10</span><span style="color: #339933;">+</span>event.<span style="color: #660066;">y</span><span style="color: #339933;">+</span>document.<span style="color: #660066;">body</span>.<span style="color: #660066;">scrollTop</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> montre<span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
GetId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;curseur&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">visibility</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;visible&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Si il est cacher (la verif n'est qu'une securité) on le rend visible.</span>
GetId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;curseur&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> text<span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Cette fonction est a améliorer, il parait qu'elle n'est pas valide (mais elle marche)</span>
i<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> cache<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
GetId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;curseur&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">visibility</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;hidden&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Si la bulle etais visible on la cache</span>
i<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
document.<span style="color: #660066;">onmousemove</span><span style="color: #339933;">=</span>move<span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// des que la souris bouge, on appelle la fonction move pour mettre a jour la position de la bulle.</span>
<span style="color: #006600; font-style: italic;">//--&amp;gt;</span></pre></td></tr></table></div>

<p>Puis on crée le fichier bt.css dans le dossier  web/css. Ce fichier permet de modifier l&#8217;aspect de l&#8217;info-bulle pour qu&#8217;elle soit assortie au backend.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p457code28'); return false;">View Code</a> CSS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p45728"><td class="code" id="p457code28"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.infobulle</span>
<span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">visibility</span> <span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#CC0000</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Verdana<span style="color: #00AA00;">,</span> Arial<span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#FFFFFF</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Ensuite , on crée le fichier bulle.class.php dans le dossier lib du projet</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p457code29'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p45729"><td class="code" id="p457code29"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> bulle
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> bubble<span style="color: #009900;">&#40;</span><span style="color: #000088;">$Message</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;a onmouseover=&quot;montre(\''</span><span style="color: #339933;">.</span><span style="color: #000088;">$Message</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'\');&quot; onmouseout=&quot;cache()&quot; href=&quot;#&quot;&gt;&lt;img src=&quot;../images/aide.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&amp;amp;nbsp;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Une dernière chose, il faut maintenant inclure une div dans la page où est affiché le formulaire. pour cela on va sur-définir le fichier : _form_header.php</p>
<p>Il est à placé dans le dossier : votre-pojet/apps/backend/modules/votre-module/templates</p>
<p>Ensuite il suffit de rajouter bulle::bubble( texte a affiché dans la bulle ) quand on implémente le label</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p457code30'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p45730"><td class="code" id="p457code30"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>widgetSchema<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setLabel<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #339933;">,</span>bulle<span style="color: #339933;">::</span><span style="color: #004000;">bubble</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Référence du contenu'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'Référence'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><strong>Résultat : </strong></p>
<p><img class="alignnone size-full wp-image-470" title="bulle" src="http://www.lexik.fr/blog/symfony/wp-content/uploads/2009/04/bulle.jpg" alt="bulle" width="500" /></p>
<p>Ainsi vous pouvez donner le maximum d&#8217;information sur l&#8217;impact d&#8217;un champs pour que l&#8217;administrateur du site internet sache ce qu&#8217;il fait</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lexik.fr/blog/symfony/symfony/admingenerator-12x/utilisation-admin-generator-astuce-457/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

