예제 #1
0
 /**
  * Returns the node matching the given ID
  *
  * @param int $nodeId ID of the resource to locate
  *
  * @return Node
  * @throws NotFoundServiceException
  */
 public function getResourceFromId($nodeId)
 {
     try {
         $node = $this->environment->getResourceFromId($nodeId);
         // Making extra sure that we can actually do something with the file
         if (!$node->getMimetype() || !$node->isReadable()) {
             throw new NotFoundServiceException("Can't access the file");
         }
         return $node;
     } catch (\Exception $exception) {
         throw new NotFoundServiceException($exception->getMessage());
     }
 }
예제 #2
0
 /**
  * Returns the node matching the given ID
  *
  * @param int $nodeId ID of the resource to locate
  *
  * @return Node|null
  *
  * @throws NotFoundServiceException
  */
 public function getResourceFromId($nodeId)
 {
     try {
         $node = $this->environment->getResourceFromId($nodeId);
         // Making extra sure that we can actually do something with the file
         if ($node->getMimetype() && $node->isReadable()) {
             return $node;
         } else {
             $this->logAndThrowNotFound("Can't access the file");
         }
     } catch (\Exception $exception) {
         $this->logAndThrowNotFound($exception->getMessage());
     }
 }