把资源存放到当前上下文

@param IPoolResource $resource
@return void
321
private static function pushResourceToRequestContext(IPoolResource $resource)
    {
        $poolResources = RequestContext::get('poolResources', []);
        $instance = $resource->getInstance();
        $poolResources[spl_object_hash($instance)] = $resource;
        RequestContext::set('poolResources', $poolResources);
    }
328324
private function setPageHeaders($resource)
    {
        $this->title = $resource->title;
        $this->pageTitle = $resource->category->title;
        $this->description = $resource->title . ' ' . $resource->summary;
        $this->image = ltrim(uploaded_images_url($resource->image), '/');
        $this->addBreadcrumbLink($resource->category->title,
            $this->URLPrefix . $resource->category->url);
        $this->addBreadcrumbLink($resource->title, $resource->url);

        $this->setBanners($resource->image, $resource->title, $resource->summary);
    }
1038682
public function releaseResource(AbstractResourceFile $resource) {
        if (is_null($this->getReleaseDir())) {
            throw new Exception("ERROR: RELEASE DIR IS NULL: " . $resource->getRealPath());
        }
        if (!$this->getReleaseDir()->exists()) {
            $this->getReleaseDir()->mkdirs();
        }
        $release_file = $this->makeReleaseFile($resource);
        $release_dir = $release_file->getAbsoluteFile()->getParentFile();
        if (!$release_dir->exists()) {
            if (!$release_dir->mkdirs()) {
                throw new FileWriteErrorException("The directory '" . $release_dir->getAbsolutePath() . "' create fails.");
            }
        }
        \file_put_contents($release_file->getAbsolutePath(), $resource->getFileContents());
    }
414555
public function addResource(string ...$resource)
    {
        foreach ($resource as $_resource)
        {
            $this->resourceRegistry->save($_resource);
        }
    }
96474
protected function registerResource(ResourceInterface $resource): void
    {
        \assert($this->hasNotBeenAdded($resource));

        $this->addedResources[$resource->getId()][$resource->getType()] = true;
    }
1357770
public function setResource(ResourceInterface $resource) {
		if ($this->type === RelationshipObject::TO_MANY) {
			throw new InputException('can not set a resource on a to-many relationship, use ->addResource()');
		}
		
		$this->resource = $resource;
	}
1283478
public static function fileConfig($resource)
    {
        self::$config = new Config($resource, new ConfigLoader());
        self::$config->load();
        self::$config->configure();
    }
169760
public function resource($name, $resource = null)
    {
        if ($resource) {
            $this->addResource($name, $resource);
        } else {
            return $this->getResource($name);
        }
    }
1177211
public function hasResource($resource)
    {
        if (!isset($this->resourcesCached[$resource])) {
            if (isset($this->resources[$resource])) {
                $this->resourcesCached[$resource] = $this->resources[$resource];
            } else {
                $found = false;
                foreach ($this->resources as $resourceName) {
                    $regex = str_replace(
                        array("\*", "\?"), // wildcard chars
                        array('.*', '.'),   // regexp chars
                        preg_quote($resourceName)
                    );

                    if (preg_match('/^' . $regex . '$/is', $resource)) {
                        $found = true;
                    }
                }

                $this->resourcesCached[$resource] = $found;
            }
        }

        return $this->resourcesCached[$resource];
    }
84832
public function setResource($resource)
    {
        $res = $this->driverInstance->setResource($resource);
        if (!$this->isInstanceOf($res, YamlInterface::class)) {
            throw new YamlException('YamlInterface method setSource() must return YamlInterface object.');
        }

        return $this;
    }
688988
protected function callMigration($resource)
    {
        $migrationName = $this->getMigrationName($resource);

        if ($this->confirm("Do you want me to create a '$migrationName' migration and schema for this resource? [yes|no]"))
        {
            $this->call('generate:migration', [
                'migrationName' => $migrationName,
                '--fields' => $this->option('fields')
            ]);
        }
    }
250007
public function setResource($resource)
    {
        $this->resource = $resource;

        if (null !== $resource) {
            $this->stopPropagation();
        }

        return $this;
    }
1260839
public function unpublishResource(PersistentResource $resource)
    {
        $resources = $this->resourceRepository->findSimilarResources($resource);
        if (count($resources) > 1) {
            $message = sprintf('Did not unpublish resource %s with SHA1 hash %s because it is used by other Resource objects.', $resource->getFilename(), $resource->getSha1());
            $this->messageCollector->append($message, Error::SEVERITY_NOTICE);
            return;
        }
        $this->unpublishFile($this->getRelativePublicationPathAndFilename($resource));
    }
470728
private function _uploadAssetFileFromResource($url, $resource)
    {
        $blockSize = self::MAX_BLOCK_SIZE;
        $blockIds = [];

        $blockContent = fread($resource, $blockSize);
        if (feof($resource)) {
            $this->_uploadAssetFileSingle($url, $blockContent);

            return;
        }

        $blockId = $this->_generateBlockId(count($blockIds));

        $blockIds[] = $blockId;
        $this->_uploadBlock($url, $blockId, $blockContent);

        while (!feof($resource)) {
            $blockContent = fread($resource, $blockSize);

            $blockId = $this->_generateBlockId(count($blockIds));

            $blockIds[] = $blockId;
            $this->_uploadBlock($url, $blockId, $blockContent);
        }

        $this->_commitBlocks($url, $blockIds);
    }
309838
public function removeResource(ResourceNode $resource)
    {
        if ($this->isLinkedToResource($resource)) {
            $this->resources->removeElement($resource);
            --$this->resourceCount;
        }
    }
514966
public function deleteResource(PersistentResource $resource)
    {
        try {
            $this->getCurrentBucket()->object($this->keyPrefix . $resource->getSha1())->delete();
        } catch (NotFoundException $e) {
            return true;
        }

        return true;
    }
193593
public function addResource(ResourceInterface $resource) {
		if ($this->type === RelationshipObject::TO_ONE) {
			throw new InputException('can not add a resource to a to-one relationship, use ->setResource()');
		}
		
		$this->resources[] = $resource;
	}