/** * Requests a specific Article based off the passed in code * and office. * * Office is an optional parameter. * * First it attempts to login with the passed configuration into * this instances constructor. If successful it will get the Service * class to handle further interactions. * * If no office has been passed it will instead take the default office * from the passed in config class. * * It makes a new instance of the Request\Read\Article() and sets the * office and code parameters. * * Using the Service class it will attempt to send the DOM document from * Read\Article() * * It sets the response to this instances method setResponse() (which you * can access with getResponse()) * * If the response was successful it will return a * \Pronamic\Twinfield\Article\Article instance, made by the * \Pronamic\Twinfield\Article\Mapper\ArticleMapper class. * * @access public * @param int $code * @param int $office * @return \Pronamic\Twinfield\Article\Article | false */ public function get($code, $office = null) { // Attempts to process the login if ($this->getLogin()->process()) { // Get the secure service class $service = $this->getService(); // No office passed, get the office from the Config if (!$office) { $office = $this->getConfig()->getOffice(); } // Make a request to read a single Article. Set the required values $request_article = new Request\Read\Article(); $request_article->setOffice($office)->setCode($code); // Send the Request document and set the response to this instance. $response = $service->send($request_article); $this->setResponse($response); // Return a mapped article if successful or false if not. if ($response->isSuccessful()) { return ArticleMapper::map($response); } else { return false; } } }