Adds a resource for this configuration.

@param ResourceInterface $resource A resource instance

@return $this
183759
public function addResource(ResourceInterface $resource)
    {
        if (!$this->trackResources) {
            return $this;
        }

        $this->resources[] = $resource;

        return $this;
    }
756753
public static function fromResource(ResourceInterface $resource, $path)
	{
		if ($resource instanceof FileResourceInterface) {
			return $resource;
		}
		file_put_contents($path, $resource->getStream());
		$attr = [
			'mimetype' => $resource->getMimetype(),
			'lastmodified' => $resource->getLastModified(),
			'filename' => $resource->getFilename()
		];
		return new FileResource($path, $attr);
	}
502825
public function applyEntity(Resource $resource, EntityInterface $entity)
    {
        $this->validateResourceTypes($resource->getEntityType(), $entity->getType());
        $document->pushData($entity);
        return $this;
    }
825829
protected function insertResources(array $resources)
    {
        foreach ($resources as $resource) {
            if (null === $resource->getParent()) {
                $this->addResource($resource);
            } else {
                $parent = $resource->getParent()->getResourceId();
                $this->addResource($resource, $parent);
            }
        }

        return $this;
    }
931916
public function linkResource(ResourceNode $resource)
    {
        if (!$this->isLinkedToResource($resource)) {
            $this->resources->add($resource);
            ++$this->resourceCount;
        }
    }
1121120
public function addResource(AbstractResourceFile $resource) {
        if (!parent::offsetExists($resource->getMemberId())) {
            parent::offsetSet($resource->getMemberId(), $resource);
        }
    }
377680
public function set(ResourceInterface $resource): ResourceCollectionInterface
    {
        $this->collection[$this->buildArrayKey($resource->type(), $resource->id())] = $resource;

        return $this;
    }
1195216
public function setResource(ImageResourceInterface $resource)
    {
        $this->resource = $resource;

        if ($this->resource instanceof ImageFilterableInterface) {
            $this->filterResolver = new FilterResolver($this->resource->loadFilters());
        }
    }
853866
public function add(ResourceInterface $resource): void
    {
        if (!$resource instanceof $this->interface) {
            throw new UnexpectedTypeException($resource, $this->interface);
        }

        if (in_array($resource, $this->findAll())) {
            throw new ExistingResourceException();
        }

        $this->arrayObject->append($resource);
    }
638968
protected function serialize(ResourceInterface $resource, $data)
    {
        // Get the serializer from the resource, or use the default.
        $serializer = $resource->getSerializer() ?? $this->getSerializer();
        
        if ($serializer instanceof SerializerInterface) {
            if ($resource instanceof Collection) {
                if ($data === null) {
                    return $serializer->nullCollection();
                }
                $data = $serializer->collection($resource->getResourceKey(), $data);
                if ($resource->hasPaginator()) {
                    $data = array_merge($data, $serializer->paginator($resource->getPaginator()));
                }
            } elseif ($resource instanceof Item) {
                if ($data === null) {
                    return $serializer->nullItem();
                }
                $data = $serializer->item($resource->getResourceKey(), $data);
            }
        } elseif (\is_callable($serializer)) {
            // Serialize via a callable/closure
            $data = $serializer($resource->getResourceKey(), $data);
        }
       
        return $data;
    }
1047045
public function addSecondaryResource(ResourceNode $resource)
    {
        if (!$this->secondaryResources->contains($resource)) {
            $this->secondaryResources->add($resource);
        }

        return $this;
    }
72703
public function createTrackedObject(ResourceInterface $resource)
    {
        $tracked = new TrackedObject();
        $tracked->setResource($resource);
        $tracked->setChecksum($resource->getChecksum());

        if(is_null($tracked->getID())){
            $tracked->setID(PathUtil::createPathID($resource->getResource()));
        }
        return $tracked;
    }
153831
protected function createParsedResource($resource): ResourceInterface
    {
        \assert(
            $this->schemaContainer->hasSchema($resource),
            'No Schema found for resource `' . \get_class($resource) . '`.'
        );

        return $this->factory->createParsedResource(
            $this->position,
            $this->schemaContainer,
            $resource
        );
    }
3876
public function addResourceProvider(ResourceProvider $provider)
    {
        $this->loaded && $this->loaded->__invoke();

        $this->resourceProviders[] = $provider;

        return $this;
    }
1237959
public function add(ProviderInterface $provider)
    {
        $container = $this->container;

        $this->container = $provider->register($container);

        $this->providers[] = (string) get_class($provider);

        return $this;
    }
681442
public function setResourceType(ResourceType $resourceType)
    {
        if ($this->resourceType instanceof ResourceType) {
            $this->resourceType->removeMaskDecoder($this);
        }

        $this->resourceType = $resourceType;
        $this->resourceType->addMaskDecoder($this);

        return $this;
    }
1306084
protected function addHelpResource($key, $resource)
    {
        if (isset($this->helpResources[$key])) {
            throw new \LogicException('The resource you are trying to add is already set.');
        }

        if (false === is_object(($resource))) {
            throw new \InvalidArgumentException(sprintf('The resource "%s" you are trying to add is not an object. addHelpResource() accepts only objects. Use addHelpValue() to store other kind of values.', $key));
        }

        $this->helpResources[$key] = $resource;

        return $this;
    }