ヤミRoot VoidGate
User / IP
:
216.73.216.110
Host / Server
:
146.88.233.70 / dev.loger.cm
System
:
Linux hybrid1120.fr.ns.planethoster.net 3.10.0-957.21.2.el7.x86_64 #1 SMP Wed Jun 5 14:26:44 UTC 2019 x86_64
Command
|
Upload
|
Create
Mass Deface
|
Jumping
|
Symlink
|
Reverse Shell
Ping
|
Port Scan
|
DNS Lookup
|
Whois
|
Header
|
cURL
:
/
home
/
itrave
/
api
/
vendor
/
friendsofsymfony
/
rest-bundle
/
Serializer
/
Normalizer
/
Viewing: FormErrorNormalizer.php
<?php /* * This file is part of the FOSRestBundle package. * * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace FOS\RestBundle\Serializer\Normalizer; use Symfony\Component\Form\FormError; use Symfony\Component\Form\FormInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Translation\TranslatorInterface; /** * Normalizes invalid Form instances. * * @author Ener-Getick <egetick@gmail.com> */ class FormErrorNormalizer implements NormalizerInterface { private $translator; public function __construct(TranslatorInterface $translator) { $this->translator = $translator; } /** * {@inheritdoc} */ public function normalize($object, $format = null, array $context = []) { return [ 'code' => isset($context['status_code']) ? $context['status_code'] : null, 'message' => 'Validation Failed', 'errors' => $this->convertFormToArray($object), ]; } /** * {@inheritdoc} */ public function supportsNormalization($data, $format = null) { return $data instanceof FormInterface && $data->isSubmitted() && !$data->isValid(); } /** * This code has been taken from JMSSerializer. */ private function convertFormToArray(FormInterface $data) { $form = $errors = []; foreach ($data->getErrors() as $error) { $errors[] = $this->getErrorMessage($error); } if ($errors) { $form['errors'] = $errors; } $children = []; foreach ($data->all() as $child) { if ($child instanceof FormInterface) { $children[$child->getName()] = $this->convertFormToArray($child); } } if ($children) { $form['children'] = $children; } return $form; } private function getErrorMessage(FormError $error) { if (null !== $error->getMessagePluralization()) { return $this->translator->transChoice($error->getMessageTemplate(), $error->getMessagePluralization(), $error->getMessageParameters(), 'validators'); } return $this->translator->trans($error->getMessageTemplate(), $error->getMessageParameters(), 'validators'); } }
Coded With 💗 by
0x6ick