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