🔐 Sid Gifari File Manager Pro
v8.0.5 | 2026-06-17 09:44:27 | PHP 8.1.34
📂
/ (Root)
/
opt
/
alt
/
php54
/
usr
/
share
/
pear
/
Symfony
/
Bridge
/
Doctrine
/
Form
/
DataTransformer
📍 /opt/alt/php54/usr/share/pear/Symfony/Bridge/Doctrine/Form/DataTransformer
🔄 Refresh
✏️
Editing: CollectionToArrayTransformer.php
Read Only
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bridge\Doctrine\Form\DataTransformer; use Symfony\Component\Form\Exception\TransformationFailedException; use Symfony\Component\Form\DataTransformerInterface; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; /** * @author Bernhard Schussek <bschussek@gmail.com> */ class CollectionToArrayTransformer implements DataTransformerInterface { /** * Transforms a collection into an array. * * @param Collection $collection A collection of entities * * @return mixed An array of entities * * @throws TransformationFailedException */ public function transform($collection) { if (null === $collection) { return array(); } // 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(); } /** * Transforms choice keys into entities. * * @param mixed $array An array of entities * * @return Collection A collection of entities */ public function reverseTransform($array) { if ('' === $array || null === $array) { $array = array(); } else { $array = (array) $array; } return new ArrayCollection($array); } }
💾 Save Changes
❌ Cancel