把资源从当前上下文删除
@param IPoolResource $resource
@return void
511194
private static function removeResourceFromRequestContext(IPoolResource $resource)
    {
        $poolResources = RequestContext::get('poolResources', []);
        $instance = $resource->getInstance();
        $key = spl_object_hash($instance);
        if(isset($poolResources[$key]))
        {
            unset($poolResources[$key]);
            RequestContext::set('poolResources', $poolResources);
        }

        $name = 'poolResource.' . $resource->getPool()->getName();
        $poolResource = RequestContext::get($name);
        if($poolResource === $resource)
        {
            RequestContext::set($name, null);
        }
    }
627256
public function setResource(PersistentResource $resource)
    {
        $this->lastModified = new \DateTime();
        $this->resource = $resource;
        $this->refresh();
    }
1281689
protected function removeImageFromStorage (HCResources $resource)
    {
        $path = $this->uploadPath . $resource->id;

        if (Storage::has ($path)) {
            Storage::delete ($path);
        }
    }
1304407
public function parse($resource, $output)
    {
        printf('file %s' . PHP_EOL, $resource);

        $pathinfo = pathinfo($resource);
        $extension = $pathinfo['extension'];

        $this->environment->setSourceFile($resource);

        $parser = $this->configuration->getParserForFileExtension($extension);

        if (!$parser instanceof ParserInterface) {
            throw new \Exception('No parser found. Have you initialized any plugins?');
        }

        if ($parser instanceof HasEnvironmentInterface) {
            $parser->setEnvironment($this->environment);
        }

        $content = $parser->parse($resource);
        $output  = $parser->getOutputFilename($output);
        file_put_contents($output, $content);
    }
530411
protected function setError($resource)
    {
        if (is_string($resource)) {
            $this->getDriver()->setError(
                $resource, -1
            );
        } else {
            $this->getDriver()->setError(
                $this->realError($resource),
                $this->realErrorCode($resource)
            );
        }
    }
1119712
public function delete($resource)
    {
        $event = $this->createResourceEvent($resource);
        $this->dispatcher->dispatch($this->config->getEventName('pre_delete'), $event);

        if (!$event->isPropagationStopped()) {
            $this->removeResource($event);

            $this->dispatcher->dispatch($this->config->getEventName('post_delete'), $event);
        }

        return $event;
    }
169760
public function resource($name, $resource = null)
    {
        if ($resource) {
            $this->addResource($name, $resource);
        } else {
            return $this->getResource($name);
        }
    }
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;
	}
728072
public function load($resource, $type = null): void
    {
        $path = $this->locator->locate($resource);

        /** @var mixed[]|null $content */
        $content = $this->loadFile($path);
        $this->container->fileExists($path);

        // empty file
        if ($content === null) {
            return;
        }

        // imports: $this->parseImports($content, $path);
        $this->privatesCaller->callPrivateMethod($this, 'parseImports', $content, $path);

        // parameters
        if (isset($content[self::PARAMETERS_KEY])) {
            $this->ensureParametersIsArray($content, $path);

            foreach ($content[self::PARAMETERS_KEY] as $key => $value) {
                // $this->resolveServices($value, $path, true),
                $resolvedValue = $this->privatesCaller->callPrivateMethod(
                    $this,
                    'resolveServices',
                    $value,
                    $path,
                    true
                );

                // only this section is different
                if ($this->container->hasParameter($key)) {
                    $newValue = $this->parametersMerger->merge(
                        $resolvedValue,
                        $this->container->getParameter($key)
                    );

                    $this->container->setParameter($key, $newValue);
                } else {
                    $this->container->setParameter($key, $resolvedValue);
                }
            }
        }

        // extensions: $this->loadFromExtensions($content);
        $this->privatesCaller->callPrivateMethod($this, 'loadFromExtensions', $content);

        /**
         * services - not accessible, private parent properties, luckily not needed
         * - $this->anonymousServicesCount = 0;
         * - $this->anonymousServicesSuffix = ContainerBuilder::hash($path);
         */
        $this->setCurrentDir(dirname($path));
        try {
            // $this->parseDefinitions($content, $path);
            $this->privatesCaller->callPrivateMethod($this, 'parseDefinitions', $content, $path);
        } finally {
            $this->instanceof = [];
        }
    }
1033194
public function registerResource(Resources\Resource $resource)
  {
      $this->resources[strtolower($resource->getName())] = $resource;
  }
404109
public function setConnectionResource($resource): void
    {
        $this->connection = $resource;

        $this->setDateStyle(pg_parameter_status($resource, 'DateStyle'));
    }
1184029
protected function storeVersion(PuliResource $resource)
    {
        if (null !== $this->changeStream) {
            $this->changeStream->append($resource);
        }
    }
1319377
function addResource($name, $resource)
    {
        $name = (string) $name;

        if (array_key_exists($name, $this->_t_loader_map_resource_MapRes))
            throw new \Exception(sprintf(
                'Resource Map (%s) already exists in map.'
                , $name
            ));

        $this->_t_loader_map_resource_MapRes[$name] = $resource;
        return $this;
    }
467514
public void copyResource(String filename, String resource) throws IOException {
    write(filename, IOUtils.toByteArray(getClass().getResource(resource)));
  }
183759
public function addResource(ResourceInterface $resource)
    {
        if (!$this->trackResources) {
            return $this;
        }

        $this->resources[] = $resource;

        return $this;
    }
190249
public function update(Resource $resource)
    {
        $data = $resource->toArray();

        /** @var ClientEntity $client */
        $client = $this->getRepository()->findOneBy(array('id' => $data['id']));
        if (!$client) {
            $errorMessage = $this->translator->trans('error.client_not_found', array('%id%' => $data['id']));
            throw new NotFoundHttpException($errorMessage);
        }

        $client->setRedirectUris($data['redirectUris']);
        $client->setAllowedGrantTypes($data['grants']);

        $this->entityManager->persist($client);
        $this->entityManager->flush();
    }
685258
protected function addResourceArray(array $resource): void
    {
        foreach ($resource as $locale => $value) {
            if ($locale === '@metadata') {
                $this->parseMetadata($value);
                continue;
            }
            $this->addSubresource($value, $locale);
        }
    }