1<?php
2
3/*
4 * This file is part of the TYPO3 CMS project.
5 *
6 * It is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License, either version 2
8 * of the License, or any later version.
9 *
10 * For the full copyright and license information, please read the
11 * LICENSE.txt file that was distributed with this source code.
12 *
13 * The TYPO3 project - inspiring people to share!
14 */
15
16namespace TYPO3\CMS\Extbase\Persistence\Generic\Qom;
17
18/**
19 * Performs a logical conjunction of two other constraints.
20 *
21 * To satisfy the And constraint, a node-tuple must satisfy both constraint1 and
22 * constraint2.
23 * @internal only to be used within Extbase, not part of TYPO3 Core API.
24 */
25class LogicalAnd implements AndInterface
26{
27    /**
28     * @var ConstraintInterface
29     */
30    protected $constraint1;
31
32    /**
33     * @var ConstraintInterface
34     */
35    protected $constraint2;
36
37    /**
38     * @param ConstraintInterface $constraint1
39     * @param ConstraintInterface $constraint2
40     */
41    public function __construct(ConstraintInterface $constraint1, ConstraintInterface $constraint2)
42    {
43        $this->constraint1 = $constraint1;
44        $this->constraint2 = $constraint2;
45    }
46
47    /**
48     * Fills an array with the names of all bound variables in the constraints
49     *
50     * @param array $boundVariables
51     */
52    public function collectBoundVariableNames(&$boundVariables)
53    {
54        $this->constraint1->collectBoundVariableNames($boundVariables);
55        $this->constraint2->collectBoundVariableNames($boundVariables);
56    }
57
58    /**
59     * Gets the first constraint.
60     *
61     * @return ConstraintInterface the constraint; non-null
62     */
63    public function getConstraint1()
64    {
65        return $this->constraint1;
66    }
67
68    /**
69     * Gets the second constraint.
70     *
71     * @return ConstraintInterface the constraint; non-null
72     */
73    public function getConstraint2()
74    {
75        return $this->constraint2;
76    }
77}
78