<?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>Agence de Développement Informatique du Nord &#187; Sonata</title>
	<atom:link href="http://blog.adin.pro/category/sonata/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.adin.pro</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Thu, 26 Dec 2019 08:54:31 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.1</generator>
	<item>
		<title>Fatal error : Declaration of {{path}}::validate() must be compatible with that of Sonata\AdminBundle\Admin\AdminInterface::validate()</title>
		<link>http://blog.adin.pro/2013-10-08/fatal-error-declaration-of-pathvalidate-must-be-compatible-with-that-of-sonataadminbundleadminadmininterfacevalidate/</link>
		<comments>http://blog.adin.pro/2013-10-08/fatal-error-declaration-of-pathvalidate-must-be-compatible-with-that-of-sonataadminbundleadminadmininterfacevalidate/#comments</comments>
		<pubDate>Tue, 08 Oct 2013 20:01:30 +0000</pubDate>
		<dc:creator><![CDATA[blogadmin]]></dc:creator>
				<category><![CDATA[Sonata]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Symfony2]]></category>
		<category><![CDATA[validator]]></category>

		<guid isPermaLink="false">http://blog.adin.pro/?p=311</guid>
		<description><![CDATA[<p>You are trying to setup a custom validator on Sonata and you get this error : Fatal error: Declaration of Adin\AdminBundle\Admin\AnnonceAdmin::validate() must be compatible with that of Sonata\AdminBundle\Admin\AdminInterface::validate() in /home/www/arlogis/src/Adin/AdminBundle/Admin/AnnonceAdmin.php on line 250 Don&#8217;t panic, just add this at the &#8230; <a href="http://blog.adin.pro/2013-10-08/fatal-error-declaration-of-pathvalidate-must-be-compatible-with-that-of-sonataadminbundleadminadmininterfacevalidate/">Continue reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="http://blog.adin.pro/2013-10-08/fatal-error-declaration-of-pathvalidate-must-be-compatible-with-that-of-sonataadminbundleadminadmininterfacevalidate/">Fatal error : Declaration of {{path}}::validate() must be compatible with that of Sonata\AdminBundle\Admin\AdminInterface::validate()</a> appeared first on <a rel="nofollow" href="http://blog.adin.pro">Agence de Développement Informatique du Nord</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>You are trying to setup a custom validator on Sonata and you get this error :</p>
<p>Fatal error: Declaration of Adin\AdminBundle\Admin\AnnonceAdmin::validate() must be compatible with that of Sonata\AdminBundle\Admin\AdminInterface::validate() in /home/www/arlogis/src/Adin/AdminBundle/Admin/AnnonceAdmin.php on line 250 </p>
<p>Don&#8217;t panic, just add this at the begining of your class</p>
<pre class="brush: php; title: ; notranslate">
use Sonata\AdminBundle\Validator\ErrorElement;
</pre>
<p>in our example it&#8217;s in this file  : /AdminBundle/Admin/AnnonceAdmin.php</p>
<p>The post <a rel="nofollow" href="http://blog.adin.pro/2013-10-08/fatal-error-declaration-of-pathvalidate-must-be-compatible-with-that-of-sonataadminbundleadminadmininterfacevalidate/">Fatal error : Declaration of {{path}}::validate() must be compatible with that of Sonata\AdminBundle\Admin\AdminInterface::validate()</a> appeared first on <a rel="nofollow" href="http://blog.adin.pro">Agence de Développement Informatique du Nord</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.adin.pro/2013-10-08/fatal-error-declaration-of-pathvalidate-must-be-compatible-with-that-of-sonataadminbundleadminadmininterfacevalidate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symfony2 sonata custom CRUD template</title>
		<link>http://blog.adin.pro/2013-10-07/symfony2-sonata-custom-crud-template/</link>
		<comments>http://blog.adin.pro/2013-10-07/symfony2-sonata-custom-crud-template/#comments</comments>
		<pubDate>Mon, 07 Oct 2013 14:10:57 +0000</pubDate>
		<dc:creator><![CDATA[blogadmin]]></dc:creator>
				<category><![CDATA[Sonata]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Twig]]></category>
		<category><![CDATA[Override]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony2]]></category>
		<category><![CDATA[twig]]></category>

		<guid isPermaLink="false">http://blog.adin.pro/?p=306</guid>
		<description><![CDATA[<p>It is possible to change templates use by default. First, override the controller action method, in your AdminBundle/Controller/SecteurAdminController.php file The import thing on previous code is the render() fonction, the first parameter is the template to use. In our example, &#8230; <a href="http://blog.adin.pro/2013-10-07/symfony2-sonata-custom-crud-template/">Continue reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="http://blog.adin.pro/2013-10-07/symfony2-sonata-custom-crud-template/">Symfony2 sonata custom CRUD template</a> appeared first on <a rel="nofollow" href="http://blog.adin.pro">Agence de Développement Informatique du Nord</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>It is possible to change templates use by default.</p>
<p>First, override the controller action method, in your AdminBundle/Controller/SecteurAdminController.php file</p>
<pre class="brush: php; title: ; notranslate">
 /**
     * return the Response object associated to the list action
     *
     * @return Response
     */
    public function listAction()
    {
        if (false === $this-&gt;admin-&gt;isGranted('LIST')) {
            throw new AccessDeniedException();
        }

        $datagrid = $this-&gt;admin-&gt;getDatagrid();
        $formView = $datagrid-&gt;getForm()-&gt;createView();

        // set the theme for the current Admin Form
        $this-&gt;get('twig')-&gt;getExtension('form')-&gt;setTheme($formView, $this-&gt;admin-&gt;getFilterTheme());

        //custom code from here
        $total = 0;
        $enable = 0;
        $new = 0;
        $site = $this-&gt;admin-&gt;site;

        $repository = $this-&gt;getDoctrine()-&gt;getRepository('TripixAdminBundle:Annonce');
        $total = $repository-&gt;getNombreAnnonceTotal($site);
        $enable = $repository-&gt;getNombreAnnonceEnabled($site);
        $new = $repository-&gt;getNombreAnnonceNew($site);



        return $this-&gt;render('TripixAdminBundle:CRUD:list_secteur.html.twig', array(
            'action'   =&gt; 'list',
            'form'     =&gt; $formView,
            'datagrid' =&gt; $datagrid,
            'total'     =&gt; $total,
            'enable'    =&gt; $enable,
            'new'       =&gt; $new,
        ));
    }
</pre>
<p>The import thing on previous code is the render() fonction, the first parameter is the template to use.<br />
In our example, the template file will be /AdminBundle/Ressources/view/CRUD/list_secteur.html.twig</p>
<p>You can use the /AdminBundle/Ressources/view/CRUD/base_secteur.html.twig file as example for your custom template.</p>
<p>Parent function to override on the controller are here : /vendor/bundles/Sonata/AdminBundle/Controller/CRUDController.php</p>
<p>The post <a rel="nofollow" href="http://blog.adin.pro/2013-10-07/symfony2-sonata-custom-crud-template/">Symfony2 sonata custom CRUD template</a> appeared first on <a rel="nofollow" href="http://blog.adin.pro">Agence de Développement Informatique du Nord</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.adin.pro/2013-10-07/symfony2-sonata-custom-crud-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symfony2 Sonata add custom column on page list</title>
		<link>http://blog.adin.pro/2013-10-07/symfony2-sonata-add-custom-column-on-page-list/</link>
		<comments>http://blog.adin.pro/2013-10-07/symfony2-sonata-add-custom-column-on-page-list/#comments</comments>
		<pubDate>Mon, 07 Oct 2013 12:44:16 +0000</pubDate>
		<dc:creator><![CDATA[blogadmin]]></dc:creator>
				<category><![CDATA[Sonata]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony2]]></category>
		<category><![CDATA[twig]]></category>

		<guid isPermaLink="false">http://blog.adin.pro/?p=302</guid>
		<description><![CDATA[<p>To add a custom column on a page list, just follow these steps. In the example, we will add a &#8220;Nombre d&#8217;annoce(s)&#8221; column. On your admin class file (ex: /AdminBundle/Admin/SecteurAdmin.php), on your configureListFields() fonction, add a new entry on the &#8230; <a href="http://blog.adin.pro/2013-10-07/symfony2-sonata-add-custom-column-on-page-list/">Continue reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="http://blog.adin.pro/2013-10-07/symfony2-sonata-add-custom-column-on-page-list/">Symfony2 Sonata add custom column on page list</a> appeared first on <a rel="nofollow" href="http://blog.adin.pro">Agence de Développement Informatique du Nord</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>To add a custom column on a page list, just follow these steps. In the example, we will add a &#8220;Nombre d&#8217;annoce(s)&#8221; column.</p>
<p>On your admin class file (ex: /AdminBundle/Admin/SecteurAdmin.php), on your configureListFields() fonction, add a new entry on the listMapper object</p>
<pre class="brush: php; title: ; notranslate">
    /**
     * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
     * @return void
     */
    protected function configureListFields(ListMapper $listMapper) {
        $listMapper
                -&gt;addIdentifier('titre')
                -&gt;add('Tri', 'string', array('template' =&gt; 'TripixAdminBundle:Admin:list_tri.html.twig'))
                -&gt;add('Nb', 'string', array('label' =&gt; 'Nombre d\'annonce(s)', 'template' =&gt; 'TripixAdminBundle:Admin:list_nb_annonce.html.twig'))
                -&gt;add('_action', 'actions', array(
                    'actions' =&gt; array(
                        'edit' =&gt; array(),
                        'delete' =&gt; array(),
                    )
                ))
        ;
    }
</pre>
<p>This new entry said to use the TripixADminBundle:Admin:list_tri.html.twig template.</p>
<p>Now, create your template file (list_nb_annonce.html) in the /AdminBundle/ressources/view/admin/ directory.</p>
<pre class="brush: php; title: ; notranslate">
{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}

{% block field%}
{% if admin.datagrid.results|length &gt; 1 %}
 &lt;div&gt;
        &lt;strong&gt;{{ object.getNombreAnnonce}}&lt;/strong&gt;
    &lt;/div&gt;
{% endif %}
{% endblock %}
</pre>
<p>In our example, getNombreAnnonce() is not defined, let&#8217;s do it<br />
In the /adminBundle/Entity/Secteur.php file, add</p>
<pre class="brush: php; title: ; notranslate">
   public function getNombreAnnonce()
    {
      return count($this-&gt;getAnnonces());
    }
</pre>
<p>That&#8217;s all.</p>
<p>The post <a rel="nofollow" href="http://blog.adin.pro/2013-10-07/symfony2-sonata-add-custom-column-on-page-list/">Symfony2 Sonata add custom column on page list</a> appeared first on <a rel="nofollow" href="http://blog.adin.pro">Agence de Développement Informatique du Nord</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.adin.pro/2013-10-07/symfony2-sonata-add-custom-column-on-page-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>must be compatible with that of Sonata\AdminBundle\Admin\AdminInterface::validate() error message</title>
		<link>http://blog.adin.pro/2013-10-06/must-be-compatible-with-that-of-sonataadminbundleadminadmininterfacevalidate-error-message/</link>
		<comments>http://blog.adin.pro/2013-10-06/must-be-compatible-with-that-of-sonataadminbundleadminadmininterfacevalidate-error-message/#comments</comments>
		<pubDate>Sun, 06 Oct 2013 14:53:03 +0000</pubDate>
		<dc:creator><![CDATA[blogadmin]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Sonata]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Symfony2]]></category>
		<category><![CDATA[validator]]></category>

		<guid isPermaLink="false">http://blog.adin.pro/?p=299</guid>
		<description><![CDATA[<p>You are using sonata and want to validate some fields. You innocently add the validate function to your Admin file Then, you get this error : You checked to AdminInterface file the declaration is the same. To fix it, you &#8230; <a href="http://blog.adin.pro/2013-10-06/must-be-compatible-with-that-of-sonataadminbundleadminadmininterfacevalidate-error-message/">Continue reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="http://blog.adin.pro/2013-10-06/must-be-compatible-with-that-of-sonataadminbundleadminadmininterfacevalidate-error-message/">must be compatible with that of Sonata\AdminBundle\Admin\AdminInterface::validate() error message</a> appeared first on <a rel="nofollow" href="http://blog.adin.pro">Agence de Développement Informatique du Nord</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>You are using sonata and want to validate some fields.<br />
You innocently add the validate function to your Admin file</p>
<pre class="brush: php; title: ; notranslate">
function validate(ErrorElement $errorElement, $object)
{
}
</pre>
<p>Then, you get this error :</p>
<pre class="brush: bash; title: ; notranslate">
Fatal error: Declaration of Adin\AdminBundle\Admin\AnnonceAdmin::validate() must be compatible with that of Sonata\AdminBundle\Admin\AdminInterface::validate() in /home/www/arlogis/src/Adin/AdminBundle/Admin/AnnonceAdmin.php on line 251 
</pre>
<p>You checked to AdminInterface file the declaration is the same.</p>
<p>To fix it, you need to use additionnal namespace :</p>
<pre class="brush: php; title: ; notranslate">
use Sonata\AdminBundle\Validator\ErrorElement;
use Symfony\Component\Validator\ValidatorInterface;
</pre>
<p>The post <a rel="nofollow" href="http://blog.adin.pro/2013-10-06/must-be-compatible-with-that-of-sonataadminbundleadminadmininterfacevalidate-error-message/">must be compatible with that of Sonata\AdminBundle\Admin\AdminInterface::validate() error message</a> appeared first on <a rel="nofollow" href="http://blog.adin.pro">Agence de Développement Informatique du Nord</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.adin.pro/2013-10-06/must-be-compatible-with-that-of-sonataadminbundleadminadmininterfacevalidate-error-message/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
