/**
  * @param array $expected
  * @return NavigationResult
  */
 protected function prepareExpectedResult(array $expected)
 {
     $expectedResult = new NavigationResult();
     $expectedResult->setId($expected['id']);
     $expectedResult->setAvailable($expected['iaAvailable']);
     $expectedResult->setAccessible($expected['iaAccessible']);
     return $expectedResult;
 }
 /**
  * @param object $entity
  * @param string $resultType
  * @param string $scope
  * @return NavigationResult
  */
 protected function getResult($entity, $resultType, $scope = EntityPaginationManager::VIEW_SCOPE)
 {
     $result = new NavigationResult();
     if ($this->storage->isEnvironmentValid() && $this->storage->isEntityInStorage($entity, $scope)) {
         $entityName = ClassUtils::getClass($entity);
         if ($this->isIdentifierMatched($entity, $resultType, $scope)) {
             do {
                 $identifier = $this->getProcessedIdentifier($entity, $resultType, $scope);
                 if (!$identifier) {
                     break;
                 }
                 $navigationEntity = $this->doctrineHelper->getEntity($entityName, $identifier);
                 $permission = EntityPaginationManager::getPermission($scope);
                 if (!$navigationEntity) {
                     $this->storage->unsetIdentifier($identifier, $entity, $scope);
                     $result->setAvailable(false);
                 } elseif (!$this->securityFacade->isGranted($permission, $navigationEntity)) {
                     $this->storage->unsetIdentifier($identifier, $entity, $scope);
                     $result->setAccessible(false);
                 }
             } while (!$navigationEntity || !$this->securityFacade->isGranted($permission, $navigationEntity));
             $result->setId($identifier);
         }
     }
     return $result;
 }