1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
5
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
6
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
7
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
8
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
9
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
10
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
11
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
12
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
13
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
14
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
15
|
|
|
* |
16
|
|
|
* This software consists of voluntary contributions made by many individuals |
17
|
|
|
* and is licensed under the MIT license. For more information, see |
18
|
|
|
* <http://www.doctrine-project.org>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace DoctrineModule\Validator\Service; |
22
|
|
|
|
23
|
|
|
use Interop\Container\ContainerInterface; |
24
|
|
|
use DoctrineModule\Validator\NoObjectExists; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Factory for creating NoObjectExists instances |
28
|
|
|
* |
29
|
|
|
* @license MIT |
30
|
|
|
* @link http://www.doctrine-project.org/ |
31
|
|
|
* @since 1.3.0 |
32
|
|
|
* @author Fabian Grutschus <[email protected]> |
33
|
|
|
*/ |
34
|
|
|
class NoObjectExistsFactory extends AbstractValidatorFactory |
35
|
|
|
{ |
36
|
|
|
protected $validatorClass = NoObjectExists::class; |
37
|
|
|
|
38
|
2 |
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
39
|
|
|
{ |
40
|
2 |
|
$container = $this->container($container); |
41
|
|
|
|
42
|
2 |
|
$repository = $this->getRepository($container, $options); |
|
|
|
|
43
|
|
|
|
44
|
2 |
|
$validator = new NoObjectExists($this->merge($options, [ |
|
|
|
|
45
|
2 |
|
'object_repository' => $repository, |
46
|
2 |
|
'fields' => $this->getFields($options), |
|
|
|
|
47
|
2 |
|
])); |
48
|
|
|
|
49
|
2 |
|
return $validator; |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.