Respond collection of resources.

@param IlluminateCollection|array $collection
@param null $transformer
@param string|null $resourceKey
@return \Illuminate\Contracts\Http\Response
325828
public function withCollection($collection, $transformer = null, $resourceKey = null)
    {
        return $this->respond(
            $this->getCollection($collection, $transformer, $resourceKey)
        );
    }
757820
public function getResources(
        ResourceTransformer $resourceTransformer,
        ResourceDefinition $resourceDefinition,
        Context $context,
        $request = null
    ) {
        if (!$this->hasApplicableContentType()) {
            return null;
        }

        $rawContent = $this->getRawContent();
        $content = json_decode($rawContent, true);

        if (!$content) {
            throw new \InvalidArgumentException("Could not decode body: " . $rawContent);
        }

        $resourceCollection = $resourceTransformer->getResourceFactory()->createResourceCollection();

        if (isset($content[ResourceTransformer::RELATIONSHIP_ITEMS])) {
            // This is a list of items
            foreach ($content[ResourceTransformer::RELATIONSHIP_ITEMS] as $item) {
                $resource = $resourceTransformer->fromArray(
                    $resourceDefinition,
                    $item,
                    $context
                );
                $resourceCollection->add($resource);
            }
        } else {
            $resource = $resourceTransformer->fromArray(
                $resourceDefinition,
                $content,
                $context
            );
            $resourceCollection->add($resource);
        }

        return $resourceCollection;
    }
424699
public function collection(
        ResourceManager $resourceManager,
        ApiRequest $request,
        int $version,
        string $resource
    )
    {
        $resourceManager->version($version);

        /** @var HandlesCollectionRequest $handler */
        $handler = $this->initializeHandler($resourceManager, $resource, $request, HandlesCollectionRequest::class);

        $parameters = $request->asParameters();

        $repository = $this->initializeRepository($resourceManager, $resource, $parameters);

        $result = $handler->index($repository, $parameters);

        $document = $this->makeDocumentFromCollection($resourceManager, $resource, $result, $parameters, $handler);

        return $this->respond($document);
    }
1294328
public function transformEntity($entity, $transformer = null, SerializerAbstract $serializer = null): array
	{
		$transformer = $transformer ?: $this->getTransformerFromClassProperty();

		$results = $this->transform()->resourceWith($entity, $transformer)->usingPaginatorIfPaged();

		if ($serializer) {
			return $results->serialize($serializer);
		}

		return $results->serialize();
	}
1211273
function Collection(response, dispatcher, dispatchOptions) {
  if (!Collection.isCollectionResponse(response)) {
    throw new Error(
        'Cannot create Collection from response that does not have resources');
  }

  this.data = response.data;
  this._response = response;
  this._dispatcher = dispatcher;
  this._dispatchOptions = dispatchOptions;
}
270510
public function collection($items, $transformer, $model_name = '', $meta = [])
    {
        $resource = new Collection($items, $transformer, $model_name);

        $resource->setMeta($meta);
        if ($items instanceof LengthAwarePaginator) {
            $resource->setPaginator(new IlluminatePaginatorAdapter($items));
        }

        return $this->manager->createData($resource)->toArray();
    }
1214903
public function makeCollection(ArrayAccess $collection, array $meta = [], TransformerAbstract $transformer = null)
    {
        if ($this->isPaged($collection)) {
            $paginator = $collection;
            $collection = $collection->getIterator();
            $resource = $this->makeFractalCollection($collection, $this->getTransformer($transformer));
            $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
        } else {
            $resource = $this->makeFractalCollection($collection, $this->getTransformer($transformer));
        }

        $resource = $this->addFractalMeta($resource, $meta);

        $fractal = $this->getFractalFactory()->createData($resource)->toArray();

        return $fractal;
    }
123340
public function itemWith($entity, $transformer, $key = null): TransformationFactory
	{
		$this->entity      = $entity;
		$this->transformer = $transformer;
		$this->resource    = new Item($entity, $transformer, $key);

		return $this;
	}
753137
public function hasPropertyInput(
        ResourceTransformer $transformer,
        &$input,
        Field $field,
        Context $context
    ): bool {
        return array_key_exists($field->getDisplayName(), $input);
    }
446687
protected function fetchDataProperty($resource, TransformerInterface $transformer)
    {
        if (!$transformer->getProperty()) {
            return $resource;
        }

        if (is_array($resource) && array_key_exists($transformer->getProperty(), $resource)) {
            return $resource[$transformer->getProperty()];
        }

        if (method_exists($resource, $transformer->getProperty())) {
            return $resource->{$transformer->getProperty()}();
        }

        if ($transformer->getMappingOptions()['required']) {
            throw new UndefinedItemPropertyException(sprintf(
                'Undefined property "%s"', $transformer->getProperty()
            ));
        } else {
            return null;
        }
    }
432741
public function collection($resourceKey, array $data, $includeAttributes = true)
    {
        $resources = [];

        foreach ($data as $resource) {

            /**
             * Add option to override resource key with data.
             */
            if (is_array($resource) && array_key_exists('_resource_key', $resource)) {
                $resourceKey = $resource['_resource_key'];
                unset($resource['_resource_key']);
            }

            $resources[] = $this->item($resourceKey, $resource, $includeAttributes)['data'];
        }

        return ['data' => $resources];
    }
784214
protected function primitive($data, $transformer = null, $resourceKey = null)
    {
        return new Primitive($data, $transformer, $resourceKey);
    }
926887
public function publishCollection(CollectionInterface $collection, callable $callback = null)
    {
        if (!$this->configurationService->getCurrentConfigurationByPath('resourceProxy')) {
            return parent::publishCollection($collection, $callback);
        }

        /**
         * @var ProxyAwareWritableFileSystemStorage $storage
         */
        $storage = $collection->getStorage();
        if (!$storage instanceof ProxyAwareWritableFileSystemStorage) {
            return parent::publishCollection($collection, $callback);
        }

        foreach ($collection->getObjects($callback) as $object) {
            /** @var StorageObject $object */
            if ($storage->resourceIsPresentInStorage($object) === false) {
                // this storage ignores resources that are not yet in the filesystem as they
                // are optimistically created during read operations
                continue;
            }
            $sourceStream = $object->getStream();
            $this->publishFile($sourceStream, $this->getRelativePublicationPathAndFilename($object));
            fclose($sourceStream);
        }
    }
255334
public function withCollection($data, $transformer, $resourceKey = null, Cursor $cursor = null, $meta = [], array $headers = [])
    {
        $resource = new Collection($data, $transformer, $resourceKey);

        foreach ($meta as $metaKey => $metaValue) {
            $resource->setMetaValue($metaKey, $metaValue);
        }

        if (!is_null($cursor)) {
            $resource->setCursor($cursor);
        }

        $rootScope = $this->manager->createData($resource);

        return $this->withArray($rootScope->toArray(), $headers);
    }
580847
public void execute(TransformerImpl transformer) throws TransformerException
  {

    transformer.pushCurrentTemplateRuleIsNull(true);    
    try
    {
      transformSelectedNodes(transformer);
    }
    finally
    {
      transformer.popCurrentTemplateRuleIsNull();
    }
  }
1246382
public function loadTransformations(Transformer $transformer)
    {
        /** @var ConfigurationHelper $configurationHelper */
        $configurationHelper = $this->getHelper('phpdocumentor_configuration');

        $received = array();
        $transformations = $configurationHelper->getConfigValueFromPath('transformations/transformations');
        if (is_array($transformations)) {
            if (isset($transformations['writer'])) {
                $received[] = $this->createTransformation($transformations);
            } else {
                foreach ($transformations as $transformation) {
                    if (is_array($transformation)) {
                        $received[] = $this->createTransformation($transformations);
                    }
                }
            }
        }

        $this->appendReceivedTransformations($transformer, $received);
    }
780556
public function collection($data, $transformer, $resourceKey = null, Cursor $cursor = null, $meta = [])
    {
        if (!is_object($transformer) && !is_callable($transformer)) {
            $transformer = $this->di->getShared($transformer);
        }

        $resource = new Collection($data, $transformer, $resourceKey);

        foreach ($meta as $metaKey => $metaValue) {
            $resource->setMetaValue($metaKey, $metaValue);
        }

        if (!is_null($cursor)) {
            $resource->setCursor($cursor);
        }

        $rootScope = $this->getManager()->createData($resource);

        return $rootScope->toArray();
    }