@@ -90,25 +90,25 @@ |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | //Ensure we have an valid operator |
93 | - if(!in_array($this->operator, self::ALLOWED_OPERATOR_VALUES, true)) { |
|
94 | - throw new \RuntimeException('Invalid operator '. $this->operator . ' provided. Valid operators are '. implode(', ', self::ALLOWED_OPERATOR_VALUES)); |
|
93 | + if (!in_array($this->operator, self::ALLOWED_OPERATOR_VALUES, true)) { |
|
94 | + throw new \RuntimeException('Invalid operator '.$this->operator.' provided. Valid operators are '.implode(', ', self::ALLOWED_OPERATOR_VALUES)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $expressions = []; |
98 | 98 | |
99 | 99 | if ($this->operator === 'ANY' || $this->operator === 'NONE') { |
100 | - foreach($this->value as $value) { |
|
100 | + foreach ($this->value as $value) { |
|
101 | 101 | //We cannnot use an paramater here, as this is the only way to pass the FCQN to the query (via binded params, we would need to use ClassMetaData). See: https://github.com/doctrine/orm/issues/4462 |
102 | 102 | $expressions[] = ($queryBuilder->expr()->isInstanceOf($this->property, $value)); |
103 | 103 | } |
104 | 104 | |
105 | - if($this->operator === 'ANY') { |
|
105 | + if ($this->operator === 'ANY') { |
|
106 | 106 | $queryBuilder->andWhere($queryBuilder->expr()->orX(...$expressions)); |
107 | 107 | } else { //NONE |
108 | 108 | $queryBuilder->andWhere($queryBuilder->expr()->not($queryBuilder->expr()->orX(...$expressions))); |
109 | 109 | } |
110 | 110 | } else { |
111 | - throw new \RuntimeException('Unknown operator '. $this->operator . ' provided. Valid operators are '. implode(', ', self::ALLOWED_OPERATOR_VALUES)); |
|
111 | + throw new \RuntimeException('Unknown operator '.$this->operator.' provided. Valid operators are '.implode(', ', self::ALLOWED_OPERATOR_VALUES)); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | } |
115 | 115 | \ No newline at end of file |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | public function setValue(?AbstractDBElement $value): void |
112 | 112 | { |
113 | 113 | if (!$value instanceof $this->class) { |
114 | - throw new \InvalidArgumentException('The value must be an instance of ' . $this->class); |
|
114 | + throw new \InvalidArgumentException('The value must be an instance of '.$this->class); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | $this->value = $value; |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | //Ensure we have an valid operator |
158 | - if(!in_array($this->operator, $this->getAllowedOperatorValues(), true)) { |
|
159 | - throw new \RuntimeException('Invalid operator '. $this->operator . ' provided. Valid operators are '. implode(', ', $this->getAllowedOperatorValues())); |
|
158 | + if (!in_array($this->operator, $this->getAllowedOperatorValues(), true)) { |
|
159 | + throw new \RuntimeException('Invalid operator '.$this->operator.' provided. Valid operators are '.implode(', ', $this->getAllowedOperatorValues())); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | //We need to handle null values differently, as they can not be compared with == or != |
163 | 163 | if ($this->value === null) { |
164 | - if($this->operator === '=' || $this->operator === 'INCLUDING_CHILDREN') { |
|
164 | + if ($this->operator === '=' || $this->operator === 'INCLUDING_CHILDREN') { |
|
165 | 165 | $queryBuilder->andWhere(sprintf("%s IS NULL", $this->property)); |
166 | 166 | return; |
167 | 167 | } |
@@ -171,16 +171,16 @@ discard block |
||
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
174 | - throw new \RuntimeException('Unknown operator '. $this->operator . ' provided. Valid operators are '. implode(', ', $this->getAllowedOperatorValues())); |
|
174 | + throw new \RuntimeException('Unknown operator '.$this->operator.' provided. Valid operators are '.implode(', ', $this->getAllowedOperatorValues())); |
|
175 | 175 | } |
176 | 176 | |
177 | - if($this->operator === '=' || $this->operator === '!=') { |
|
177 | + if ($this->operator === '=' || $this->operator === '!=') { |
|
178 | 178 | $this->addSimpleAndConstraint($queryBuilder, $this->property, $this->identifier, $this->operator, $this->value); |
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | 182 | //Otherwise retrieve the children list and apply the operator to it |
183 | - if($this->isStructural()) { |
|
183 | + if ($this->isStructural()) { |
|
184 | 184 | $list = $this->nodesListBuilder->getChildrenFlatList($this->value); |
185 | 185 | //Add the element itself to the list |
186 | 186 | $list[] = $this->value; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | return; |
196 | 196 | } |
197 | 197 | } else { |
198 | - throw new \RuntimeException('Cannot apply operator '. $this->operator . ' to non-structural type'); |
|
198 | + throw new \RuntimeException('Cannot apply operator '.$this->operator.' to non-structural type'); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | } |
@@ -117,19 +117,19 @@ |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | //Ensure we have an valid operator |
120 | - if(!in_array($this->operator, self::ALLOWED_OPERATOR_VALUES, true)) { |
|
121 | - throw new \RuntimeException('Invalid operator '. $this->operator . ' provided. Valid operators are '. implode(', ', self::ALLOWED_OPERATOR_VALUES)); |
|
120 | + if (!in_array($this->operator, self::ALLOWED_OPERATOR_VALUES, true)) { |
|
121 | + throw new \RuntimeException('Invalid operator '.$this->operator.' provided. Valid operators are '.implode(', ', self::ALLOWED_OPERATOR_VALUES)); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | if ($this->operator !== 'BETWEEN') { |
125 | 125 | $this->addSimpleAndConstraint($queryBuilder, $this->property, $this->identifier, $this->operator, $this->value1); |
126 | - } else { |
|
126 | + } else { |
|
127 | 127 | if ($this->value2 === null) { |
128 | 128 | throw new RuntimeException("Cannot use operator BETWEEN without value2!"); |
129 | 129 | } |
130 | 130 | |
131 | - $this->addSimpleAndConstraint($queryBuilder, $this->property, $this->identifier . '1', '>=', $this->value1); |
|
132 | - $this->addSimpleAndConstraint($queryBuilder, $this->property, $this->identifier . '2', '<=', $this->value2); |
|
131 | + $this->addSimpleAndConstraint($queryBuilder, $this->property, $this->identifier.'1', '>=', $this->value1); |
|
132 | + $this->addSimpleAndConstraint($queryBuilder, $this->property, $this->identifier.'2', '<=', $this->value2); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | \ No newline at end of file |
@@ -123,7 +123,7 @@ |
||
123 | 123 | |
124 | 124 | if ($this->operator !== 'BETWEEN') { |
125 | 125 | $this->addSimpleAndConstraint($queryBuilder, $this->property, $this->identifier, $this->operator, $this->value1); |
126 | - } else { |
|
126 | + } else { |
|
127 | 127 | if ($this->value2 === null) { |
128 | 128 | throw new RuntimeException("Cannot use operator BETWEEN without value2!"); |
129 | 129 | } |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | //Ensure we have an valid operator |
90 | - if(!in_array($this->operator, self::ALLOWED_OPERATOR_VALUES, true)) { |
|
91 | - throw new \RuntimeException('Invalid operator '. $this->operator . ' provided. Valid operators are '. implode(', ', self::ALLOWED_OPERATOR_VALUES)); |
|
90 | + if (!in_array($this->operator, self::ALLOWED_OPERATOR_VALUES, true)) { |
|
91 | + throw new \RuntimeException('Invalid operator '.$this->operator.' provided. Valid operators are '.implode(', ', self::ALLOWED_OPERATOR_VALUES)); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | if ($this->operator === 'ANY') { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } elseif ($this->operator === 'NONE') { |
97 | 97 | $this->addSimpleAndConstraint($queryBuilder, $this->property, $this->identifier, 'NOT IN', $this->value); |
98 | 98 | } else { |
99 | - throw new \RuntimeException('Unknown operator '. $this->operator . ' provided. Valid operators are '. implode(', ', self::ALLOWED_OPERATOR_VALUES)); |
|
99 | + throw new \RuntimeException('Unknown operator '.$this->operator.' provided. Valid operators are '.implode(', ', self::ALLOWED_OPERATOR_VALUES)); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
103 | 103 | \ No newline at end of file |
@@ -74,34 +74,34 @@ discard block |
||
74 | 74 | { |
75 | 75 | $fields_to_search = []; |
76 | 76 | |
77 | - if($this->name) { |
|
77 | + if ($this->name) { |
|
78 | 78 | $fields_to_search[] = 'part.name'; |
79 | 79 | } |
80 | - if($this->category) { |
|
80 | + if ($this->category) { |
|
81 | 81 | $fields_to_search[] = 'category.name'; |
82 | 82 | } |
83 | - if($this->description) { |
|
83 | + if ($this->description) { |
|
84 | 84 | $fields_to_search[] = 'part.description'; |
85 | 85 | } |
86 | - if($this->tags) { |
|
86 | + if ($this->tags) { |
|
87 | 87 | $fields_to_search[] = 'part.tags'; |
88 | 88 | } |
89 | - if($this->storelocation) { |
|
89 | + if ($this->storelocation) { |
|
90 | 90 | $fields_to_search[] = 'storelocations.name'; |
91 | 91 | } |
92 | - if($this->ordernr) { |
|
92 | + if ($this->ordernr) { |
|
93 | 93 | $fields_to_search[] = 'orderdetails.supplierpartnr'; |
94 | 94 | } |
95 | - if($this->mpn) { |
|
95 | + if ($this->mpn) { |
|
96 | 96 | $fields_to_search[] = 'part.manufacturer_product_url'; |
97 | 97 | } |
98 | - if($this->supplier) { |
|
98 | + if ($this->supplier) { |
|
99 | 99 | $fields_to_search[] = 'suppliers.name'; |
100 | 100 | } |
101 | - if($this->manufacturer) { |
|
101 | + if ($this->manufacturer) { |
|
102 | 102 | $fields_to_search[] = 'manufacturer.name'; |
103 | 103 | } |
104 | - if($this->footprint) { |
|
104 | + if ($this->footprint) { |
|
105 | 105 | $fields_to_search[] = 'footprint.name'; |
106 | 106 | } |
107 | 107 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | //Convert the fields to search to a list of expressions |
121 | - $expressions = array_map(function (string $field) { |
|
121 | + $expressions = array_map(function(string $field) { |
|
122 | 122 | if ($this->regex) { |
123 | 123 | return sprintf("REGEXP(%s, :search_query) = 1", $field); |
124 | 124 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | if ($this->regex) { |
136 | 136 | $queryBuilder->setParameter('search_query', $this->keyword); |
137 | 137 | } else { |
138 | - $queryBuilder->setParameter('search_query', '%' . $this->keyword . '%'); |
|
138 | + $queryBuilder->setParameter('search_query', '%'.$this->keyword.'%'); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 |
@@ -42,15 +42,15 @@ |
||
42 | 42 | |
43 | 43 | $value = $property->getValue($this); |
44 | 44 | //We only want filters (objects implementing FilterInterface) |
45 | - if($value instanceof FilterInterface) { |
|
45 | + if ($value instanceof FilterInterface) { |
|
46 | 46 | $filters[$property->getName()] = $value; |
47 | 47 | } |
48 | 48 | |
49 | 49 | //Add filters in collections |
50 | 50 | if ($value instanceof Collection) { |
51 | 51 | foreach ($value as $key => $filter) { |
52 | - if($filter instanceof FilterInterface) { |
|
53 | - $filters[$property->getName() . '.' . (string) $key] = $filter; |
|
52 | + if ($filter instanceof FilterInterface) { |
|
53 | + $filters[$property->getName().'.'.(string) $key] = $filter; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | $this->cache->invalidateTags([$secure_class_name]); |
58 | 58 | |
59 | 59 | //Trigger a sidebar reload for all users (see SidebarTreeUpdater service) |
60 | - if(!$element instanceof LabelProfile) { |
|
60 | + if (!$element instanceof LabelProfile) { |
|
61 | 61 | $this->cache->invalidateTags(['sidebar_tree_update']); |
62 | 62 | } |
63 | 63 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | { |
27 | 27 | |
28 | 28 | |
29 | - $builder->addEventListener(FormEvents::PRE_SET_DATA, function (PreSetDataEvent $event) { |
|
29 | + $builder->addEventListener(FormEvents::PRE_SET_DATA, function(PreSetDataEvent $event) { |
|
30 | 30 | $form = $event->getForm(); |
31 | 31 | /** @var ProjectBOMEntry $data */ |
32 | 32 | $data = $event->getData(); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function buildForm(FormBuilderInterface $builder, array $options) |
37 | 37 | { |
38 | 38 | //At initialization we have to fill the form element with our selected data, so the user can see it |
39 | - $builder->addEventListener(FormEvents::PRE_SET_DATA, function (PreSetDataEvent $event) { |
|
39 | + $builder->addEventListener(FormEvents::PRE_SET_DATA, function(PreSetDataEvent $event) { |
|
40 | 40 | $form = $event->getForm(); |
41 | 41 | $config = $form->getConfig()->getOptions(); |
42 | 42 | $data = $event->getData() ?? []; |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | |
96 | 96 | $resolver->setDefaults([ |
97 | 97 | //Prefill the selected choice with the needed data, so the user can see it without an additional Ajax request |
98 | - 'choice_attr' => ChoiceList::attr($this, function (?Part $part) { |
|
99 | - if($part) { |
|
98 | + 'choice_attr' => ChoiceList::attr($this, function(?Part $part) { |
|
99 | + if ($part) { |
|
100 | 100 | //Determine the picture to show: |
101 | 101 | $preview_attachment = $this->previewGenerator->getTablePreviewAttachment($part); |
102 | 102 | if ($preview_attachment !== null) { |