mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Form\DataTransformer;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
|
||||
class PersonToIdTransformer implements DataTransformerInterface
|
||||
{
|
||||
@@ -14,37 +21,19 @@ class PersonToIdTransformer implements DataTransformerInterface
|
||||
*/
|
||||
private $om;
|
||||
|
||||
/**
|
||||
* @param ObjectManager $om
|
||||
*/
|
||||
public function __construct(ObjectManager $om)
|
||||
{
|
||||
$this->om = $om;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms an object (issue) to a string (id).
|
||||
*
|
||||
* @param Person|null $issue
|
||||
* @return string
|
||||
*/
|
||||
public function transform($issue)
|
||||
{
|
||||
if (null === $issue) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return $issue->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a string (id) to an object (issue).
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return Person|null
|
||||
*
|
||||
* @throws TransformationFailedException if object (issue) is not found.
|
||||
*
|
||||
* @return Person|null
|
||||
*/
|
||||
public function reverseTransform($id)
|
||||
{
|
||||
@@ -54,8 +43,7 @@ class PersonToIdTransformer implements DataTransformerInterface
|
||||
|
||||
$issue = $this->om
|
||||
->getRepository('ChillPersonBundle:Person')
|
||||
->findOneBy(array('id' => $id))
|
||||
;
|
||||
->findOneBy(['id' => $id]);
|
||||
|
||||
if (null === $issue) {
|
||||
throw new TransformationFailedException(sprintf(
|
||||
@@ -66,5 +54,20 @@ class PersonToIdTransformer implements DataTransformerInterface
|
||||
|
||||
return $issue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms an object (issue) to a string (id).
|
||||
*
|
||||
* @param Person|null $issue
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function transform($issue)
|
||||
{
|
||||
if (null === $issue) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $issue->getId();
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user