Skip to content

Commit a62876f

Browse files
Updated some help notes
1 parent 4d71179 commit a62876f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/AppBundle/Form/DataTransformer/TagArrayToStringTransformer.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public function __construct(ObjectManager $manager)
3737
*/
3838
public function transform($array)
3939
{
40-
// This transformation expects an array of Tag always thanks to
40+
// The value received is an array of Tag objects generated with
4141
// 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
4343

4444
/* @var Tag[] $array */
4545
return implode(',', $array);
@@ -56,7 +56,7 @@ public function reverseTransform($string)
5656

5757
$names = explode(',', $string);
5858

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.
6060
$tags = $this->manager->getRepository(Tag::class)->findBy([
6161
'name' => $names,
6262
]);
@@ -66,11 +66,11 @@ public function reverseTransform($string)
6666
$tag->setName($name);
6767
$tags[] = $tag;
6868

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.
7171
}
7272

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.
7474
// See Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer::reverseTransform()
7575
return $tags;
7676
}

0 commit comments

Comments
 (0)