Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Vortex often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Vortex, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
7 | abstract class Vortex |
||
8 | { |
||
9 | use \UnserAllerLib_Api_V4_AdapterProvider; |
||
10 | |||
11 | const DIRECTIVE_FIELDS = 'fields'; |
||
12 | const META_ON_OBJECT_LEVEL_ENABLED = 1; |
||
13 | const META_ON_OBJECT_LEVEL_DISABLED = 0; |
||
14 | |||
15 | /** |
||
16 | * @var \Doctrine\ORM\EntityManager |
||
17 | */ |
||
18 | private $entityManager; |
||
19 | |||
20 | /** |
||
21 | * Defines data that can be included with an api call. You'd try to return only the most frequently used data |
||
22 | * in default payload. Other available raw and aggregated data you'd make includable. Every availableInclude |
||
23 | * has it's own include method and has to be mentioned in this configuration. |
||
24 | * |
||
25 | * Go to the Project Repository for an example configuration |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | protected static $includeWhitelist = []; |
||
30 | protected static $filterWhitelist = []; |
||
31 | protected static $orderWhitelist = []; |
||
32 | |||
33 | private $abstractFilterWhitelist = [ |
||
34 | 'id' => '', |
||
35 | 'any' => '', |
||
36 | 'all' => '' |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * Used in the include configuration to tell if a property is a recursive inclusion or not |
||
41 | */ |
||
42 | const INCLUDE_DIRECT = 0; |
||
43 | const INCLUDE_RECURSIVE = 1; |
||
44 | |||
45 | /** |
||
46 | * Collects operations that have to be run on the doctrine result after query execution |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | private $resultArrayFixSchedule = []; |
||
51 | |||
52 | /** |
||
53 | * Repositories can define a set of properties that are included by default |
||
54 | * |
||
55 | * @var array |
||
56 | */ |
||
57 | protected static $defaultIncludes = []; |
||
58 | |||
59 | /** |
||
60 | * Repositories can define a default order which is taken by default |
||
61 | * |
||
62 | * @var array |
||
63 | */ |
||
64 | protected static $defaultOrder = []; |
||
65 | |||
66 | /** |
||
67 | * If an ID is specified in the URL, it will be saved here for usage in child adapters. |
||
68 | * |
||
69 | * @var int|null |
||
70 | */ |
||
71 | protected $id = null; |
||
72 | |||
73 | /** |
||
74 | * All parameters unsorted |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | protected $unsortedParams = []; |
||
79 | |||
80 | protected $supportedLanguages; |
||
81 | |||
82 | |||
83 | private $finalIncludeWhitelist; |
||
84 | private $finalFilterWhitelist; |
||
85 | private $finalOrderWhitelist; |
||
86 | |||
87 | public function __construct($entityManager, $supportedLanguages = []) |
||
88 | { |
||
89 | $this->entityManager = $entityManager; |
||
90 | $this->supportedLanguages = $supportedLanguages; |
||
91 | |||
92 | //Cache customized whitelists merged with core whitelists |
||
93 | $this->finalFilterWhitelist = array_merge($this->getStaticPropertyOfClassMergedWithParents( |
||
94 | static::class, |
||
95 | 'filterWhitelist' |
||
96 | ), $this->abstractFilterWhitelist); |
||
97 | $this->finalOrderWhitelist = $this->getStaticPropertyOfClassMergedWithParents(static::class, 'orderWhitelist'); |
||
98 | $this->finalIncludeWhitelist = $this->getStaticPropertyOfClassMergedWithParents( |
||
99 | static::class, |
||
100 | 'includeWhitelist' |
||
101 | ); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * @return \Doctrine\ORM\EntityManager |
||
106 | */ |
||
107 | public function getEntityManager() |
||
111 | |||
112 | /** |
||
113 | * @param \Doctrine\ORM\EntityManager $entityManager |
||
114 | * @return $this |
||
115 | */ |
||
116 | public function setEntityManager($entityManager) |
||
121 | |||
122 | private function isNotIncludableProperty($property) |
||
126 | |||
127 | private function isNotFilterableProperty($property) |
||
131 | |||
132 | private function isNotOrderableProperty($property) |
||
136 | |||
137 | public function getTranslatableIncludeNames() |
||
143 | |||
144 | /** |
||
145 | * @return array |
||
146 | */ |
||
147 | private function getPlatformOptions() |
||
151 | |||
152 | /** |
||
153 | * @return bool |
||
154 | */ |
||
155 | protected function arePlatformUsersPublic() |
||
159 | |||
160 | /** |
||
161 | * @return bool |
||
162 | */ |
||
163 | protected function arePlatformUsersPrivate() |
||
167 | |||
168 | /** |
||
169 | * @param \Doctrine\ORM\QueryBuilder $query |
||
170 | * @param string $alias |
||
171 | * @param \UnserAller_Model_User $currentUser |
||
172 | * @param array $additionalParams |
||
173 | * @param $language |
||
174 | * @param $filtername |
||
175 | * @return \Doctrine\ORM\Query\Expr\Orx |
||
176 | * @throws \UnserAllerLib_Api_V4_Exception_MissingFilterDirective |
||
177 | * @throws \UnserAllerLib_Api_V4_Exception_SafeForPrinting |
||
178 | */ |
||
179 | private function filterAny($query, $alias, $currentUser, $additionalParams, $language, $filtername) |
||
190 | |||
191 | /** |
||
192 | * @param \Doctrine\ORM\QueryBuilder $query |
||
193 | * @param string $alias |
||
194 | * @param \UnserAller_Model_User $currentUser |
||
195 | * @param array $additionalParams |
||
196 | * @param $language |
||
197 | * @param $filtername |
||
198 | * @return \Doctrine\ORM\Query\Expr\Orx |
||
199 | * @throws \UnserAllerLib_Api_V4_Exception_MissingFilterDirective |
||
200 | * @throws \UnserAllerLib_Api_V4_Exception_SafeForPrinting |
||
201 | */ |
||
202 | private function filterAll($query, $alias, $currentUser, $additionalParams, $language, $filtername) |
||
213 | |||
214 | /** |
||
215 | * @param \Doctrine\ORM\QueryBuilder $query |
||
216 | * @param string $expressionType |
||
217 | * @param \UnserAller_Model_User $currentUser |
||
218 | * @param array $additionalParams |
||
219 | * @param $language |
||
220 | * @param $filtername |
||
221 | * @return \Doctrine\ORM\Query\Expr\Orx |
||
222 | * @throws \UnserAllerLib_Api_V4_Exception_MissingFilterDirective |
||
223 | * @throws \UnserAllerLib_Api_V4_Exception_SafeForPrinting |
||
224 | */ |
||
225 | private function abstractFilterMultipleFields( |
||
264 | |||
265 | /** |
||
266 | * Executes include methods driven by a include string. See API docs to know how this string looks like |
||
267 | * |
||
268 | * @param \Doctrine\ORM\QueryBuilder $query |
||
269 | * @param \UnserAller_Model_User $currentUser |
||
270 | * @param $language |
||
271 | * @param string $includeString |
||
272 | * @param array $meta |
||
273 | * @return \Doctrine\ORM\QueryBuilder |
||
274 | */ |
||
275 | protected function addIncludeStatements($query, $currentUser, $language, $includeString, &$meta = []) |
||
297 | |||
298 | /** |
||
299 | * Collecting whitelist not just for current class but merged with all whitelists from parent classes. |
||
300 | * So when we overwrite whitelists locally they are still including all the elements from core adapters. |
||
301 | * |
||
302 | * @param null|string $class |
||
303 | * @param $propertyname |
||
304 | * @return array |
||
305 | */ |
||
306 | private function getStaticPropertyOfClassMergedWithParents($class, $propertyname) |
||
318 | |||
319 | private function getStaticPropertyOfClassOrArray($class, $propertyname) |
||
323 | |||
324 | private function updateMetaOnInclude(&$meta, $includeName) |
||
331 | |||
332 | /** |
||
333 | * Calls methods that add where conditions to a query driven by a string (see api docs for string format) |
||
334 | * |
||
335 | * @param \Doctrine\ORM\QueryBuilder $query |
||
336 | * @param \UnserAller_Model_User $currentUser |
||
337 | * @param string $filterString |
||
338 | * @param $language |
||
339 | * @param string $joinFiltersWith |
||
340 | * @return \Doctrine\ORM\QueryBuilder |
||
341 | * @throws \UnserAllerLib_Api_V4_Exception_InvalidFilter |
||
342 | * @uses filterAny |
||
343 | * @uses filterAll |
||
344 | */ |
||
345 | protected function addFilterStatements($query, $currentUser, $filterString, $language, $joinFiltersWith = 'AND') |
||
373 | |||
374 | abstract protected function getFallbackLanguage($resultItem, $requestedLanguage); |
||
375 | |||
376 | /** |
||
377 | * Transforms additionalParams for included collections into params which are used |
||
378 | * during post processing to call a findXForApi method |
||
379 | * |
||
380 | * @param array $additionalParams |
||
381 | * @return array |
||
382 | */ |
||
383 | protected function parseAdditionalIncludeParams($additionalParams) |
||
405 | |||
406 | /** |
||
407 | * Calls methods that add orderBy statements to a query driven by a string (see api docs for the string format) |
||
408 | * |
||
409 | * @param \Doctrine\ORM\QueryBuilder $query |
||
410 | * @param \UnserAller_Model_User $currentUser |
||
411 | * @param string $orderString |
||
412 | * @return \Doctrine\ORM\QueryBuilder |
||
413 | * @throws \UnserAllerLib_Api_V4_Exception_InvalidOrder |
||
414 | */ |
||
415 | private function addOrderStatements($query, $currentUser, $orderString) |
||
438 | |||
439 | /** |
||
440 | * Knows how to append post processing directions to the post process schedule |
||
441 | * |
||
442 | * @param array $tasks |
||
443 | */ |
||
444 | private function schedulePostProcessingDirections($tasks) |
||
458 | |||
459 | /** |
||
460 | * Returns the name of the appropriate include method for $requestedInclude. The rule is simple: |
||
461 | * uppercase first letter and every letter that comes after a dot, remove dots and prepend 'include'. Examples: |
||
462 | * |
||
463 | * returns includeProject when $requestedInclude = project |
||
464 | * returns includePhaseProjectNumberOfLikes when $requestedInclude = phase.project.numerOfLikes |
||
465 | * |
||
466 | * @param string $requestedInclude |
||
467 | * @return string |
||
468 | */ |
||
469 | private function decodeMethodFromRequestedInclude($requestedInclude) |
||
473 | |||
474 | /** |
||
475 | * Returns the name of the appropriate include method for $requestedInclude. The rule is simple: |
||
476 | * uppercase first letter and every letter that comes after a dot, remove dots, prepend 'include'. Examples: |
||
477 | * |
||
478 | * returns includeProject when $requestedInclude = project |
||
479 | * returns includePhaseProjectNumberOfLikes when $requestedInclude = phase.project.numerOfLikes |
||
480 | * |
||
481 | * @param string $requestedInclude |
||
482 | * @return string |
||
483 | */ |
||
484 | private function decodeMethodFromRequestedFilter($requestedInclude) |
||
488 | |||
489 | /** |
||
490 | * Returns the name of the appropriate include method for $requestedInclude. The rule is simple: |
||
491 | * uppercase first letter and every letter that comes after a dot, remove dots, prepend 'include'. Examples: |
||
492 | * |
||
493 | * returns includeProject when $requestedInclude = project |
||
494 | * returns includePhaseProjectNumberOfLikes when $requestedInclude = phase.project.numerOfLikes |
||
495 | * |
||
496 | * @param string $field |
||
497 | * @return string |
||
498 | */ |
||
499 | private function decodeMethodFromRequestedOrder($field) |
||
503 | |||
504 | /** |
||
505 | * Calculates total pages for an $incompleteStatement. Incomplete statements are doctrine query builder instances |
||
506 | * with all required conditions but no select statement and no additional includes. |
||
507 | * |
||
508 | * @param int $numberOfRows |
||
509 | * @param int $limit |
||
510 | * @return float|int |
||
511 | */ |
||
512 | private function calculateTotalPages($numberOfRows, $limit) |
||
520 | |||
521 | /** |
||
522 | * @param \Doctrine\ORM\QueryBuilder $incompleteStatement |
||
523 | * @return int |
||
524 | */ |
||
525 | private function selectTotalNumberOfRows($incompleteStatement) |
||
548 | |||
549 | /** |
||
550 | * Doctrine will throw errors if a table has a multi column primary index |
||
551 | * http://stackoverflow.com/questions/18968963/select-countdistinct-error-on-multiple-columns |
||
552 | * @return string |
||
553 | */ |
||
554 | protected function getPrimaryIndexCol() |
||
558 | |||
559 | /** |
||
560 | * Todo: Include collections by additional params and not by includes and adjust docs |
||
561 | * Takes the include string and decodes it to an array with include names as keys and an array with additionalParams |
||
562 | * as the value. Includes that are nested inside included collections are grouped and added as additional params |
||
563 | * to the included collection. |
||
564 | * |
||
565 | * @param $string |
||
566 | * @param $availableIncludes |
||
567 | * @return array |
||
568 | */ |
||
569 | private function parseIncludeString($string, $availableIncludes) |
||
621 | |||
622 | /** |
||
623 | * creates an array out of string in this format: |
||
624 | * |
||
625 | * modifierName1(modifierParam1|modifierParam2):modifierName2(modifierParam3) |
||
626 | * |
||
627 | * Result: |
||
628 | * [ |
||
629 | * 'modifierName1' => ['modifierParam1','modifierParam2'], |
||
630 | * 'modifierName2' => ['modifierParam3'] |
||
631 | * ] |
||
632 | * |
||
633 | * But doesn't work when modifier params contain other modifiers with params themselves |
||
634 | * |
||
635 | * @param string $allModifiersStr |
||
636 | * @return array |
||
637 | */ |
||
638 | private function parseModifierStringQuickButInaccurate($allModifiersStr) |
||
657 | |||
658 | /** |
||
659 | * creates an array out of string in this format: |
||
660 | * |
||
661 | * modifierName1(modifierParam1|modifierParam2):modifierName2(modifierParam3)) |
||
662 | * |
||
663 | * Can also handle modifier params that contain other modifier with params |
||
664 | * |
||
665 | * @param string $s |
||
666 | * @return array |
||
667 | */ |
||
668 | View Code Duplication | private function parseModifierArraySlowButAccurate($s) |
|
714 | |||
715 | /** |
||
716 | * Can make an array out of parameter string that looks like this: |
||
717 | * |
||
718 | * param1|param2|param3 |
||
719 | * |
||
720 | * Can also handle params that contain other modifiers with params like this: |
||
721 | * param1|modifier(innerParam1|innerParam2)|param3 |
||
722 | * |
||
723 | * @param string $s |
||
724 | * @return array |
||
725 | */ |
||
726 | private function parseModifierParamStringSlowButAccurate($s) |
||
727 | { |
||
728 | $paramArr = []; |
||
729 | $tmpStr = ''; |
||
730 | |||
731 | $depth = 0; |
||
732 | for ($i = 0; $i < strlen($s); $i++) { |
||
733 | switch ($s[$i]) { |
||
734 | case '(': |
||
735 | $tmpStr .= $s[$i]; |
||
736 | $depth++; |
||
737 | break; |
||
738 | |||
739 | case ')': |
||
740 | $tmpStr .= $s[$i]; |
||
741 | $depth--; |
||
742 | break; |
||
743 | |||
744 | case '|': |
||
745 | if ($depth) { |
||
746 | $tmpStr .= $s[$i]; |
||
747 | } else { |
||
748 | $paramArr[] = $tmpStr; |
||
749 | $tmpStr = ''; |
||
750 | } |
||
751 | break; |
||
752 | |||
753 | default: |
||
754 | $tmpStr .= $s[$i]; |
||
755 | } |
||
756 | } |
||
757 | |||
758 | if (strlen($tmpStr)) { |
||
759 | $paramArr[] = $tmpStr; |
||
760 | } |
||
761 | |||
762 | return $paramArr; |
||
763 | } |
||
764 | |||
765 | /** |
||
766 | * Checks if includeName is an include nested inside a recursive inclusion. |
||
767 | * If yes, return the path to that item - false otherwise. |
||
768 | * |
||
769 | * Example: |
||
770 | * For projects there can be an include for phases. Phases are included recursively in its own adapter. So you'd |
||
771 | * want when you include phases.steps that the steps inclusion is executed in the phase adapter and not in the |
||
772 | * project adapter. That's why we need to separate includes that need to be passed further here. |
||
773 | * |
||
774 | * "recursiveinclude" results to false |
||
775 | * "normalprop1" results to false |
||
776 | * "recursiveinclude.normalprop1.normalprop2" results to "recursiveinclude" |
||
777 | * "normalprop1.recursiveinclude.normalprop2" results to "normalprop1.recursiveinclude" |
||
778 | * |
||
779 | * @param $includeName |
||
780 | * @param $availableIncludes |
||
781 | * @return bool|string |
||
782 | */ |
||
783 | private function pathForNestedInclude($includeName, $availableIncludes) |
||
800 | |||
801 | /** |
||
802 | * Include configuration can either have just the strategy or a configuration array with the strategy inside. |
||
803 | * |
||
804 | * @param mixed $include |
||
805 | * @return integer |
||
806 | */ |
||
807 | private function extractStrategyForInclude($include) |
||
811 | |||
812 | /** |
||
813 | * Validates the include string and returns an array with requiredIncludes |
||
814 | * |
||
815 | * @param string $string |
||
816 | * @return array |
||
817 | */ |
||
818 | private function parseRichParamString($string) |
||
862 | |||
863 | private function mergeWithImplicitIncludes($includes, $implicitIncludes) |
||
875 | |||
876 | /** |
||
877 | * @param \Doctrine\ORM\QueryBuilder $query |
||
878 | * @param string $alias |
||
879 | * @param \UnserAller_Model_User $currentUser |
||
880 | * @param array $additionalParams |
||
881 | * @return \Doctrine\ORM\Query\Expr\Andx |
||
882 | */ |
||
883 | protected function filterId($query, $alias, $currentUser, $additionalParams) |
||
889 | |||
890 | private function getImplicitIncludes($includeName) |
||
906 | |||
907 | /** |
||
908 | * @param \UnserAller_Model_User $currentUser |
||
909 | * @return \Doctrine\ORM\QueryBuilder |
||
910 | */ |
||
911 | abstract protected function initIncompleteStatement($currentUser); |
||
912 | |||
913 | private function createIncompleteStatement( |
||
928 | |||
929 | /** |
||
930 | * @param \UnserAller_Model_User $currentUser |
||
931 | * @param string $filterString |
||
932 | * @param $language |
||
933 | * @param string $joinFiltersWith |
||
934 | * @return int |
||
935 | */ |
||
936 | public function findTotalNumberOfRows($currentUser, $filterString = '', $language = '', $joinFiltersWith = 'AND') |
||
942 | |||
943 | /** |
||
944 | * @param \UnserAller_Model_User $currentUser |
||
945 | * @param string $language |
||
946 | * @param string $filterString |
||
947 | * @param string $includeString |
||
948 | * @param string $orderString |
||
949 | * @param int $limit |
||
950 | * @param int $page |
||
951 | * @param string $joinFiltersWith |
||
952 | * @param int $metaOnObjectLevelOption |
||
953 | * @return array |
||
954 | */ |
||
955 | public function findMultipleForApi( |
||
1018 | |||
1019 | private function initMetaArray($modelPathOffset = '', $language = '') |
||
1028 | |||
1029 | /** |
||
1030 | * @param string $language |
||
1031 | * @param string $filterString |
||
1032 | * @param string $includeString |
||
1033 | * @param string $orderString |
||
1034 | * @param int $limit |
||
1035 | * @param int $page |
||
1036 | * @param string $filterMode |
||
1037 | * @return array |
||
1038 | */ |
||
1039 | public function findMultiple( |
||
1060 | |||
1061 | /** |
||
1062 | * @param \UnserAller_Model_User $currentUser |
||
1063 | * @param string $language |
||
1064 | * @param string $filterString |
||
1065 | * @param string $includeString |
||
1066 | * @param string $orderString |
||
1067 | * @param int $limit |
||
1068 | * @param string $filterMode |
||
1069 | * @return \Generator |
||
1070 | */ |
||
1071 | public function batchFindMultiple( |
||
1114 | |||
1115 | |||
1116 | /** |
||
1117 | * @param \UnserAller_Model_User $currentUser |
||
1118 | * @param string $language |
||
1119 | * @param string $filterString |
||
1120 | * @param string $includeString |
||
1121 | * @param string $orderString |
||
1122 | * @param int $limit |
||
1123 | * @param int $page |
||
1124 | * @param string $filterMode |
||
1125 | * @return array |
||
1126 | */ |
||
1127 | public function getNativeSqlIngredientsForFindMultiple( |
||
1143 | |||
1144 | /** |
||
1145 | * Returns a query builder from the findMultipleForApi method. |
||
1146 | * |
||
1147 | * @param $currentUser |
||
1148 | * @param string $language |
||
1149 | * @param string $filterString |
||
1150 | * @param string $includeString |
||
1151 | * @param string $orderString |
||
1152 | * @param int $limit |
||
1153 | * @param int $page |
||
1154 | * @param string $filterMode |
||
1155 | * @return QueryBuilder |
||
1156 | */ |
||
1157 | public function getQueryBuilderFromFindMultiple( |
||
1187 | |||
1188 | /** |
||
1189 | * @param Query $query |
||
1190 | * @return array |
||
1191 | */ |
||
1192 | private function getNativeSqlIngredients($query) |
||
1218 | |||
1219 | /** |
||
1220 | * @param \UnserAller_Model_User $currentUser |
||
1221 | * @param string $language |
||
1222 | * @param string $filterString |
||
1223 | * @param string $includeString |
||
1224 | * @param string $orderString |
||
1225 | * @param int $metaOnObjectLevelOption |
||
1226 | * @return array|null |
||
1227 | */ |
||
1228 | public function findOneForApi( |
||
1245 | |||
1246 | /** |
||
1247 | * @param string $language |
||
1248 | * @param string $filterString |
||
1249 | * @param string $includeString |
||
1250 | * @param string $orderString |
||
1251 | * @return array|null |
||
1252 | */ |
||
1253 | public function findOne($language = '', $filterString = '', $includeString = '', $orderString = '') |
||
1264 | |||
1265 | /** |
||
1266 | * @param \UnserAller_Model_User $currentUser |
||
1267 | * @param int $id |
||
1268 | * @param string $language |
||
1269 | * @param string $include |
||
1270 | * @param int $metaOnObjectLevelOption |
||
1271 | * @return array|null |
||
1272 | */ |
||
1273 | public function findForApi( |
||
1290 | |||
1291 | /** |
||
1292 | * @param int $id |
||
1293 | * @param string $language |
||
1294 | * @param string $include |
||
1295 | * @return array|null |
||
1296 | */ |
||
1297 | public function find($id, $language = '', $include = '') |
||
1307 | |||
1308 | /** |
||
1309 | * @return null|\UnserAller_Model_User|object |
||
1310 | */ |
||
1311 | private function getCurrentlyAuthenticatedUser() |
||
1318 | |||
1319 | /** |
||
1320 | * @param \UnserAller_Model_User $currentUser |
||
1321 | * @param string $language |
||
1322 | * @param string $filterString |
||
1323 | * @param string $includeString |
||
1324 | * @param string $orderString |
||
1325 | * @param int $metaOnObjectLevelOption |
||
1326 | * @return array|null |
||
1327 | */ |
||
1328 | protected function createSingleResult( |
||
1359 | |||
1360 | protected function getDefaultPostProcessDirections() |
||
1364 | |||
1365 | /** |
||
1366 | * Adds the default select statement, all includes and order statements to the incomplete statement |
||
1367 | * and returns the qurey builder instance |
||
1368 | * |
||
1369 | * @param \UnserAller_Model_User $currentUser |
||
1370 | * @param $language |
||
1371 | * @param \Doctrine\ORM\QueryBuilder $incompleteStatement |
||
1372 | * @param string $includeString |
||
1373 | * @param string $orderString |
||
1374 | * @param array $meta |
||
1375 | * @return \Doctrine\ORM\QueryBuilder |
||
1376 | */ |
||
1377 | private function completeStatement( |
||
1401 | |||
1402 | /** |
||
1403 | * Returns the default select statement. In this case it just returns the first root entity which means the |
||
1404 | * entire root entity will be selected |
||
1405 | * |
||
1406 | * @param \Doctrine\ORM\QueryBuilder $query |
||
1407 | * @return string |
||
1408 | */ |
||
1409 | protected function getDefaultSelectStatement($query) |
||
1413 | |||
1414 | /** |
||
1415 | * Returns first root alias from query builder |
||
1416 | * |
||
1417 | * @param \Doctrine\ORM\QueryBuilder $query |
||
1418 | * @return string |
||
1419 | */ |
||
1420 | protected function getRootAlias($query) |
||
1425 | |||
1426 | /** |
||
1427 | * Returns true if result item has an additional layer in the hierarchy because of custom subselects |
||
1428 | * |
||
1429 | * @param array $item |
||
1430 | * @return bool |
||
1431 | */ |
||
1432 | private function mustFlattenResultItem($item) |
||
1436 | |||
1437 | /** |
||
1438 | * Returns doctrine array results with all fixes applied |
||
1439 | * |
||
1440 | * @param \Doctrine\ORM\QueryBuilder $statement |
||
1441 | * @return array |
||
1442 | */ |
||
1443 | private function getRawResult($statement) |
||
1449 | |||
1450 | /** |
||
1451 | * Doctrine will create an additional result layer when values are selected that do not belong |
||
1452 | * to the doctrine object model. This function removes this additional layer and merges custom values with |
||
1453 | * the doctrine object model for a single result item - not the whole result array. |
||
1454 | * |
||
1455 | * @param array $item |
||
1456 | * @return array |
||
1457 | */ |
||
1458 | private function flattenResultItem($item) |
||
1466 | |||
1467 | /** |
||
1468 | * Parses $string for orderBy statements and returns an array where order statements are values. |
||
1469 | * |
||
1470 | * When string is "latestFirst, longestFirst" result would be: ['latestFirst', 'longestFirst'] |
||
1471 | * |
||
1472 | * @param string $string |
||
1473 | * @return array |
||
1474 | */ |
||
1475 | protected function parseOrderString($string) |
||
1479 | |||
1480 | /** |
||
1481 | * @uses getFallbackLanguage |
||
1482 | * @uses getRequestedLanguage |
||
1483 | * @param $language |
||
1484 | * @return callable |
||
1485 | */ |
||
1486 | private function getItemLanguageGetter($language) |
||
1490 | |||
1491 | /** |
||
1492 | * @param mixed[] $resultItem |
||
1493 | * @param string $requestedLanguage |
||
1494 | * @return string |
||
1495 | */ |
||
1496 | private function getRequestedLanguage($resultItem, $requestedLanguage) |
||
1500 | |||
1501 | /** |
||
1502 | * Executes all operations that were scheduled for post processing |
||
1503 | * |
||
1504 | * @param array $result |
||
1505 | * @param \UnserAller_Model_User $currentUser |
||
1506 | * @param $language |
||
1507 | * @param array $meta |
||
1508 | * @param int $metaOnObjectLevelOption |
||
1509 | * @return array |
||
1510 | */ |
||
1511 | private function applyScheduledFixes( |
||
1551 | |||
1552 | private function retrieveNestedCollectionResult($value, $nestingOptions, $language = '') |
||
1585 | |||
1586 | private function retrieveNestedCollection($value, $nestingOptions, $language, $finalPath, $meta) |
||
1590 | |||
1591 | private function retrieveNestedCollectionAndMergeMeta($value, $nestingOptions, $language, $finalPath, &$meta) |
||
1597 | |||
1598 | private function retrieveNestedSingleResult($value, $nestingOptions, $language = '') |
||
1615 | |||
1616 | private function retrieveNestedSingleAndMergeMeta($value, $nestingOptions, $language, $finalPath, &$meta) |
||
1622 | |||
1623 | private function mergeNestedMeta(&$meta, $nestedMeta, $includeName) |
||
1624 | { |
||
1625 | foreach ($nestedMeta['modelnameIndex'] as $model => $paths) { |
||
1626 | foreach ($paths as $path) { |
||
1627 | $fullPath = $includeName . '.' . $path; |
||
1628 | if ($path && (!isset($meta['modelnameIndex'][$model]) || !in_array($fullPath, $meta['modelnameIndex'][$model]))) { |
||
1629 | $meta['modelnameIndex'][$model][] = $fullPath; |
||
1630 | } |
||
1631 | } |
||
1632 | } |
||
1633 | } |
||
1634 | |||
1635 | /** |
||
1636 | * @param $item |
||
1637 | * @param $scheduledFixes |
||
1638 | * @param $currentUser |
||
1639 | * @param $meta |
||
1640 | * @param $collectionNestingMethod |
||
1641 | * @param $language |
||
1642 | * @param $itemLanguageGetter |
||
1643 | * @param int $metaOnObjectLevelOption |
||
1644 | * @uses retrieveNestedCollection |
||
1645 | * @uses retrieveNestedCollectionAndMergeMeta |
||
1646 | */ |
||
1647 | private function applyFixesToItem( |
||
1734 | |||
1735 | /** |
||
1736 | * @param mixed[] $resultItem |
||
1737 | * @param string $requestedLanguage |
||
1738 | * @param callable $itemLanguageGetter |
||
1739 | * @return array |
||
1740 | */ |
||
1741 | private function createMetadataForResultItem($resultItem, $requestedLanguage, $itemLanguageGetter, $model = null) |
||
1748 | |||
1749 | /** |
||
1750 | * Applies filter methods for $filterName to $value |
||
1751 | * @uses filterJsonAfterwards |
||
1752 | * @uses filterJsonIfNullSetEmptyObjectAfterwards |
||
1753 | * @uses filterJsonOrNullAfterwards |
||
1754 | * @uses filterDatetimeAfterwards |
||
1755 | * @uses filterDatetimeOrNullAfterwards |
||
1756 | * @uses filterIntOrNullAfterwards |
||
1757 | * @uses filterNl2BrAfterwards |
||
1758 | * @param string $filterName |
||
1759 | * @param mixed $value |
||
1760 | * @param $currentUser |
||
1761 | * @return mixed |
||
1762 | */ |
||
1763 | private function filterValue($filterName, $value, $currentUser) |
||
1771 | |||
1772 | /** |
||
1773 | * @param $field |
||
1774 | * @param \Doctrine\ORM\QueryBuilder $query |
||
1775 | * @param string $alias |
||
1776 | * @param \UnserAller_Model_User $currentUser |
||
1777 | * @param array $methods |
||
1778 | * @return \Doctrine\ORM\Query\Expr\Andx |
||
1779 | * @uses stringContainExpression |
||
1780 | * @uses stringContainsExpression |
||
1781 | * @uses stringIsExpression |
||
1782 | * @uses stringNotExpression |
||
1783 | * @uses stringFalseExpression |
||
1784 | * @uses stringTrueExpression |
||
1785 | */ |
||
1786 | protected function createConditionsForStringColumn($field, $query, $alias, $currentUser, $methods) |
||
1798 | |||
1799 | /** |
||
1800 | * @param \Doctrine\ORM\QueryBuilder $query |
||
1801 | * @param $fallbackField |
||
1802 | * @param $translationName |
||
1803 | * @param $language |
||
1804 | * @param string $alias |
||
1805 | * @param \UnserAller_Model_User $currentUser |
||
1806 | * @param $additionalParams |
||
1807 | * @return \Doctrine\ORM\Query\Expr\Composite |
||
1808 | * @throws \UnserAllerLib_Api_V4_Exception_InvalidFilter |
||
1809 | */ |
||
1810 | protected function createConditionsForMultilanguageStringColumn( |
||
1856 | |||
1857 | |||
1858 | /** |
||
1859 | * @param $field |
||
1860 | * @param \Doctrine\ORM\QueryBuilder $query |
||
1861 | * @param string $alias |
||
1862 | * @param \UnserAller_Model_User $currentUser |
||
1863 | * @param array $methods |
||
1864 | * @return \Doctrine\ORM\Query\Expr\Andx |
||
1865 | * @uses dateGtExpression |
||
1866 | * @uses dateGteExpression |
||
1867 | * @uses dateLtExpression |
||
1868 | * @uses dateLteExpression |
||
1869 | * @uses dateFalseExpression |
||
1870 | * @uses dateTrueExpression |
||
1871 | * @uses dateIsExpression |
||
1872 | * @uses dateNotExpression |
||
1873 | */ |
||
1874 | View Code Duplication | protected function createConditionsForDatetimeColumn($field, $query, $alias, $currentUser, $methods) |
|
1886 | |||
1887 | /** |
||
1888 | * @param $field |
||
1889 | * @param \Doctrine\ORM\QueryBuilder $query |
||
1890 | * @param string $alias |
||
1891 | * @param \UnserAller_Model_User $currentUser |
||
1892 | * @param array $methods |
||
1893 | * @return \Doctrine\ORM\Query\Expr\Andx |
||
1894 | * @uses entityFalseExpression |
||
1895 | * @uses entityTrueExpression |
||
1896 | * @uses entityIsExpression |
||
1897 | * @uses entityIsOrNullExpression |
||
1898 | * @uses entityNotExpression |
||
1899 | * @uses entityMeExpression |
||
1900 | * @uses entityNotmeExpression |
||
1901 | * @uses entityLtExpression |
||
1902 | * @uses entityLteExpression |
||
1903 | * @uses entityGtExpression |
||
1904 | * @uses entityGteExpression |
||
1905 | */ |
||
1906 | View Code Duplication | protected function createConditionsForEntityColumn($field, $query, $alias, $currentUser, $methods) |
|
1917 | |||
1918 | /** |
||
1919 | * @param $subquery |
||
1920 | * @param $query |
||
1921 | * @param $alias |
||
1922 | * @param $currentUser |
||
1923 | * @param $methods |
||
1924 | * @return \Doctrine\ORM\Query\Expr\Andx |
||
1925 | * @uses subqueryIsExpression |
||
1926 | * @uses subqueryFalseExpression |
||
1927 | * @uses subqueryTrueExpression |
||
1928 | * @uses subqueryNotExpression |
||
1929 | * @uses subqueryMeExpression |
||
1930 | * @uses subqueryNotmeExpression |
||
1931 | * @uses subqueryEqExpression |
||
1932 | */ |
||
1933 | protected function createConditionsForEntitySubquery($subquery, $query, $alias, $currentUser, $methods) |
||
1941 | |||
1942 | /** |
||
1943 | * @param \Doctrine\ORM\QueryBuilder $query |
||
1944 | * @param string $field |
||
1945 | * @param array $params |
||
1946 | * @param string $alias |
||
1947 | * @return mixed |
||
1948 | */ |
||
1949 | private function entityIsExpression($query, $field, $params, $alias) |
||
1953 | |||
1954 | /** |
||
1955 | * @param \Doctrine\ORM\QueryBuilder $query |
||
1956 | * @param string $field |
||
1957 | * @param array $params |
||
1958 | * @param string $alias |
||
1959 | * @return mixed |
||
1960 | */ |
||
1961 | private function entityIsOrNullExpression($query, $field, $params, $alias) |
||
1968 | |||
1969 | /** |
||
1970 | * @param \Doctrine\ORM\QueryBuilder $query |
||
1971 | * @param string $field |
||
1972 | * @param array $params |
||
1973 | * @param string $alias |
||
1974 | * @param \UnserAller_Model_User $currentUser |
||
1975 | * @return mixed |
||
1976 | * @throws \UnserAllerLib_Api_V4_Exception_UserRequiredButNotAuthenticated |
||
1977 | */ |
||
1978 | private function entityMeExpression($query, $field, $params, $alias, $currentUser) |
||
1985 | |||
1986 | |||
1987 | /** |
||
1988 | * @param \Doctrine\ORM\QueryBuilder $query |
||
1989 | * @param string $field |
||
1990 | * @param array $params |
||
1991 | * @param string $alias |
||
1992 | * @param \UnserAller_Model_User $currentUser |
||
1993 | * @return \Doctrine\ORM\Query\Expr\Comparison |
||
1994 | * @throws \UnserAllerLib_Api_V4_Exception_UserRequiredButNotAuthenticated |
||
1995 | */ |
||
1996 | private function entityNotmeExpression($query, $field, $params, $alias, $currentUser) |
||
2003 | |||
2004 | /** |
||
2005 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2006 | * @param string $field |
||
2007 | * @param array $params |
||
2008 | * @param string $alias |
||
2009 | * @return \Doctrine\ORM\Query\Expr\Func |
||
2010 | */ |
||
2011 | private function entityNotExpression($query, $field, $params, $alias) |
||
2015 | |||
2016 | /** |
||
2017 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2018 | * @param string $field |
||
2019 | * @param array $params |
||
2020 | * @param string $alias |
||
2021 | * @return \Doctrine\ORM\Query\Expr\Comparison |
||
2022 | */ |
||
2023 | private function entityFalseExpression($query, $field, $params, $alias) |
||
2027 | |||
2028 | /** |
||
2029 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2030 | * @param string $field |
||
2031 | * @param array $params |
||
2032 | * @param string $alias |
||
2033 | * @return \Doctrine\ORM\Query\Expr\Comparison |
||
2034 | */ |
||
2035 | private function entityTrueExpression($query, $field, $params, $alias) |
||
2039 | |||
2040 | /** |
||
2041 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2042 | * @param string $field |
||
2043 | * @param array $params |
||
2044 | * @param string $alias |
||
2045 | * @return mixed |
||
2046 | */ |
||
2047 | private function entityLtExpression($query, $field, $params, $alias) |
||
2059 | |||
2060 | /** |
||
2061 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2062 | * @param string $field |
||
2063 | * @param array $params |
||
2064 | * @param string $alias |
||
2065 | * @return mixed |
||
2066 | */ |
||
2067 | private function entityLteExpression($query, $field, $params, $alias) |
||
2079 | |||
2080 | /** |
||
2081 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2082 | * @param string $field |
||
2083 | * @param array $params |
||
2084 | * @param string $alias |
||
2085 | * @return mixed |
||
2086 | */ |
||
2087 | private function entityGtExpression($query, $field, $params, $alias) |
||
2099 | |||
2100 | /** |
||
2101 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2102 | * @param string $field |
||
2103 | * @param array $params |
||
2104 | * @param string $alias |
||
2105 | * @return mixed |
||
2106 | */ |
||
2107 | private function entityGteExpression($query, $field, $params, $alias) |
||
2119 | |||
2120 | /** |
||
2121 | * Translates params into where conditions. The subquery must really return an integer for it to work! |
||
2122 | * Returning null will cause wrong bahvior!!! In DQL it seems to be impossible to do an IS NULL comparison |
||
2123 | * on a subquery. And it seems to be impossible to not return null values either |
||
2124 | * Todo: Needs research, for time being only true comparison is working as expected |
||
2125 | * |
||
2126 | * |
||
2127 | * @param $subquery |
||
2128 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2129 | * @param string $alias |
||
2130 | * @param \UnserAller_Model_User $currentUser |
||
2131 | * @param array $methods |
||
2132 | * @return \Doctrine\ORM\Query\Expr\Andx |
||
2133 | * @uses subqueryFalseExpression |
||
2134 | * @uses subqueryTrueExpression |
||
2135 | * @uses subqueryGtExpression |
||
2136 | * @uses subqueryGteExpression |
||
2137 | * @uses subqueryLtExpression |
||
2138 | * @uses subqueryLteExpression |
||
2139 | * @uses subqueryEqExpression |
||
2140 | * @uses subqueryAnyExpression |
||
2141 | * @uses subqueryNullExpression |
||
2142 | */ |
||
2143 | View Code Duplication | protected function createConditionsForIntegerSubquery($subquery, $query, $alias, $currentUser, $methods) |
|
2155 | |||
2156 | /** |
||
2157 | * @param $subquery |
||
2158 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2159 | * @param string $alias |
||
2160 | * @param \UnserAller_Model_User $currentUser |
||
2161 | * @param array $methods |
||
2162 | * @return \Doctrine\ORM\Query\Expr\Andx |
||
2163 | */ |
||
2164 | View Code Duplication | protected function createConditionsForIntegerCollectionSubquery($subquery, $query, $alias, $currentUser, $methods) |
|
2172 | |||
2173 | /** |
||
2174 | * Translates params into where conditions. The subquery must really return an integer for it to work! |
||
2175 | * Returning null will cause wrong bahvior!!! In DQL it seems to be impossible to do an IS NULL comparison |
||
2176 | * on a subquery. And it seems to be impossible to not return null values either |
||
2177 | * Todo: Needs research, for time being only true comparison is working as expected |
||
2178 | * |
||
2179 | * |
||
2180 | * @param $subquery |
||
2181 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2182 | * @param string $alias |
||
2183 | * @param \UnserAller_Model_User $currentUser |
||
2184 | * @param array $methods |
||
2185 | * @return \Doctrine\ORM\Query\Expr\Andx |
||
2186 | * @uses subqueryAnyisExpression |
||
2187 | */ |
||
2188 | View Code Duplication | protected function createConditionsForStringCollectionSubquery($subquery, $query, $alias, $currentUser, $methods) |
|
2196 | |||
2197 | /** |
||
2198 | * Translates params into where conditions. The subquery must really return an integer for it to work! |
||
2199 | * Returning null will cause wrong bahvior!!! In DQL it seems to be impossible to do an IS NULL comparison |
||
2200 | * on a subquery. And it seems to be impossible to not return null values either |
||
2201 | * Todo: Needs research, for time being only true comparison is working as expected |
||
2202 | * |
||
2203 | * |
||
2204 | * @param $subquery |
||
2205 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2206 | * @param string $alias |
||
2207 | * @param \UnserAller_Model_User $currentUser |
||
2208 | * @param array $methods |
||
2209 | * @return \Doctrine\ORM\Query\Expr\Andx |
||
2210 | * @uses subqueryTrueExpression |
||
2211 | * @uses subqueryFalseExpression |
||
2212 | */ |
||
2213 | View Code Duplication | protected function createConditionsForDatetimeSubquery($subquery, $query, $alias, $currentUser, $methods) |
|
2221 | |||
2222 | /** |
||
2223 | * Translates params into where conditions. Null values are handled as you would expect it. |
||
2224 | * |
||
2225 | * @param $col |
||
2226 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2227 | * @param string $alias |
||
2228 | * @param \UnserAller_Model_User $currentUser |
||
2229 | * @param array $methods |
||
2230 | * @return \Doctrine\ORM\Query\Expr\Andx |
||
2231 | * @uses integerIsExpression |
||
2232 | * @uses integerNotExpression |
||
2233 | * @uses integerGtExpression |
||
2234 | * @uses integerGteExpression |
||
2235 | * @uses integerLtExpression |
||
2236 | * @uses integerLteExpression |
||
2237 | * @uses integerFalseExpression |
||
2238 | * @uses integerTrueExpression |
||
2239 | */ |
||
2240 | View Code Duplication | protected function createConditionsForIntegerColumn($col, $query, $alias, $currentUser, $methods) |
|
2252 | |||
2253 | /** |
||
2254 | * Todo: Whitelisting allowed subqueries for the any filter makes having this extra function unnecessary |
||
2255 | * |
||
2256 | * This one allows some filter directives that result to function calls on protected methods. Don't ever redirect |
||
2257 | * user content here. |
||
2258 | * |
||
2259 | * Translates params into where conditions. Null values are handled as you would expect it. |
||
2260 | * |
||
2261 | * @param $col |
||
2262 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2263 | * @param string $alias |
||
2264 | * @param \UnserAller_Model_User $currentUser |
||
2265 | * @param array $methods |
||
2266 | * @return \Doctrine\ORM\Query\Expr\Andx |
||
2267 | * @uses integerIsExpression |
||
2268 | * @uses integerNotExpression |
||
2269 | * @uses integerGtExpression |
||
2270 | * @uses integerGteExpression |
||
2271 | * @uses integerLtExpression |
||
2272 | * @uses integerLteExpression |
||
2273 | * @uses integerFalseExpression |
||
2274 | * @uses integerTrueExpression |
||
2275 | * @uses integerAnyExpression |
||
2276 | */ |
||
2277 | View Code Duplication | protected function createConditionsForIntegerColumnInternal($col, $query, $alias, $currentUser, $methods) |
|
2289 | |||
2290 | /** |
||
2291 | * Knows how to create a callable from a subquery definition |
||
2292 | * |
||
2293 | * @param string $name of subquery |
||
2294 | * @param mixed[] $params for subquerymethod |
||
2295 | * @return callable |
||
2296 | */ |
||
2297 | protected function locateCallableSubquery($name, $params) |
||
2301 | |||
2302 | /** |
||
2303 | * @param array $subqueryDefinition |
||
2304 | * @return string DQL |
||
2305 | */ |
||
2306 | private function consumeSubquery($subqueryDefinition) |
||
2314 | |||
2315 | /** |
||
2316 | * @param $prefix |
||
2317 | * @param string $field |
||
2318 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2319 | * @param string $alias |
||
2320 | * @param \UnserAller_Model_User $currentUser |
||
2321 | * @param array $methods |
||
2322 | * @return \Doctrine\ORM\Query\Expr\Andx |
||
2323 | */ |
||
2324 | private function createExpression($prefix, $field, $query, $alias, $currentUser, $methods) |
||
2336 | |||
2337 | /** |
||
2338 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2339 | * @param array $field |
||
2340 | * @param array $params |
||
2341 | * @param string $alias |
||
2342 | * @return mixed |
||
2343 | */ |
||
2344 | private function subqueryFalseExpression($query, $field, $params, $alias) |
||
2351 | |||
2352 | /** |
||
2353 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2354 | * @param array $field |
||
2355 | * @param array $params |
||
2356 | * @param string $alias |
||
2357 | * @return mixed |
||
2358 | */ |
||
2359 | private function subqueryNullExpression($query, $field, $params, $alias) |
||
2363 | |||
2364 | /** |
||
2365 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2366 | * @param array $subquery |
||
2367 | * @param array $params |
||
2368 | * @param string $alias |
||
2369 | * @return mixed |
||
2370 | */ |
||
2371 | View Code Duplication | private function subqueryTrueExpression($query, $subquery, $params, $alias) |
|
2378 | |||
2379 | /** |
||
2380 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2381 | * @param array $subquery |
||
2382 | * @param array $params |
||
2383 | * @param string $alias |
||
2384 | * @return mixed |
||
2385 | */ |
||
2386 | private function subqueryAnyisExpression($query, $subquery, $params, $alias) |
||
2398 | |||
2399 | /** |
||
2400 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2401 | * @param array $subquery |
||
2402 | * @param array $params |
||
2403 | * @param string $alias |
||
2404 | * @return mixed |
||
2405 | */ |
||
2406 | View Code Duplication | private function subqueryGtExpression($query, $subquery, $params, $alias) |
|
2422 | |||
2423 | /** |
||
2424 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2425 | * @param array $subquery |
||
2426 | * @param array $params |
||
2427 | * @return Query\Expr\Andx |
||
2428 | */ |
||
2429 | View Code Duplication | private function subqueryGteExpression($query, $subquery, $params) |
|
2445 | |||
2446 | /** |
||
2447 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2448 | * @param array $subquery |
||
2449 | * @param array $params |
||
2450 | * @param string $alias |
||
2451 | * @return mixed |
||
2452 | */ |
||
2453 | View Code Duplication | private function subqueryLteExpression($query, $subquery, $params, $alias) |
|
2469 | |||
2470 | /** |
||
2471 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2472 | * @param array $subquery |
||
2473 | * @param array $params |
||
2474 | * @param string $alias |
||
2475 | * @return mixed |
||
2476 | */ |
||
2477 | View Code Duplication | private function subqueryLtExpression($query, $subquery, $params, $alias) |
|
2493 | |||
2494 | /** |
||
2495 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2496 | * @param array $subquery |
||
2497 | * @param array $params |
||
2498 | * @param string $alias |
||
2499 | * @return mixed |
||
2500 | */ |
||
2501 | View Code Duplication | private function subqueryEqExpression($query, $subquery, $params, $alias) |
|
2508 | |||
2509 | /** |
||
2510 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2511 | * @param array $subquery |
||
2512 | * @param array $params |
||
2513 | * @param string $alias |
||
2514 | * @return mixed |
||
2515 | */ |
||
2516 | private function subqueryIsExpression($query, $subquery, $params, $alias) |
||
2520 | |||
2521 | /** |
||
2522 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2523 | * @param string $field |
||
2524 | * @param array $params |
||
2525 | * @param string $alias |
||
2526 | * @return mixed |
||
2527 | */ |
||
2528 | private function dateIsExpression($query, $field, $params, $alias) |
||
2532 | |||
2533 | /** |
||
2534 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2535 | * @param string $field |
||
2536 | * @param array $params |
||
2537 | * @param string $alias |
||
2538 | * @return mixed |
||
2539 | */ |
||
2540 | private function integerIsExpression($query, $field, $params, $alias) |
||
2544 | |||
2545 | /** |
||
2546 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2547 | * @param string $field |
||
2548 | * @param array $params |
||
2549 | * @param string $alias |
||
2550 | * @return mixed |
||
2551 | */ |
||
2552 | private function stringIsExpression($query, $field, $params, $alias) |
||
2556 | |||
2557 | /** |
||
2558 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2559 | * @param string $field |
||
2560 | * @param array $params |
||
2561 | * @param string $alias |
||
2562 | * @return \Doctrine\ORM\Query\Expr\Comparison |
||
2563 | * @throws \UnserAllerLib_Api_V4_Exception_UserRequiredButNotAuthenticated |
||
2564 | */ |
||
2565 | private function integerAnyExpression($query, $field, $params, $alias) |
||
2569 | |||
2570 | /** |
||
2571 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2572 | * @param string $field |
||
2573 | * @param array $params |
||
2574 | * @param string $alias |
||
2575 | * @return \Doctrine\ORM\Query\Expr\Func |
||
2576 | */ |
||
2577 | private function integerNotExpression($query, $field, $params, $alias) |
||
2581 | |||
2582 | /** |
||
2583 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2584 | * @param string $field |
||
2585 | * @param array $params |
||
2586 | * @param string $alias |
||
2587 | * @return \Doctrine\ORM\Query\Expr\Func |
||
2588 | */ |
||
2589 | private function dateNotExpression($query, $field, $params, $alias) |
||
2593 | |||
2594 | /** |
||
2595 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2596 | * @param string $field |
||
2597 | * @param array $params |
||
2598 | * @param string $alias |
||
2599 | * @return mixed |
||
2600 | */ |
||
2601 | private function stringNotExpression($query, $field, $params, $alias) |
||
2605 | |||
2606 | /** |
||
2607 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2608 | * @param string $field |
||
2609 | * @param array $params |
||
2610 | * @param string $alias |
||
2611 | * @return \Doctrine\ORM\Query\Expr\Comparison |
||
2612 | */ |
||
2613 | private function integerFalseExpression($query, $field, $params, $alias) |
||
2617 | |||
2618 | /** |
||
2619 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2620 | * @param string $field |
||
2621 | * @param array $params |
||
2622 | * @param string $alias |
||
2623 | * @return \Doctrine\ORM\Query\Expr\Comparison |
||
2624 | */ |
||
2625 | private function dateFalseExpression($query, $field, $params, $alias) |
||
2629 | |||
2630 | /** |
||
2631 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2632 | * @param string $field |
||
2633 | * @param array $params |
||
2634 | * @param string $alias |
||
2635 | * @return \Doctrine\ORM\Query\Expr\Base |
||
2636 | */ |
||
2637 | private function stringFalseExpression($query, $field, $params, $alias) |
||
2644 | |||
2645 | /** |
||
2646 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2647 | * @param string $field |
||
2648 | * @param array $params |
||
2649 | * @param string $alias |
||
2650 | * @return \Doctrine\ORM\Query\Expr\Comparison |
||
2651 | */ |
||
2652 | private function integerTrueExpression($query, $field, $params, $alias) |
||
2656 | |||
2657 | /** |
||
2658 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2659 | * @param string $field |
||
2660 | * @param array $params |
||
2661 | * @param string $alias |
||
2662 | * @return \Doctrine\ORM\Query\Expr\Comparison |
||
2663 | */ |
||
2664 | private function dateTrueExpression($query, $field, $params, $alias) |
||
2668 | |||
2669 | /** |
||
2670 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2671 | * @param string $field |
||
2672 | * @param array $params |
||
2673 | * @param string $alias |
||
2674 | * @return \Doctrine\ORM\Query\Expr\Base |
||
2675 | */ |
||
2676 | private function stringTrueExpression($query, $field, $params, $alias) |
||
2683 | |||
2684 | /** |
||
2685 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2686 | * @param string $field |
||
2687 | * @param array $params |
||
2688 | * @param string $alias |
||
2689 | * @return mixed |
||
2690 | */ |
||
2691 | View Code Duplication | private function stringContainsExpression($query, $field, $params, $alias) |
|
2704 | |||
2705 | /** |
||
2706 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2707 | * @param string $field |
||
2708 | * @param array $params |
||
2709 | * @param string $alias |
||
2710 | * @return mixed |
||
2711 | */ |
||
2712 | private function stringContainExpression($query, $field, $params, $alias) |
||
2716 | |||
2717 | /** |
||
2718 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2719 | * @param string $field |
||
2720 | * @param array $params |
||
2721 | * @param string $alias |
||
2722 | * @return mixed |
||
2723 | */ |
||
2724 | View Code Duplication | private function dateLtExpression($query, $field, $params, $alias) |
|
2736 | |||
2737 | /** |
||
2738 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2739 | * @param string $field |
||
2740 | * @param array $params |
||
2741 | * @param string $alias |
||
2742 | * @return mixed |
||
2743 | */ |
||
2744 | View Code Duplication | private function integerLtExpression($query, $field, $params, $alias) |
|
2756 | |||
2757 | /** |
||
2758 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2759 | * @param string $field |
||
2760 | * @param array $params |
||
2761 | * @param string $alias |
||
2762 | * @return mixed |
||
2763 | */ |
||
2764 | View Code Duplication | private function integerLteExpression($query, $field, $params, $alias) |
|
2776 | |||
2777 | /** |
||
2778 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2779 | * @param string $field |
||
2780 | * @param array $params |
||
2781 | * @param string $alias |
||
2782 | * @return mixed |
||
2783 | */ |
||
2784 | View Code Duplication | private function dateLteExpression($query, $field, $params, $alias) |
|
2796 | |||
2797 | /** |
||
2798 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2799 | * @param string $field |
||
2800 | * @param array $params |
||
2801 | * @param string $alias |
||
2802 | * @return mixed |
||
2803 | */ |
||
2804 | View Code Duplication | private function dateGtExpression($query, $field, $params, $alias) |
|
2816 | |||
2817 | /** |
||
2818 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2819 | * @param string $field |
||
2820 | * @param array $params |
||
2821 | * @param string $alias |
||
2822 | * @return mixed |
||
2823 | */ |
||
2824 | View Code Duplication | private function integerGtExpression($query, $field, $params, $alias) |
|
2836 | |||
2837 | /** |
||
2838 | * @return string |
||
2839 | */ |
||
2840 | protected function getModelForMeta() |
||
2844 | |||
2845 | /** |
||
2846 | * @return string |
||
2847 | */ |
||
2848 | public function getClassnameForRepresentedModel() |
||
2852 | |||
2853 | /** |
||
2854 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2855 | * @param string $field |
||
2856 | * @param array $params |
||
2857 | * @param string $alias |
||
2858 | * @return mixed |
||
2859 | */ |
||
2860 | View Code Duplication | private function integerGteExpression($query, $field, $params, $alias) |
|
2872 | |||
2873 | /** |
||
2874 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2875 | * @param string $field |
||
2876 | * @param array $params |
||
2877 | * @param string $alias |
||
2878 | * @return mixed |
||
2879 | */ |
||
2880 | View Code Duplication | private function dateGteExpression($query, $field, $params, $alias) |
|
2892 | |||
2893 | /** |
||
2894 | * Does some crazy things |
||
2895 | * |
||
2896 | * @param string $value |
||
2897 | * @return array |
||
2898 | */ |
||
2899 | private function filterJsonAfterwards($value) |
||
2903 | |||
2904 | /** |
||
2905 | * Does some crazy things |
||
2906 | * |
||
2907 | * @param string $value |
||
2908 | * @return mixed |
||
2909 | */ |
||
2910 | private function filterJsonIfNullSetEmptyObjectAfterwards($value) |
||
2914 | |||
2915 | /** |
||
2916 | * Does some crazy things |
||
2917 | * |
||
2918 | * @param string $value |
||
2919 | * @return string |
||
2920 | */ |
||
2921 | private function filterNl2BrAfterwards($value) |
||
2925 | |||
2926 | /** |
||
2927 | * Does some crazy things |
||
2928 | * |
||
2929 | * @param string $value |
||
2930 | * @return array |
||
2931 | */ |
||
2932 | private function filterJsonOrNullAfterwards($value) |
||
2936 | |||
2937 | /** |
||
2938 | * Too complex to explain |
||
2939 | * |
||
2940 | * @param string $value |
||
2941 | * @return \DateTime |
||
2942 | */ |
||
2943 | private function filterDatetimeAfterwards($value) |
||
2947 | |||
2948 | /** |
||
2949 | * Too complex to explain |
||
2950 | * |
||
2951 | * @param string $value |
||
2952 | * @return \DateTime |
||
2953 | */ |
||
2954 | private function filterDatetimeOrNullAfterwards($value) |
||
2958 | |||
2959 | /** |
||
2960 | * Too complex to explain |
||
2961 | * |
||
2962 | * @param string|null $value |
||
2963 | * @return int|null |
||
2964 | */ |
||
2965 | private function filterIntOrNullAfterwards($value) |
||
2969 | |||
2970 | /** |
||
2971 | * Returns the current resultArrayFixSchedule. Afterwards the schedule will be empty again. |
||
2972 | * |
||
2973 | * @return array |
||
2974 | */ |
||
2975 | private function flushResultArrayFixSchedule() |
||
2981 | |||
2982 | /** |
||
2983 | * Returns true if $alias was used in $query already - false otherwise |
||
2984 | * |
||
2985 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2986 | * @param string $alias |
||
2987 | * @return bool |
||
2988 | */ |
||
2989 | protected function wasAliasUsed($query, $alias) |
||
2993 | |||
2994 | /** |
||
2995 | * Returns true if $alias was used in $query already - false otherwise |
||
2996 | * |
||
2997 | * @param \Doctrine\ORM\QueryBuilder $query |
||
2998 | * @param string $alias |
||
2999 | * @return bool |
||
3000 | */ |
||
3001 | protected function wasntAliasUsed($query, $alias) |
||
3005 | |||
3006 | /** |
||
3007 | * @return array |
||
3008 | */ |
||
3009 | public function getUnsortedParams() |
||
3013 | |||
3014 | /** |
||
3015 | * @param array $unsortedParams |
||
3016 | * @return $this |
||
3017 | */ |
||
3018 | public function setUnsortedParams($unsortedParams) |
||
3024 | |||
3025 | /** |
||
3026 | * @param \Doctrine\ORM\QueryBuilder $query |
||
3027 | * @param string $translationName |
||
3028 | * @param string $language |
||
3029 | * @return string alias of joined translation table |
||
3030 | */ |
||
3031 | protected function joinTranslationOnce($query, $translationName, $language) |
||
3053 | |||
3054 | /** |
||
3055 | * @param \Doctrine\ORM\QueryBuilder $query |
||
3056 | * @param string $alias |
||
3057 | * @param string $col |
||
3058 | * @param string $name |
||
3059 | * @param string $translationName |
||
3060 | * @param string $language |
||
3061 | * @return array |
||
3062 | */ |
||
3063 | protected function abstractIncludeMultilanguageStringColumn( |
||
3086 | |||
3087 | protected function getAdditionalUserParamOrFail(&$additionalParams) |
||
3097 | } |
||
3098 |
The
EntityManager
might become unusable for example if a transaction is rolled back and it gets closed. Let’s assume that somewhere in your application, or in a third-party library, there is code such as the following:If that code throws an exception and the
EntityManager
is closed. Any other code which depends on the same instance of theEntityManager
during this request will fail.On the other hand, if you instead inject the
ManagerRegistry
, thegetManager()
method guarantees that you will always get a usable manager instance.