|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Symfony package. |
|
|
5 |
* |
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
7 |
* |
|
|
8 |
* For the full copyright and license information, please view the LICENSE |
|
|
9 |
* file that was distributed with this source code. |
|
|
10 |
*/ |
|
|
11 |
|
|
|
12 |
namespace Symfony\Component\Validator\Constraints; |
|
|
13 |
|
|
|
14 |
use Symfony\Component\Validator\Constraint; |
|
|
15 |
|
|
|
16 |
/** |
|
|
17 |
* @Annotation |
|
|
18 |
* |
|
|
19 |
* @api |
|
|
20 |
*/ |
|
|
21 |
class Collection extends Constraint |
|
|
22 |
{ |
|
|
23 |
public $fields; |
|
|
24 |
public $allowExtraFields = false; |
|
|
25 |
public $allowMissingFields = false; |
|
|
26 |
public $extraFieldsMessage = 'The fields {{ fields }} were not expected'; |
|
|
27 |
public $missingFieldsMessage = 'The fields {{ fields }} are missing'; |
|
|
28 |
|
|
|
29 |
/** |
|
|
30 |
* {@inheritDoc} |
|
|
31 |
*/ |
|
|
32 |
public function __construct($options = null) |
|
|
33 |
{ |
|
|
34 |
// no known options set? $options is the fields array |
|
|
35 |
if (is_array($options) |
|
|
36 |
&& !array_intersect(array_keys($options), array('groups', 'fields', 'allowExtraFields', 'allowMissingFields', 'extraFieldsMessage', 'missingFieldsMessage'))) { |
|
|
37 |
$options = array('fields' => $options); |
|
|
38 |
} |
|
|
39 |
|
|
|
40 |
parent::__construct($options); |
|
|
41 |
} |
|
|
42 |
|
|
|
43 |
public function getRequiredOptions() |
|
|
44 |
{ |
|
|
45 |
return array('fields'); |
|
|
46 |
} |
|
|
47 |
} |