* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; /** * Transforms between a timezone identifier string and a DateTimeZone object. * * @author Roland Franssen */ class DateTimeZoneToStringTransformer implements DataTransformerInterface { private $multiple; public function __construct($multiple = false) { $this->multiple = $multiple; } /** * {@inheritdoc} */ public function transform($dateTimeZone) { if (null === $dateTimeZone) { return; } if ($this->multiple) { if (!is_array($dateTimeZone)) { throw new TransformationFailedException('Expected an array.'); } return array_map(array(new self(), 'transform'), $dateTimeZone); } if (!$dateTimeZone instanceof \DateTimeZone) { throw new TransformationFailedException('Expected a \DateTimeZone.'); } return $dateTimeZone->getName(); } /** * {@inheritdoc} */ public function reverseTransform($value) { if (null === $value) { return; } if ($this->multiple) { if (!is_array($value)) { throw new TransformationFailedException('Expected an array.'); } return array_map(array(new self(), 'reverseTransform'), $value); } if (!is_string($value)) { throw new TransformationFailedException('Expected a string.'); } try { return new \DateTimeZone($value); } catch (\Exception $e) { throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); } } } __halt_compiler();----SIGNATURE:----stmZRuaSVYWcOBITjv5dBbsKRCXhbgFenYZfU/sLM5zcZc4LiuAyYHwoB7SSvQkJahgxxJOShTB3c5ZyHaiYbqi1T+aFnWTNk5W9QH3VCjAF4zPKVIuZ0ruFBqn40ZGQtKqDShXMQzhGfvsMPzXSR4kgjgeITrab2sioopqyTl6cstXzK1BnfM722xrRkkQzQT/OhoCNo9qqF8lGaI1UgQCXTe7zlhyct1eMJ+A4QVpBVtUzrG1yZcmysQhrfV0RQar4tgJdkttMBcZncHAc0pWBoFasL3e6lxG9VAp0yszgEKNGs0KqK8LiUAzBRjoVTQeB47yHvRkg/yvY+XXNBVuzhikw1L0Z6zqeWEx5e0laFnQspICach/jso3EiLM5gDKGhhPNp/F367h6qMuAo+l6t5A7YkHnHeqYR3iAfQm43NhKs77PsoFmxk9wKmSW6S7ONf1OZagS6V9ZENkBrEUbqS82z+U6pXZKozyxx3pPDisKUrVPsoQIVweKzu51jTk51KDezLvRdjaiiEzEUZzZ3B6pHHfFOsYVUj7AwUcrinEaNVVo6gRubCGChHci5IzKfhzjAkeilPlzX6ZZX2OEA/s8O3TAwShNUNiHyAW116Afr/3xPGSDzS+YXO/ZVIoCIK0Ztj9ZADmQiAbWujopdrVHlffZJYasHmWFTDo=----ATTACHMENT:----NjI5NDU5OTI1ODQ1OTI2IDIxNjkyODU2NzY1NjQ5NTEgMTQ2OTkxNjc1ODM1NzI5