Threaded View

  1. #1
    Sencha User willf1976's Avatar
    Join Date
    May 2009
    Location
    carpinteria, ca
    Posts
    84
    Vote Rating
    0
    willf1976 is on a distinguished road

      0  

    Default Zend Framework Ext.Direct implementation

    Zend Framework Ext.Direct implementation


    Hi All


    I have been going through the classes we have developed over the last few years and sharing back with the community some of them that I think will be useful to others.


    Our application is very heavily ext direct based. We liked the php ext direct implantation created by TommyMaintz (http://www.sencha.com/forum/showthre...ation&p=331128) so we re purposed it to work with our Zend Framework implementation. Please see this thread for more documentation.


    Our controller class automatically generates an Ext.ss.APIDesc object based on the exposed controller actions with in each class that is then used by Ext.Direct.addProvider to expose these direct methods to javascript.


    This means that any views associated with a controller that extends Zend_Controller_Action_Direct will have it's actions that have been tagged as @remotable exposed automatically as direct methods for ext to access via javascript space.


    All methods exposed in this way can also be access via post methods which our code automatically translates into direct methods.


    To use this post functionality just call the post method of your controller submitting a value of: "postAction". The postAction should be name of the method on the controller you wish to invoke as if it were being called through ext direct. This will allow you to expose your direct methods as api calls for other web services to interface with.


    We also use optional functionality to pass log in credentials with these post requests but you will need to extend our class to make this work with your own implementation.


    This project has a few proprietary pieces of code in it which are isolated into methods that 3rd parties may extend for their own purposes. Some our proprietary code was left in place commented out to give the reader an idea of how they may want to extend these methods.


    To make your own implementation of this code be sure you extend and override, or replace the following methods for our own purposes:


    Zend_Controller_Action_Helper_Abstract_Direct_Router::handleMethodException
    Zend_Controller_Action_Helper_Abstract_Direct_Router::handleOtherException
    Zend_Controller_Action_Helper_Abstract_Direct_Router::isAllowed
    Zend_Controller_Action_Direct::login


    You also will need to define a constant that our code uses to find where modules directory is: MODULES_SOURCE. this is referenced in the following places: Zend_Controller_Action_Direct::init, Zend_Controller_Action_Helper_Abstract_Direct_Api::getClassPath


    Attached file contains the following classes:


    Zend_Controller_Action_Helper_Abstract_Direct_Api -- the helper by our controller class
    Zend_Controller_Action_Helper_Abstract_Direct_BogusAction -- used by the direct implementation
    Zend_Controller_Action_Helper_Abstract_Direct_Cache -- used by the direct implementation
    Zend_Controller_Action_Helper_Abstract_Direct_Router -- used by the direct implementation
    Zend_Controller_Action_Direct -- the controller class that your controllers should extend to allow their remotable actions to be automatically exposed


    Make sure to bootstrap in the helper -- in your bootstrap file:


    Code:
    protected function _initZendDirectApi()
        {
    
    
            $zendDirectApi = new Zend_Controller_Action_Helper_Abstract_Direct_Api();
            Zend_Controller_Action_HelperBroker::addHelper($zendDirectApi);
    }

    Here is the layout code that is referenced in our code -- place in your layouts folder:


    direct.phtml:
    Code:
    <?php
    /**
     * @author Will Ferrer, Ethan Brooks
     * @copyright (c) 2012, Intellectual Property Private Equity Group
     *  @licensee 2012 developed under license for Switchsoft LLC  http://www.switchsoft.com a "Direct response telephony company" as part  of it's "VOIP Call distribution, ROI analysis platform, call recording,  and IVR for inbound and outbound sales" and Run the Business Systems LLC  a "Technology development investment group" as part of it's "PHP,  Javascript rapid application development framework and MySQL analysis  tools"
     * @license licensed under the terms of
     * the Open Source LGPL 3.0 license.  Commercial use is permitted to the extent
     * that the code/component(s) do NOT become part of another Open
    Source or Commercially
     * licensed development library or toolkit without explicit permission.
     * <p>License details: <a href="http://www.gnu.org/licenses/lgpl.html"
     * target="_blank">http://www.gnu.org/licenses/lgpl.html</a></p>
    * We are pretty nice just ask. We want to meet our licensees
    */
    echo $this->response;
    ?>

    Be sure that your view or layout files include the ext direct api actions generated by our controller class (apiJS is populated by our controller class but you need to put in your views / layouts yourself)


    Code:
    <?php
    echo "<script>".$this->apiJS."</script>";
    ?>



    Finally, we also use the class in thread below to show and hide a loading mask for direct calls and display exceptions to the user (if configured to allow it):


    http://www.sencha.com/forum/showthread.php?253464


    I have tried to modify our live code to be consumable and ready for extension but I may have missed or bumped something in the process, please let me know if you find any problems with the attached code.


    Best regards


    Will Ferrer (Run the Business)
    Attached Files
    Last edited by willf1976; 18 Jan 2013 at 11:31 AM. Reason: Made title more descriptive

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi