예제 #1
0
파일: Cache.php 프로젝트: Rovak/zf2
 /**
  * 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;
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * 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;
 }
예제 #4
0
 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());
 }
예제 #5
0
파일: Server.php 프로젝트: buse974/jrpc
 /**
  * (non-PHPdoc).
  *
  * @codeCoverageIgnore
  *
  * @see \Zend\Json\Server\Server::_handle()
  */
 protected function getParentHandle()
 {
     return parent::handleRequest();
 }
예제 #6
0
 /**
  * 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;
 }