public function __construct(Factory $factory, array $urlParameters = null) { $this->_factory = $factory; $url = ltrim($this->_url, '/'); // prepare uri if ($urlParameters) { $url = array($url, $urlParameters); } else { // check if placeholders exists if (strpos($url, '{')) { throw new Exception('Url parameters not specified'); } } // create request $this->_request = $factory->getConnection()->createRequest($this->_requestMethod, $url); // add behaviors $this->attachBehaviors($this->behaviors()); // do post-init tasks $this->init(); }
/** * * @param type $name * @param array $urlParameters * @return \Sokil\Rest\Request */ public function createRequest($name, array $urlParameters = null) { $request = parent::createRequest($name, $urlParameters); // authorise if (!$this->isAuthorised() && strtolower($name) !== 'auth') { $this->_auth(); } // client authorised - set token to request $request->setQueryParam('auth_token', $this->_token); return $request; }