1. #81
    Ext User
    Join Date
    May 2010
    Posts
    4
    Vote Rating
    0
    athome is on a distinguished road

      0  

    Default


    Hello everyone,

    Dan thank you for taking the time to bring this wonderful invention that is Ext.Direct to Symfony.

    I wrote you an email this morning before discovering this post, apologies, sorry for the spam.

    I have progressed since then, but I still have some misunderstandings.

    Here's firebug log I get with the request to extdirect.php :

    Code:
    {"Action": "event", "method": "multiply", "data": [2], "type": "rpc", "tid": 2}
    Here is the answer (in French ?!?!?!?)

    Échec du chargement de la source pour: http://www.extdirect_symfony.lab/extdirect.php
    ( eq : Failed to load source for: http://www.extdirect_symfony.lab/extdirect.php )

    If I summarize:

    - App.yml
    Code:
    all:
      ds_ext_direct_plugin:
        action_namespace: RPCTEST
    -Factories.yml
    Code:
    extdirect:
      controller:
        class: dsExtDirectController
    I left the code unchange for the function "multiply", on my event module.

    And the client call :

    Code:
    ...
          <link rel="stylesheet" type="text/css" href="/direct/ext/resources/css/ext-all.css">
          <script type="text/javascript" src="/direct/ext/adapter/ext/ext-base.js"></script>
          <script type="text/javascript" src="/direct/ext/ext-all-debug.js"></script>
          <script type="text/javascript" src="/js/extdirect_api.js"></script>
          <script type="text/javascript">
       
        Ext.Direct.addProvider( Ext.app.EXTDIRECT_API );
        RPCTEST.event.multiply( 2, function(response, e ){ alert(response) });
        
        </script>
      </head>
    => alert reponse is undefined

    Here is the result of extdirect-generate :

    - Extdirect_api.js :
    Code:
    Ext.app.EXTDIRECT_API = {"url":"\/extdirect.php","type":"remoting","actions":{"event":[{"name":"multiply","len":1}]},"namespace":"RPCTEST"};
    - extdirect.php controler is created, as extdirect_api.yml

    So, everything looks fine... Maybe I forgot something. I read the seventh page post...

    - What is the value of extdirect_api.json ?

    - If I understand, the purpose of the statement in the factories.yml file is to declare a controller, and thus, an environment. Why create a special envirronnement? Since I do not understand, I tried to add the statement in ENV or ALL, but it break it all ...
    Should I forgot something towards the creation of a special envirronnement ? Is File factories enough ?
    Visit my blog : e-laboratory

  2. #82
    Ext User
    Join Date
    May 2010
    Posts
    4
    Vote Rating
    0
    athome is on a distinguished road

      0  

    Default


    Everything is fine, now.

    The correct call in the template is :

    Code:
    RPCTEST.event.multiply( {"number":2}, function(response, e ){ console.debug(response); console.debug(e);  });
    The first param is an object, not a scalar value. That is probably why my code alert undefined.
    Visit my blog : e-laboratory

  3. #83
    Ext User
    Join Date
    May 2010
    Posts
    4
    Vote Rating
    0
    athome is on a distinguished road

      0  

    Default How-to map client form to Doctrine object

    How-to map client form to Doctrine object


    Hello Dan, Hi Ext tribe,

    I continue my Direct exploration ...

    What solution are you using to match the form data to those of a Doctrine object ?

    Example, with an event table : date_start, date_end, title, ...

    Here is a working code, but I find it extremely naive :

    Code:
    $form = new EventForm();
    $form->disableCSRFProtection();
    
    $tempEvent = array(
                "start" => array(
                    'month' => $start_tempDate[1],
                      'day' => $start_tempDate[2],
                      'year' => $start_tempDate[0],
                      'hour' => $start_tempTime[0],
                      'minute' =>$start_tempTime[1]
                ),
                "end" => array(
                    'month' => $end_tempDate[1],
                      'day' => $end_tempDate[2],
                      'year' => $end_tempDate[0],
                      'hour' => $end_tempTime[0],
                      'minute' =>$end_tempTime[1]
                ),
                "eventName" => $this->getRequestParameter('title'),
                "allDay" =>  $this->getRequestParameter('isAllday'),
                "eventDesc" => $this->getRequestParameter('description'),
                $form->getCSRFFieldName() => $form->getCSRFToken("dc8a160b3caa48277addacfaa2e573f935bcaf76")
    );
    
    $form->bind( $tempEvent  );
    
    if( $form->isValid() )
    {
              $event = $form->save();
        
              $this->result = $event->getPrimaryKey();
    }
    else
    {
              $this->result = $form->getGlobalErrors();
    }
            
    return sfView::SUCCESS;
    Some comments:

    - With a normal ajax request, there is no problem, we have the same POST data, but there, we must completely rebuild the bidding process. How did you do?
    - Can not disable the security token. How do you stand out?
    - What about @extdirect-formhandler? Is not this a case of possible use ? How to implement ?

    I tryed :

    Code:
    $event = new Event();
    $event->start = $this->getRequestParameter('start');
    $event->end = $this->getRequestParameter('end');
    $event->eventName = $this->getRequestParameter('title');
    $event->allDay = $this->getRequestParameter('isAllday');
    $event->eventDesc = $this->getRequestParameter('description');
    
    $form->bind( $event->toArray() );
    I find this way more elegant, but I can not make it work. If I manually add the security token, the code throws an error because "Event" has no "CRSF" field , but if I add not, I get a Securityerror ...

    Any comments, shared experience, is welcome.
    Visit my blog : e-laboratory

  4. #84
    Ext JS Premium Member dancablam's Avatar
    Join Date
    Apr 2008
    Location
    Dallas, TX
    Posts
    134
    Vote Rating
    0
    dancablam is on a distinguished road

      0  

    Default


    Hi athome,

    The purpose of the declarations in the factories.yml is to define a separate controller that's used only by Ext.Direct requests. Symfony's default controller accepts standard web requests and populates things like POST data in the sfWebRequest object, enables for page redirection, etc. Since dsExtDirect uses JSON-RPC a standard web request won't do, so we need a separate controller that can make sense of the data posted by Ext.Direct and populate sfWebRequest, etc.

    To match the data submitted by an Ext.Direct direct request, in my experience, takes a bit of extra creativity. I typically don't create/use symfony forms with working with Ext.Direct data. I do often, however, use the validators that are generated by the form to make sure the data conforms to my requirements. There are many ways to do this - I recommend browsing the form API to see what your options are. However, the way you do it above I think is perhaps pretty close - and a good way to do it. I've had trouble disabling CSRF too before. One work-around is to find a way to pass the CSRF data and make it a hidden form element in your Ext form. Aside from that I'd get on the symfony boards and ask why your attempts to disable CSRF aren't working - I'd like to know what you find out too because that's always confused me.

    @extdirect-formhandler is really only for use in Ext forms that have one or more file-upload field. If your form doesn't have file-upload @extdirect-formhandler should be excluded.

    I hope this helps some.

    Please let me know if I can answer any more questions for you.

    Cheers,
    Dan

  5. #85
    Ext User
    Join Date
    May 2010
    Posts
    4
    Vote Rating
    0
    athome is on a distinguished road

      0  

    Default


    Hello Dan,

    I published a few days ago my account on ExtDirect - Symfony use, thanks to your plugin.

    It is there:

    Ext.Direct & Symfony, DsExtDirectPlugin: testing implementation

    Here is the code I used to map ExtDirect data to a Doctrine object:

    Code:
    $form = new EventForm();
    $form->disableCSRFProtection();
      
    $event = new Event();
    $event->start = $this->getRequestParameter('start');
    $event->end = $this->getRequestParameter('end');
    $event->eventName = $this->getRequestParameter('title');
    $event->allDay = $this->getRequestParameter('isAllday');
    $event->eventDesc = $this->getRequestParameter('description');
      
    $aEvent = $event->toArray();
    $aEvent[ $form->getCSRFFieldName() ] = $form->getCSRFToken("my key here");
      
    $form->bind( $aEvent );
    The idea of sending the key to the client is a good idea that I'll probably use to correct my tutorial. I am a bit disappointed by the fact that you also met this difficulty. This means that the error comes from symfony, this is not common.

    About "@extdirect-formhandler", this means that dsExtDirectPlugin can handle file uploads? Do you have a short example to put me on the way?

    thank you for everything
    Visit my blog : e-laboratory

  6. #86
    Ext User
    Join Date
    Apr 2010
    Posts
    1
    Vote Rating
    0
    fanch50 is on a distinguished road

      0  

    Default


    Hi,

    Not original but big thanks for these great tools ! ExtJs & dsExtDirectPlugin combination is a really efficient way to create a WebApp !

    I have write a WebApp using dsExtDirectPlugin but now I want to secure it.

    Before I dive into, have you any recommandations to manage this ?

    I have see that we can include some plugins like sfGuardPlugin in app.yml but I have no idea how to use this option

    # Optional. List plugins who's action classes you want included in API generation (defaults to null)
    # ex: include_plugins: [sfGuardPlugin]
    #include_plugins: ~

    Could you help me ?

    Thanks !

  7. #87
    Ext JS Premium Member dancablam's Avatar
    Join Date
    Apr 2008
    Location
    Dallas, TX
    Posts
    134
    Vote Rating
    0
    dancablam is on a distinguished road

      0  

    Default


    Hi fanch50,

    I personally have never used the sfGuardPlugin plugin as I normally write my own authentication and security methods. However, the dsExtDirectPlugin, as you pointed out, does support plugins like sfGuardPlugin. It's really as simple as adding sfGuardPlugin to the include_plugins directive (ex: include_plugins: [sfGuardPlugin]) and then in the action classes that you create that extend from sfGuardPlugin you can add @extdirect-enable to the comments and this will enable those actions in the ext.direct API. I hope that makes at least some sense. Please don't hesitate to let me know if I can clarify anything further for you!

    Cheers,
    Dan

  8. #88
    Sencha User
    Join Date
    Sep 2010
    Posts
    5
    Vote Rating
    0
    turbod is on a distinguished road

      0  

    Default How to write unit test or functional test from Ext.Direct?

    How to write unit test or functional test from Ext.Direct?


    Hi! How can i write functional test or unit test from Ext.Direct?
    I use symfony 1.4 and dsExtDirectPlugin 1.0.5

  9. #89
    Sencha User
    Join Date
    Oct 2010
    Location
    Cusco
    Posts
    11
    Vote Rating
    0
    jorgelive is on a distinguished road

      0  

    Talking Symfony 2 Support

    Symfony 2 Support


    Hi Dan:

    Are you planing on making some ext direct bundle for ext direct and symfony2?

  10. #90
    Touch Premium Member
    Join Date
    Sep 2010
    Posts
    20
    Vote Rating
    0
    spaff is on a distinguished road

      0  

    Default


    Hi!

    First of all, thank you for your Plugin, it works great!

    I just wondered if there is a way to keep the possibility to switch between a development and a production environment? There are a lot of settings we have to switch between dev and prod and it wouldn't be possible to switch the settings by hand.