@@ -210,7 +210,7 @@ constraint.
210
210
}
211
211
}
212
212
213
- If the callback is stored in a different class and is static, for example ``Util ``,
213
+ If the callback is stored in a different class and is static, for example ``AppBundle\Entity\Genre ``,
214
214
you can pass the class name and the method as an array.
215
215
216
216
.. configuration-block ::
@@ -225,7 +225,7 @@ you can pass the class name and the method as an array.
225
225
class Author
226
226
{
227
227
/**
228
- * @Assert\Choice(callback={"Util ", "getGenres"})
228
+ * @Assert\Choice(callback={"AppBundle\Entity\Genre ", "getGenres"})
229
229
*/
230
230
protected $genre;
231
231
}
@@ -236,7 +236,7 @@ you can pass the class name and the method as an array.
236
236
AppBundle\Entity\Author :
237
237
properties :
238
238
genre :
239
- - Choice : { callback: [Util , getGenres] }
239
+ - Choice : { callback: [AppBundle\Entity\Genre , getGenres] }
240
240
241
241
.. code-block :: xml
242
242
@@ -250,7 +250,7 @@ you can pass the class name and the method as an array.
250
250
<property name =" genre" >
251
251
<constraint name =" Choice" >
252
252
<option name =" callback" >
253
- <value >Util </value >
253
+ <value >AppBundle\Entity\Genre </value >
254
254
<value >getGenres</value >
255
255
</option >
256
256
</constraint >
@@ -263,6 +263,7 @@ you can pass the class name and the method as an array.
263
263
// src/AppBundle/Entity/Author.php
264
264
namespace AppBundle\Entity;
265
265
266
+ use AppBundle\Entity\Genre;
266
267
use Symfony\Component\Validator\Mapping\ClassMetadata;
267
268
use Symfony\Component\Validator\Constraints as Assert;
268
269
@@ -273,7 +274,7 @@ you can pass the class name and the method as an array.
273
274
public static function loadValidatorMetadata(ClassMetadata $metadata)
274
275
{
275
276
$metadata->addPropertyConstraint('genre', new Assert\Choice(array(
276
- 'callback' => array('Util' , 'getGenres'),
277
+ 'callback' => array(Genre::class , 'getGenres'),
277
278
)));
278
279
}
279
280
}
0 commit comments