@param ResourceInterface $resource

@return array
337640
protected function breakup(ResourceInterface $resource)
    {
        $originalFile = $resource->getFile();
        $baseFile = $originalFile->getPathname();

        $this->reader->setResources(new ResourceCollection([$resource]));

        $partCount = 0;
        $started = false;
        while ($this->reader->valid()) {
            if ($this->reader->key() % $this->size === 0) {
                if ($this->reader->key() > 0) {
                    $this->endPart();
                }

                $file = sprintf('%s.part%s', $baseFile, ++$partCount);
                $this->startPart($file);
                $started = true;
            }

            $this->writer->write($this->reader->current());
            $this->writer->flush();

            $this->reader->next();
        }
        
        if ($started) {
            $this->endPart();
        }

        return $this->getPartFiles($resource);
    }
704205
protected function buildResources($data, SerializerInterface $serializer)
    {
        $resources = [];

        foreach ($data as $resource) {
            if (! ($resource instanceof Resource)) {
                $resource = new Resource($resource, $serializer);
            }

            $resources[] = $resource;
        }

        return $resources;
    }
478148
public static function fromResources(ResourceInterface ...$resources) {
		$collectionDocument = new self();
		
		foreach ($resources as $resource) {
			$collectionDocument->addResource($resource);
		}
		
		return $collectionDocument;
	}
733936
public function addResource(ResourceInterface $resource, $loader)
    {
        $this->resources[$loader][] = $resource;
        $this->loaded = false;
    }
31314
public static function toArray($resource) {
		if (self::isArray($resource)) {
			return $resource;

		} else if (self::isObject($resource)) {
			return self::buildArray($resource);

		} else if (self::isJson($resource)) {
			return json_decode($resource, true);

		} else if ($ser = self::isSerialized($resource)) {
			return self::toArray($ser);

		} else if ($xml = self::isXml($resource)) {
			return self::xmlToArray($xml);
		}

		return $resource;
	}
1308167
protected function getAvailableTypes(string $resource)
    {
        $cached = $this->cache['available_types'][$resource] ?? null;
        if ($cached !== null) {
            return $cached;
        }

        $types = $this->resources[$resource]['handlers']['GET'] ?? [];
        $types = (is_array($types))
            ? array_filter(array_replace($this->default_content_type, $types))
            : [];

        $this->cache['available_types'][$resource] = $types;
        return $types;
    }
385139
public function addResource(ResourceInterface $resource, $name = null) {
		if ($name === null) {
			$this->resources[] = $resource;
			
			return $this;
		}
		
		$this->resources[$name] = $resource;
		
		return $this;
	}
526725
protected function hasNotBeenAdded(ResourceInterface $resource): bool
    {
        return isset($this->addedResources[$resource->getId()][$resource->getType()]) === false;
    }
215228
protected function executeOnMulitpleResources(array $resources): array
    {
        $results = [];

        foreach ($resources as $resource) {
            $results[$resource->name()] = $this->executeOn($resource);
        }

        return $results;
    }
993260
private function createControllerDefinition(ResourceInterface $resource)
    {
        $definition = new Definition($resource->getController(), [
            new Reference('lug.resource.'.$resource->getName()),
        ]);

        $definition->addMethodCall('setContainer', [new Reference('service_container')]);
        $definition->addTag('lug.controller', ['resource' => $resource->getName()]);

        return $definition;
    }
764866
protected static function getSessionSettings(ContainerInterface $container): array
    {
        /** @var SettingsProviderInterface $provider */
        $provider = $container->get(SettingsProviderInterface::class);
        $settings = $provider->get(C::class);

        return $settings;
    }
410795
public function setResource(ResourceInterface $resource = null)
    {
        $this->resource = $resource;

        // Clear urls
        $this->urls = null;

        return $this;
    }
1230022
public function getRedirectParameters($resource = null)
    {
        $redirect = $this->parameters->get('redirect');

        if ($this->areParametersIntentionallyEmptyArray($redirect)) {
            return [];
        }

        if (!is_array($redirect)) {
            $redirect = ['parameters' => []];
        }

        $parameters = $redirect['parameters'] ?? [];
        $parameters = $this->addExtraRedirectParameters($parameters);

        if (null !== $resource) {
            $parameters = $this->parseResourceValues($parameters, $resource);
        }

        return $parameters;
    }
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;
    }
450649
protected function loadResource($resource, $required)
    {
        foreach ($this->loaders as $loader) {
            if (!$loader->supports($resource)) {
                continue;
            }

            try {
                return $loader->load($resource);
            } catch (ResourceNotFoundException $e) {
                if ($required) {
                    throw $e;
                }

                return [];
            }
        }

        throw new ResourceException(sprintf('There is no configuration loader available to load the resource "%s"', $resource));
    }
292423
public function removeElement(ResourceInterface $resource): ResourceCollectionInterface
    {
        $this->remove($resource->type(), $resource->id());

        return $this;
    }
1113455
private function parseResource(ResourceInterface $resource): iterable
    {
        $seenBefore = isset($this->resourcesTracker[$resource->getId()][$resource->getType()]);

        // top level resources should be yielded in any case as it could be an array of the resources
        // for deeper levels it's not needed as they go to `included` section and it must have no more
        // than one instance of the same resource.

        if ($seenBefore === false || $resource->getPosition()->getLevel() <= ParserInterface::ROOT_LEVEL) {
            yield $resource;
        }

        // parse relationships only for resources not seen before (prevents infinite loop for circular references)
        if ($seenBefore === false) {
            // remember by id and type
            $this->resourcesTracker[$resource->getId()][$resource->getType()] = true;

            foreach ($resource->getRelationships() as $name => $relationship) {
                \assert(\is_string($name));
                \assert($relationship instanceof RelationshipInterface);

                $isShouldParse = $this->isPathRequested($relationship->getPosition()->getPath());

                if ($isShouldParse === true && $relationship->hasData() === true) {
                    $relData = $relationship->getData();
                    if ($relData->isResource() === true) {
                        yield from $this->parseResource($relData->getResource());

                        continue;
                    } elseif ($relData->isCollection() === true) {
                        foreach ($relData->getResources() as $relResource) {
                            \assert($relResource instanceof ResourceInterface ||
                                $relResource instanceof IdentifierInterface);
                            if ($relResource instanceof ResourceInterface) {
                                yield from $this->parseResource($relResource);
                            }
                        }

                        continue;
                    }

                    \assert($relData->isNull() || $relData->isIdentifier());
                }
            }
        }
    }