Transforms a collection into an array.

@return mixed An array of entities

@throws TransformationFailedException
960060
public function transform($collection)
    {
        if (null === $collection) {
            return [];
        }

        // For cases when the collection getter returns $collection->toArray()
        // in order to prevent modifications of the returned collection
        if (\is_array($collection)) {
            return $collection;
        }

        if (!$collection instanceof Collection) {
            throw new TransformationFailedException('Expected a Doctrine\Common\Collections\Collection object.');
        }

        return $collection->toArray();
    }
352453
public function toArray()
    {
        $data = $this->getAttributes();

        if (!$this->hasId()) {
            unset($data[$this->uniqueIdField]);
        } else {
            $data[$this->uniqueIdField] = $this->getId();
        }

        if($children = $this->getChildren()){
           $_children = array();
            foreach($children as $child){
               $_children[] = $child->toArray();
           }
            $data["children"] = &$_children;
        }

        return $data;
    }
1076522
public function toArray()
    {
        $properties = $this->properties;

        foreach ($properties as $name => $value) {
            if ($value instanceof Entity) {
                $properties[$name] = $value->toArray();
            }
        }

        return $properties;
    }
667658
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof VersionInfo) {
            throw new TransformationFailedException(
                'Value cannot be transformed because passed value is not an VersionInfo object'
            );
        }

        return ['content_info' => $value->getContentInfo(), 'version_no' => $value->versionNo];
    }
118876
public function reverseTransform($id)
	{
        if (!$id || $id === 'Add' || empty($id))
		{
			return null;
		}

		if (!is_array($id))
		{

			$entity = $this->entityRepository->find($id);
			if (null === $entity)
			{
				throw new TransformationFailedException(
					sprintf(
						'A %s with id "%s" does not exist!',
						$this->entityType,
						$id
					)
				);
			}

			return $entity;
		}

		return $id;
	}
473660
public function getList()
    {
        $result = $this->execute();
        $list = new ArrayCollection;

        //Convert all of them to entities
        foreach ($result as $row)
        {
            $list->add($this->convertValue($row[0]));
        }

        return $list;
    }
203825
public function toArray()
    {
        $data = parent::toArray();

        foreach ($this->getComputedProperties() as $property)
        {
            if ($this->{$property} instanceof ModelEntityInterface) {
                $data[$property] = array_values($this->{$property}->toArray());
            } else {
                $data[$property] = $this->{$property};
            }
        }

        foreach(array_keys($data) as $key)
        {
            if (substr($key, 0, 1) === '_') {
                unset($data[$key]);
            }
        }

        return $data;
    }
158690
public function transform($collection)
    {
        if (null === $collection) {
            return [];
        }

        if (!$collection instanceof Collection) {
            throw new TransformationFailedException(sprintf('Expected a %s object.', Collection::class));
        }

        $values = [];
        foreach ($collection as $field) {
            $values[$field->getId()] = $field;
        }

        return $values;
    }
1021711
public function toSearchableArray(): array
    {
        $entity = $this->getEntityObject();

        if (method_exists($entity, 'toSearchableArray')) {
            return $entity->toSearchableArray($this->toArray());
        }

        return [];
    }
605844
public function saveToAndGetClonedEntities()
    {
        $data = $this->transformFromFormData($this->data);

        $cloned_entities = array();
        foreach ($this->entities as $entity) {
            $entity['entity'] = clone $entity['entity'];
            $cloned_entities[] = $entity;

            if ($entity['entity'] instanceof EntityInterface) {
                $entity['entity']->setFormData($data, $entity['fields']);
            } else {
                $this->entityProcessor->saveToEntity($entity['entity'], $data, $entity['fields']);
            }
        }

        return $cloned_entities;
    }
1240997
public function transform()
    {
        $object = $this->resource;

        $data = $object instanceof Collection || $object instanceof AbstractPaginator
            ? $object->map([$this, 'transformResource'])->toArray()
            : $this->transformResource($object);

        if ($object instanceof AbstractPaginator) {
            $this->withMeta(array_merge(
                $this->getExtra('meta', []), Arr::except($object->toArray(), ['data'])
            ));
        }

        $data = array_filter(compact('data') + $this->extras);
        ksort($data);

        return $data;
    }
801012
public function toArray()
    {
        $this->buildGroupsCollection();

        return parent::toArray() + [
                'stub'             => $this->stubElements,
                'name'             => $this->relationName,
                'label'            => $this->label,
                'groups'           => $this->groups,
                'remove'           => $this->toRemove,
                'newEntitiesCount' => $this->new,
                'limit'            => $this->limit,
            ];
    }
875904
public function reverseTransform($value): ?array
    {
        if (empty($value)) {
            return [];
        }

        if (!is_string($value)) {
            throw new TransformationFailedException('Expected a string.');
        }

        $value = explode(',', $value);

        try {
            return array_map([$this->locationService, 'loadLocation'], $value);
        } catch (NotFoundException $e) {
            throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
        }
    }
1059802
public function reverseTransform($array)
    {
        if ('' === $array || null === $array) {
            $array = [];
        }

        $values = [];
        foreach ($array as $slug => $field) {
            if ($field === null) {
                continue;
            }
            if (!$field instanceof FieldInterface) {
                throw new TransformationFailedException(sprintf('Expected a %s object.', FieldInterface::class));
            }
            if (!$field->getContentType()) {
                $field->setContentType($this->contentType);
            }
            $values[] = $field;
        }

        return new ArrayCollection($values);
    }
238352
public function toArray()
    {
        $array = [
            'header' => $this->header->toArray(),
            'trailer' => $this->trailer->toArray(),
            'detalhes' => new Collection()
        ];
        foreach ($this->detalhe as $detalhe) {
            $array['detalhes']->push($detalhe->toArray());
        }
        return $array;
    }
1021180
public function toArray() {
      $collectionArray = array();
      foreach ($this->data as $data) {
        $collectionArray[] = $data->toArray();
      }
      return $collectionArray;
    }
877167
public function transform($collection)
    {
        if (null === $collection) {
            return [];
        }

        if (!$collection instanceof Collection) {
            throw new TransformationFailedException('Expected a ' . Collection::class . ' object.');
        }

        $values = [];
        foreach ($collection as $fieldValue) {
            $values[$fieldValue->getField()->getId()] = $fieldValue;
        }

        return $values;
    }