/** * 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()); } }
/** * 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()); } }