[FORM] Implement ActorArrayTransformer
This commit is contained in:
parent
279cfcd058
commit
c3aa2ae400
|
@ -32,27 +32,37 @@
|
|||
|
||||
namespace App\Util\Form;
|
||||
|
||||
use App\Entity\GSActor;
|
||||
|
||||
class ActorArrayTransformer extends ArrayTransformer
|
||||
{
|
||||
/**
|
||||
* Transforms array of GSActors into string of usernames
|
||||
*
|
||||
* @param array $a
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function transform($a)
|
||||
{
|
||||
// TODO convert each to string
|
||||
$s = parent::transform($a);
|
||||
return parent::transform(array_map(
|
||||
function ($actor) { return $actor->getNickname(); },
|
||||
$a)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms string of usernames into GSActors
|
||||
*
|
||||
* @param string $s
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function reverseTransform($s)
|
||||
{
|
||||
$a = parent::reverseTransform($s);
|
||||
// TODO convert each to profile
|
||||
return array_map(
|
||||
function ($nickmame) { return GSActor::getFromNickname($nickmame); },
|
||||
parent::reverseTransform($s)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user