/** * Cache a service map description (SMD) to a file * * Returns true on success, false on failure * * @param string $filename * @param \Zend\Json\Server\Server $server * @return boolean */ public static function saveSmd($filename, Server $server) { if (!is_string($filename) || !file_exists($filename) && !is_writable(dirname($filename))) { return false; } if (0 === @file_put_contents($filename, $server->getServiceMap()->toJson())) { return false; } return true; }
/** * Cache a service map description (SMD) to a file * * Returns true on success, false on failure * * @param string $filename * @param \Zend\Json\Server\Server $server * @return bool */ public static function saveSmd($filename, Server $server) { if (!is_string($filename) || !file_exists($filename) && !is_writable(dirname($filename))) { return false; } ErrorHandler::start(); $test = file_put_contents($filename, $server->getServiceMap()->toJson()); ErrorHandler::stop(); if (0 === $test) { return false; } return true; }
/** * Cache a service map description (SMD) to a file * * Returns true on success, false on failure * * @param string $filename * @param Server $server * @return bool */ public static function saveSmd($filename, Server $server) { if (!is_string($filename) || !file_exists($filename) && !is_writable(dirname($filename))) { return false; } set_error_handler(function ($errno, $errstr) { // swallow errors; method returns false on failure }, E_WARNING); $test = file_put_contents($filename, $server->getServiceMap()->toJson()); restore_error_handler(); if (0 === $test) { return false; } return true; }
public function testLoadFunctionsShouldLoadResultOfGetFunctions() { $this->server->setClass('ZendTest\\Json\\TestAsset\\Foo'); $functions = $this->server->getFunctions(); $server = new Server\Server(); $server->loadFunctions($functions); $this->assertEquals($functions->toArray(), $server->getFunctions()->toArray()); }
/** * (non-PHPdoc). * * @codeCoverageIgnore * * @see \Zend\Json\Server\Server::_handle() */ protected function getParentHandle() { return parent::handleRequest(); }
/** * Handle the SMD request */ protected function renderSmd() { $server = new Server(); $server->setClass($this->serverClass); $smd = $server->getServiceMap(); $smd->setTarget($this->getServiceUri()); $smd->setEnvelope(Smd::ENV_JSONRPC_2); echo $smd; }