Пример #1
0
 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->GadgetServer = new GadgetServer();
     // prevent polution from other test cases + make sure we're not testing
     // a cached result
     $_GET = array('nocache' => 1);
     $_POST = array();
     $GadgetContext = new GadgetContext('GADGET');
     $GadgetContext->setUrl('http://test.chabotc.com/testGadget.xml');
     $this->gadget = $this->GadgetServer->processGadget($GadgetContext);
 }
Пример #2
0
 public function process($requests)
 {
     $response = array();
     foreach ($requests->gadgets as $gadget) {
         try {
             $gadgetUrl = $gadget->url;
             $gadgetModuleId = $gadget->moduleId;
             $context = new JsonRpcGadgetContext($requests->context, $gadgetUrl);
             $gadgetServer = new GadgetServer();
             $gadget = $gadgetServer->processGadget($context);
             $response[] = $this->makeResponse($gadget, $gadgetModuleId, $gadgetUrl);
         } catch (Exception $e) {
             $response[] = array('errors' => array($e->getMessage()), 'moduleId' => $gadgetModuleId, 'url' => $gadgetUrl);
         }
     }
     return $response;
 }
 /**
  * Creates the gadget using the GadgetServer class and calls outputGadget
  *
  */
 public function doGet()
 {
     try {
         if (empty($_GET['url'])) {
             throw new GadgetException("Missing required parameter: url");
         }
         // GadgetContext builds up all the contextual variables (based on the url or post)
         // plus instances all required classes (feature registry, fetcher, blacklist, etc)
         $this->context = new GadgetContext('GADGET');
         // Unfortunatly we can't do caja content filtering here, hoping we'll have a RPC service
         // or command line caja to use for this at some point
         $gadgetServer = new GadgetServer();
         $gadget = $gadgetServer->processGadget($this->context);
         $this->outputGadget($gadget, $this->context);
     } catch (Exception $e) {
         $this->outputError($e);
     }
 }