@@ -37,9 +37,9 @@ public function __construct(ObjectManager $manager)
37
37
*/
38
38
public function transform ($ array )
39
39
{
40
- // This transformation expects an array of Tag always thanks to
40
+ // The value received is an array of Tag objects generated with
41
41
// Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer::transform()
42
- // Just remains transform this array into a comma separated string format.
42
+ // The value returned is a string that concatenates the string representation of those objects
43
43
44
44
/* @var Tag[] $array */
45
45
return implode (', ' , $ array );
@@ -56,7 +56,7 @@ public function reverseTransform($string)
56
56
57
57
$ names = explode (', ' , $ string );
58
58
59
- // Now we need to get the current tags and to find the new ones that should be created.
59
+ // Get the current tags and find the new ones that should be created.
60
60
$ tags = $ this ->manager ->getRepository (Tag::class)->findBy ([
61
61
'name ' => $ names ,
62
62
]);
@@ -66,11 +66,11 @@ public function reverseTransform($string)
66
66
$ tag ->setName ($ name );
67
67
$ tags [] = $ tag ;
68
68
69
- // Don't worry about persisting these new tags, Doctrine is able to do it automatically
70
- // thanks to cascade={"persist"} configuration in AppBundle\Entity\Post::$tags property.
69
+ // There's no need to persist these new tags because Doctrine does that automatically
70
+ // thanks to the cascade={"persist"} option in the AppBundle\Entity\Post::$tags property.
71
71
}
72
72
73
- // This one should return an array always to transform these tags into Collection instance again .
73
+ // Return an array of tags to transform them back into a Doctrine Collection .
74
74
// See Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer::reverseTransform()
75
75
return $ tags ;
76
76
}
0 commit comments