示例#1
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param 	ObjectConfig $config An optional ObjectConfig object with configuration options.
  * @return 	void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('controller' => $this->getIdentifier()->package, 'behaviors' => array('persistable', 'resettable'), 'limit' => array('max' => 1000, 'default' => 20)));
     parent::_initialize($config);
 }
示例#2
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param 	ObjectConfig $config An optional ObjectConfig object with configuration options.
  * @return 	void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('behaviors' => array('persistable', 'resettable'), 'limit' => array('max' => 1000, 'default' => 20)));
     parent::_initialize($config);
 }
示例#3
0
 /**
  * Resolve the request
  *
  * @param DispatcherContext $context A dispatcher context object
  */
 protected function _resolveRequest(DispatcherContext $context)
 {
     if ($controller = ObjectConfig::unbox($context->param)) {
         $url = $this->getObject('lib:http.url', array('url' => $controller));
         //Set the request query
         $context->request->query->clear()->add($url->getQuery(true));
         //Set the controller
         $identifier = $url->toString(HttpUrl::BASE);
         $identifier = $this->getIdentifier($identifier);
         $this->setController($identifier);
     }
     parent::_resolveRequest($context);
 }
示例#4
0
 /**
  * Send the response to the client
  *
  * - Set the affected entities in the payload for none-SAFE requests that return a successful response. Make an
  * exception for 204 No Content responses which should not return a response body.
  *
  * - Add an Allow header to the response if the status code is 405 METHOD NOT ALLOWED.
  *
  * @param DispatcherContext $context   A dispatcher context object
  * @return mixed
  */
 protected function _actionSend(DispatcherContext $context)
 {
     $request = $this->getRequest();
     $response = $this->getResponse();
     if (!$request->isSafe()) {
         if ($response->isSuccess()) {
             //Render the controller and set the result in the response body
             if ($response->getStatusCode() !== HttpResponse::NO_CONTENT) {
                 $controller = $this->getController();
                 $context->result = $controller->execute('render', $controller->getContext($context));
             }
         } else {
             //Add an Allow header to the response
             if ($response->getStatusCode() === HttpResponse::METHOD_NOT_ALLOWED) {
                 try {
                     $this->_actionOptions($context);
                 } catch (Exception $e) {
                     //do nothing
                 }
             }
         }
     }
     return parent::_actionSend($context);
 }