getResource
Return the requested resource
Can be used to return resources dynamically at run-time

@param string $resourceId resourceId

@return array|null
559050
public function getResource($resourceId)
    {
        if (isset($this->resources[$resourceId])) {
            return $this->resources[$resourceId];
        }

        $dynamicResource = $this->dynamicResourceMapper($resourceId);

        if (!empty($dynamicResource)) {
            return $dynamicResource;
        }

        return null;
    }
308324
public function getResourceByUri($uri)
    {
        // get rid of everything after the ?
        $uri = \strtok($uri, '?');

        $resources = $this->getResourcesAsArray($this->resources);
        foreach ($resources as $resource) {
            \assert($resource instanceof Resource);
            if ($resource->matchesUri($uri)) {
                return $resource;
            }
        }

        throw new ResourceNotFoundException($uri);
    }
504513
public function get($paymentId, array $parameters = [])
    {
        if (empty($paymentId) || strpos($paymentId, self::RESOURCE_ID_PREFIX) !== 0) {
            throw new ApiException("Invalid payment ID: '{$paymentId}'. A payment ID should start with '".self::RESOURCE_ID_PREFIX."'.");
        }

        return parent::rest_read($paymentId, $parameters);
    }
710718
public function getItem(string $resourceClass, $id, string $operationName = null, array $context = [])
    {
        /** @var ObjectManager $manager */
        $manager = $this->managerRegistry->getManagerForClass($resourceClass);

        if (!\is_array($id) && !($context[IdentifierConverterInterface::HAS_IDENTIFIER_CONVERTER] ?? false)) {
            $id = $this->normalizeIdentifiers($id, $manager, $resourceClass);
        }

        $fetchData = $context['fetch_data'] ?? true;
        if (!$fetchData && $manager instanceof EntityManagerInterface) {
            return $manager->getReference($resourceClass, $id);
        }

        $repository = $manager->getRepository($resourceClass);
        if (!method_exists($repository, 'createQueryBuilder')) {
            throw new RuntimeException('The repository class must have a "createQueryBuilder" method.');
        }

        $queryBuilder = $repository->createQueryBuilder('o');
        $queryNameGenerator = new QueryNameGenerator();
        $doctrineClassMetadata = $manager->getClassMetadata($resourceClass);

        $this->addWhereForIdentifiers((array) $id, $queryBuilder, $doctrineClassMetadata);

        foreach ($this->itemExtensions as $extension) {
            $extension->applyToItem($queryBuilder, $queryNameGenerator, $resourceClass, $id, $operationName, $context);

            if ($extension instanceof QueryResultItemExtensionInterface && $extension->supportsResult($resourceClass, $operationName, $context)) {
                return $extension->getResult($queryBuilder, $resourceClass, $operationName, $context);
            }
        }

        return $queryBuilder->getQuery()->getOneOrNullResult();
    }
292222
public function getFollowerResource($userId, $resourceId, $resourceClass)
    {
        $followerResource = $this->getFollowerResourceRepository()->findOneBy(
            [
                'followerId' => $userId,
                'hash' => $this->getHash($resourceId, $resourceClass),
            ]
        );

        return $followerResource;
    }
135409
protected static function getResource( $hash )
    {
        static $resource = null;
        if(is_null($resource)) {
            $resource = sem_get($hash);
        }
        return $resource;
    }
483472
public function getResource($name)
    {
        foreach ($this->_resources as $resource) {
            if ($resource->getName() == $name) {
                return $resource;
            }
        }
    }
1269947
protected function convertResourceToObject($resource, $resourceId = null)
    {
        return ! $resource instanceof Resource ? new SimpleResource($resource, $resourceId) : $resource;
    }
306504
public function get($id)
    {
        foreach ($this->data as $container) {
            if ($container->getId() === $id) {
                return $container;
            }
        }

        throw new ResourceNotFoundException(sprintf('Container "%s" not found.', $id));
    }
1186950
public function isSitesResourceId($resourceId)
    {
        $needle = ResourceProvider::RESOURCE_SITES . '.';
        $length = strlen($needle);

        return (substr($resourceId, 0, $length) === $needle);
    }
334081
protected function dynamicResourceMapper($resourceId)
    {
        // Page Resource Mapper
        $resource = $this->pageResourceMapper($resourceId);

        if (!empty($resource)) {
            return $resource;
        }

        $resource = $this->siteResourceMapper($resourceId);

        if (!empty($resource)) {
            return $resource;
        }

        return null;
    }
55213
public function buildPagesResourceId(
        $siteId
    ) {
        return $this->resourceName->get(
            ResourceName::RESOURCE_SITES,
            $siteId,
            ResourceName::RESOURCE_PAGES
        );
    }
1086311
private function getResourceFromNode(ResourceNode $resourceNode)
    {
        /** @var AbstractResource $resource */
        $resource = $this->om
            ->getRepository($resourceNode->getClass())
            ->findOneBy(['resourceNode' => $resourceNode]);

        return $resource;
    }
425166
@Override
	@Transactional
	public String getResource(String id)
	{
		final TemplateCall call = templater.template("resource_template");

		final ResourceTemplateEntity entity = resourceProvisionService.getOrCreateTemplate(id);

		if (entity == null)
			throw new RestException(404, "No such resource with id: " + id);

		call.set("entity", entity);
		call.set("nonce", nonceStore.getValue());

		return call.process();
	}
410307
@Override
    public byte[] read(String resourceId) {
        File f = this.cachedResources.get(resourceId);
        if (Objects.isNull(f)) {
            return null;
        }
        try {
			return Files.readAllBytes(f.toPath());
		} catch (IOException exception) {
			throw new MonetaryException("An error on retrieve the resource id: " + resourceId, exception);
		}
    }
444302
public function getResource($recordId)
    {
        $collection = $this->getThisCollection();
        $repository = $this->getRepository();
        $returnedResource = null;

        list($returnedResource, $resultSet) = $this->loadResource($recordId, $collection, $repository);

        if($returnedResource) {
            $relationships = $collection->getRelationships();

            if (count($relationships)) {
                foreach ($relationships as $tableReference => $field) {
                    /** @var ForestField $field */
                    $foreignCollection = $this->findCollection($tableReference);

                    $relationship = new ForestRelationship;
                    $relationship->setType($foreignCollection->getName());
                    $relationship->setEntityClassName($foreignCollection->getEntityClassName());
                    $relationship->setFieldName($field->getField());
                    $relationship->setIdentifier($foreignCollection->getIdentifier());
                    if ($field->isTypeToOne()) {
                        $relationship->setId($resultSet[$field->getForeignKey()]);
                    }
                        $returnedResource->addRelationship($relationship);
                }

                foreach($returnedResource->getRelationships() as $relationship) {
                    if($relationship->getId()) {
                        $foreignCollection = $this->findCollection($relationship->getType());
                        $foreignRepository = $this->getEntityManager()->getRepository($relationship->getEntityClassName());
                        list($resourceToInclude, $rs) = $this->loadResource(
                            $relationship->getId(), 
                            $foreignCollection, 
                            $foreignRepository
                        );
                        
                        if($resourceToInclude) {
                            $resourceToInclude->setType($relationship->getType());
                            $returnedResource->includeResource($resourceToInclude);
                        }
                    }
                }
            }
        }

        return $returnedResource->formatJsonApi();
    }
199475
public function getResource()
    {
        if ($this->_resource === null) {
            $this->_resource = $this->toResource();
        }
        return $this->_resource;
    }