ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 10199


Ignore:
Timestamp:
Jan 17, 2009, 10:11:22 PM (11 years ago)
Author:
ebihara
Message:

#3111:added support for doing GET/POST/PUT/DELETE members by the OpenPNE WEB API

Location:
OpenPNE3/plugins/opWebAPIPlugin/trunk
Files:
10 added
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opWebAPIPlugin/trunk/apps/api/modules/feeds/actions/actions.class.php

    r10183 r10199  
    1414 * @package    OpenPNE
    1515 * @subpackage feeds
    16  * @author     Your name here
    17  * @version    SVN: $Id: actions.class.php 9301 2008-05-27 01:08:46Z dwhittle $
     16 * @author     Kousuke Ebihara <ebihara@tejimaya.com>
    1817 */
    1918class feedsActions extends sfActions
    2019{
     20  public function preExecute()
     21  {
     22    $this->getResponse()->setHttpHeader('GData-Version', 2);
     23    $this->getResponse()->setHttpHeader('Content-Type', 'text/xml');
     24
     25    $request = sfContext::getInstance()->getRequest();
     26    $model = $request->getParameter('model');
     27
     28    $className = 'opAPI'.sfInflector::classify($model);
     29    $this->forward404Unless(class_exists($className));
     30
     31    $params = $request->getParameterHolder()->getAll();
     32    $this->api = new $className($params);
     33  }
     34
    2135 /**
    22   * Executes index action
     36  * Executes retrieveEntries action
    2337  *
    2438  * @param sfRequest $request A request object
    2539  */
    26   public function executeIndex($request)
     40  public function executeRetrieveEntries($request)
    2741  {
    28     $this->forward('default', 'module');
     42    $this->result = $this->api->retrieve();
     43    $this->forward404Unless($this->result);
     44    return $this->renderText($this->result);
     45  }
     46
     47 /**
     48  * Executes insertEntry action
     49  *
     50  * @param sfRequest $request A request object
     51  */
     52  public function executeInsertEntry($request)
     53  {
     54    $this->result = $this->api->insert();
     55    $this->forward404Unless($this->result);
     56
     57    $this->getResponse()->setStatusCode(201);
     58    return $this->renderText($this->result);
     59  }
     60
     61 /**
     62  * Executes updateEntry action
     63  *
     64  * @param sfRequest $request A request object
     65  */
     66  public function executeUpdateEntry($request)
     67  {
     68    $this->result = $this->api->update();
     69    $this->forward404Unless($this->result);
     70    return $this->renderText($this->result);
     71  }
     72
     73 /**
     74  * Executes deleteEntry action
     75  *
     76  * @param sfRequest $request A request object
     77  */
     78  public function executeDeleteEntry($request)
     79  {
     80    $this->result = $this->api->delete();
     81    $this->forward404Unless($this->result);
     82    return sfView::NONE;
    2983  }
    3084}
Note: See TracChangeset for help on using the changeset viewer.