@@ -206,7 +206,7 @@ constraint.
206206 }
207207 }
208208
209- If the callback is stored in a different class and is static, for example ``Util ``,
209+ If the callback is stored in a different class and is static, for example ``App\Entity\Genre ``,
210210you can pass the class name and the method as an array.
211211
212212.. configuration-block ::
@@ -221,7 +221,7 @@ you can pass the class name and the method as an array.
221221 class Author
222222 {
223223 /**
224- * @Assert\Choice(callback={"Util ", "getGenres"})
224+ * @Assert\Choice(callback={"App\Entity\Genre ", "getGenres"})
225225 */
226226 protected $genre;
227227 }
@@ -232,7 +232,7 @@ you can pass the class name and the method as an array.
232232 App\Entity\Author :
233233 properties :
234234 genre :
235- - Choice : { callback: [Util , getGenres] }
235+ - Choice : { callback: [App\Entity\Genre , getGenres] }
236236
237237 .. code-block :: xml
238238
@@ -246,7 +246,7 @@ you can pass the class name and the method as an array.
246246 <property name =" genre" >
247247 <constraint name =" Choice" >
248248 <option name =" callback" >
249- <value >Util </value >
249+ <value >App\Entity\Genre </value >
250250 <value >getGenres</value >
251251 </option >
252252 </constraint >
@@ -259,6 +259,7 @@ you can pass the class name and the method as an array.
259259 // src/Entity/Author.php
260260 namespace App\Entity;
261261
262+ use App\Entity\Genre;
262263 use Symfony\Component\Validator\Mapping\ClassMetadata;
263264 use Symfony\Component\Validator\Constraints as Assert;
264265
@@ -269,7 +270,7 @@ you can pass the class name and the method as an array.
269270 public static function loadValidatorMetadata(ClassMetadata $metadata)
270271 {
271272 $metadata->addPropertyConstraint('genre', new Assert\Choice(array(
272- 'callback' => array('Util' , 'getGenres'),
273+ 'callback' => array(Genre::class , 'getGenres'),
273274 )));
274275 }
275276 }
0 commit comments