‪TYPO3CMS  10.4
PersistenceDelegate.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 
29 {
33  protected ‪$queryBuilder;
34 
38  protected ‪$resolveModifier;
39 
43  protected ‪$generateModifier;
44 
51  {
52  $this->queryBuilder = ‪$queryBuilder;
53  $this->resolveModifier = ‪$resolveModifier;
54  $this->generateModifier = ‪$generateModifier;
55  }
56 
60  public function ‪exists(array $values): bool
61  {
62  $this->‪applyValueModifier($this->resolveModifier, $values);
63  return $this->queryBuilder
64  ->count('*')
65  ->execute()
66  ->fetchColumn(0) > 0;
67  }
68 
72  public function ‪resolve(array $values): ?array
73  {
74  $this->‪applyValueModifier($this->resolveModifier, $values);
75  $result = $this->queryBuilder
76  ->execute()
77  ->fetch();
78  return $result !== false ? $result : null;
79  }
80 
84  public function ‪generate(array $values): ?array
85  {
86  $this->‪applyValueModifier($this->generateModifier, $values);
87  $result = $this->queryBuilder
88  ->execute()
89  ->fetch();
90  return $result !== false ? $result : null;
91  }
92 
97  protected function ‪applyValueModifier(\Closure $modifier, array $values)
98  {
99  $modifier($this->queryBuilder, $values);
100  }
101 }
‪TYPO3\CMS\Core\Routing\Aspect\PersistenceDelegate\__construct
‪__construct(QueryBuilder $queryBuilder, \Closure $resolveModifier, \Closure $generateModifier)
Definition: PersistenceDelegate.php:47
‪TYPO3\CMS\Core\Routing\Aspect\PersistenceDelegate\generate
‪generate(array $values)
Definition: PersistenceDelegate.php:81
‪TYPO3\CMS\Core\Routing\Aspect\PersistenceDelegate
Definition: PersistenceDelegate.php:29
‪TYPO3\CMS\Core\Routing\Aspect\PersistenceDelegate\resolve
‪resolve(array $values)
Definition: PersistenceDelegate.php:69
‪TYPO3\CMS\Core\Database\Query\QueryBuilder
Definition: QueryBuilder.php:52
‪TYPO3\CMS\Core\Routing\Aspect\PersistenceDelegate\$generateModifier
‪Closure $generateModifier
Definition: PersistenceDelegate.php:40
‪TYPO3\CMS\Core\Routing\Aspect\PersistenceDelegate\$queryBuilder
‪QueryBuilder $queryBuilder
Definition: PersistenceDelegate.php:32
‪TYPO3\CMS\Core\Routing\Aspect\PersistenceDelegate\applyValueModifier
‪applyValueModifier(\Closure $modifier, array $values)
Definition: PersistenceDelegate.php:94
‪TYPO3\CMS\Core\Routing\Aspect\PersistenceDelegate\$resolveModifier
‪Closure $resolveModifier
Definition: PersistenceDelegate.php:36
‪TYPO3\CMS\Core\Routing\Aspect\DelegateInterface
Definition: DelegateInterface.php:27
‪TYPO3\CMS\Core\Routing\Aspect
Definition: AspectFactory.php:18
‪TYPO3\CMS\Core\Routing\Aspect\PersistenceDelegate\exists
‪exists(array $values)
Definition: PersistenceDelegate.php:57