コード例 #1
0
 private function getEntityManager()
 {
     $client = new \Everyman\Neo4j\Client(new \Everyman\Neo4j\Transport('localhost', 7474));
     $em = new Neo4j\EntityManager($client, new Neo4j\MetaRepository());
     $em->setProxyFactory(new Neo4j\ProxyFactory('/tmp', true));
     return $em;
 }
コード例 #2
0
ファイル: Path.php プロジェクト: esynaps/neo4j-ogm
 /**
  * @param RawPath $path
  * @param EntityManager $entityManager
  */
 public function __construct(RawPath $path, EntityManager $entityManager)
 {
     $this->entities = new ArrayCollection();
     foreach ($path as $node) {
         $this->entities->add($entityManager->load($node));
     }
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function authenticate(TokenInterface $token)
 {
     /** @var OAuthToken $token */
     if (!$this->supports($token)) {
         return null;
     }
     try {
         $tokenString = $token->getToken();
         /** @var AccessToken $accessToken */
         if ($accessToken = $this->serverService->verifyAccessToken($tokenString)) {
             $userRepository = $this->entityManager->getRepository(ClassPath::USER);
             $scope = $accessToken->getScope();
             /** @var User $user */
             $user = $userRepository->find($accessToken->getUserId());
             if (!empty($user)) {
                 try {
                     $this->userChecker->checkPreAuth($user);
                 } catch (AccountStatusException $e) {
                     throw new OAuth2AuthenticateException(OAuth2::HTTP_UNAUTHORIZED, OAuth2::TOKEN_TYPE_BEARER, $this->serverService->getVariable(OAuth2::CONFIG_WWW_REALM), 'access_denied', $e->getMessage());
                 }
                 $token->setUser($user);
             }
             $roles = null !== $user ? $user->getRoles() : array();
             if (!empty($scope)) {
                 foreach (explode(' ', $scope) as $role) {
                     $roles[] = 'ROLE_' . strtoupper($role);
                 }
             }
             $token = new OAuthToken($roles);
             $token->setAuthenticated(true);
             $token->setToken($tokenString);
             if (null !== $user) {
                 try {
                     $this->userChecker->checkPostAuth($user);
                 } catch (AccountStatusException $e) {
                     throw new OAuth2AuthenticateException(OAuth2::HTTP_UNAUTHORIZED, OAuth2::TOKEN_TYPE_BEARER, $this->serverService->getVariable(OAuth2::CONFIG_WWW_REALM), 'access_denied', $e->getMessage());
                 }
                 $token->setUser($user);
             }
             return $token;
         }
     } catch (OAuth2ServerException $e) {
         if (!method_exists('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException', 'setToken')) {
             // Symfony 2.1
             throw new AuthenticationException('OAuth2 authentication failed', null, 0, $e);
         }
         throw new AuthenticationException('OAuth2 authentication failed', 0, $e);
     }
     throw new AuthenticationException('OAuth2 authentication failed');
 }
コード例 #4
0
 public function testRelationRemove()
 {
     $eventManager = $this->getEventManagerWithListenerExpectations(array('prePersist' => 3, 'postPersist' => 3, 'preRelationCreate' => 1, 'postRelationCreate' => 1, 'preRelationRemove' => 1, 'postRelationRemove' => 1));
     $movie = new Entity\Movie();
     $movie->setTitle('Terminator');
     $actor = new Entity\Person();
     $actor->setFirstName('Arnold');
     $movie->addActor($actor);
     $this->em->setEventManager($eventManager);
     $this->em->persist($movie);
     $this->em->flush();
     $movie = $this->em->find(get_class($movie), $movie->getId());
     $actor = $movie->getActors()->first();
     $movie->removeActor($actor);
     $this->em->persist($movie);
     $this->em->flush();
 }
コード例 #5
0
ファイル: PathFinder.php プロジェクト: esynaps/neo4j-ogm
 /**
  * @param Object|Proxy $a
  * @param Object|Proxy $b
  * @return mixed
  */
 protected function preparePaths($a, $b)
 {
     if (!$a instanceof Proxy) {
         $a = $this->entityManager->reload($a);
     }
     if (!$b instanceof Proxy) {
         $b = $this->entityManager->reload($b);
     }
     $startNode = $a->__getNode();
     $endNode = $b->__getNode();
     if (null === $this->relationship) {
         $paths = $startNode->findPathsTo($endNode);
     } else {
         $paths = $startNode->findPathsTo($endNode, $this->relationship);
     }
     if ($this->maxDepth !== null) {
         $paths->setMaxDepth($this->maxDepth);
     }
     if ($this->algorithm !== null) {
         $paths->setAlgorithm($this->algorithm);
     }
     return $paths;
 }
コード例 #6
0
 /**
  * @deprecated
  * @param string $class
  * @return Repository
  */
 protected function getRepository($class)
 {
     trigger_error('Function HireVoice\\Neo4j\\Repository::getRepository is deprecated. Use HireVoice\\Neo4j\\EntityManager::getRepository instead!', E_USER_DEPRECATED);
     return $this->entityManager->getRepository($class);
 }
コード例 #7
0
 /**
  * @inheritdoc
  */
 public function loadUserByUsername($username)
 {
     /** @var UserRepository $repository */
     $repository = $this->entityManager->getRepository(ClassPath::USER);
     return $repository->findByEmail($username);
 }
コード例 #8
0
 public function __construct($host, $port, $proxy_dir, $username = null, $password = null)
 {
     $configuration = new Configuration(array('host' => $host, 'port' => $port, 'proxy_dir' => $proxy_dir, 'username' => $username, 'password' => $password));
     parent::__construct($configuration);
 }
コード例 #9
0
 /**
  * Get list data from database by query
  *
  * @param string $query
  * @return ArrayCollection
  */
 protected function getOneByQuery($query)
 {
     return $this->entityManager->createCypherQuery()->query($query)->getOne();
 }