コード例 #1
0
 public static function getByNodeId($id)
 {
     $node = Neo4jClient::client()->getNode($id);
     $content = new Content();
     $content->id = $node->getId();
     $content->title = $node->getProperty('title');
     $content->url = $node->getProperty('url');
     $content->url = $node->getProperty('tags');
     $content->node = $node;
     return $content;
 }
コード例 #2
0
 /**
  * Gets a User by node id
  *
  * @param  int|string $id Node id
  * @return User
  */
 public static function getByNodeId($id)
 {
     return self::fromNode(Neo4jClient::client()->getNode($id));
 }
コード例 #3
0
 /**
  * @group unit
  */
 public function testSetClient()
 {
     $client = $this->getMockClient();
     Neo4jClient::setClient($client);
     $this->assertSame($client, Neo4jClient::client());
 }
コード例 #4
0
 /**
  * Get content by node id
  *
  * @param  int     $id Node id
  * @return Content
  */
 public static function getByNodeId($id)
 {
     $node = Neo4jClient::client()->getNode($id);
     return self::createFromNode($node);
 }
コード例 #5
0
ファイル: app.php プロジェクト: graphstory/graph-kit-php
use GraphStory\GraphKit\Service\UserService;
use GraphStory\GraphKit\Slim\JsonResponse;
use GraphStory\GraphKit\Slim\Middleware\Navigation;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Slim\Middleware\SessionCookie;
use Slim\Mustache\Mustache;
use Slim\Slim;
if (getenv('SLIM_MODE') !== 'test') {
    $neo4jClient = new \Everyman\Neo4j\Client($config['graphStory']['restHost'], $config['graphStory']['restPort']);
    $neo4jClient->getTransport()->setAuth($config['graphStory']['restUsername'], $config['graphStory']['restPassword']);
    if ($config['graphStory']['https']) {
        $neo4jClient->getTransport()->useHttps();
    }
    // neo client
    Neo4jClient::setClient($neo4jClient);
}
$app = new Slim($config['slim']);
$app->container->singleton('logger', function () use($config) {
    $logger = new Logger('graph-kit');
    $logger->pushHandler(new StreamHandler($config['logging']['logFile'], $config['logging']['logLevel']));
    return $logger;
});
$app->jsonResponse = function () use($app) {
    return new JsonResponse($app->response);
};
$app->error(function (\Exception $e) use($app) {
    if ($e instanceof JsonResponseEncodingException) {
        $app->logger->error(sprintf("Error encoding JSON response for request path '%'", $app->request->getPathInfo()));
        $app->jsonResponse->build(array('error' => array('message' => 'Response body could not be parsed as valid JSON')), 500);
        $app->response->finalize();