[FORM] Implement ActorArrayTransformer

This commit is contained in:
Daniel 2020-10-14 21:43:44 +01:00 committed by Hugo Sales
parent 279cfcd058
commit c3aa2ae400
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -32,27 +32,37 @@
namespace App\Util\Form; namespace App\Util\Form;
use App\Entity\GSActor;
class ActorArrayTransformer extends ArrayTransformer class ActorArrayTransformer extends ArrayTransformer
{ {
/** /**
* Transforms array of GSActors into string of usernames
*
* @param array $a * @param array $a
* *
* @return string * @return string
*/ */
public function transform($a) public function transform($a)
{ {
// TODO convert each to string return parent::transform(array_map(
$s = parent::transform($a); function ($actor) { return $actor->getNickname(); },
$a)
);
} }
/** /**
* Transforms string of usernames into GSActors
*
* @param string $s * @param string $s
* *
* @return array * @return array
*/ */
public function reverseTransform($s) public function reverseTransform($s)
{ {
$a = parent::reverseTransform($s); return array_map(
// TODO convert each to profile function ($nickmame) { return GSActor::getFromNickname($nickmame); },
parent::reverseTransform($s)
);
} }
} }