@@ -50,15 +50,15 @@ |
||
50 | 50 | |
51 | 51 | //Add a attachment for each footprint attachment |
52 | 52 | $this->addSql( |
53 | - 'INSERT IGNORE INTO attachments (element_id, type_id, name, class_name, path, last_modified, datetime_added) ' . |
|
54 | - "SELECT footprints.id, 1000, 'Footprint', 'Footprint', REPLACE(footprints.filename, '%BASE%/img/footprints', '%FOOTPRINTS%' ), NOW(), NOW() FROM footprints " . |
|
53 | + 'INSERT IGNORE INTO attachments (element_id, type_id, name, class_name, path, last_modified, datetime_added) '. |
|
54 | + "SELECT footprints.id, 1000, 'Footprint', 'Footprint', REPLACE(footprints.filename, '%BASE%/img/footprints', '%FOOTPRINTS%' ), NOW(), NOW() FROM footprints ". |
|
55 | 55 | "WHERE footprints.filename <> ''" |
56 | 56 | ); |
57 | 57 | |
58 | 58 | //Do the same for 3D Footprints |
59 | 59 | $this->addSql( |
60 | - 'INSERT IGNORE INTO attachments (element_id, type_id, name, class_name, path, last_modified, datetime_added) ' . |
|
61 | - "SELECT footprints.id, 1001, 'Footprint 3D', 'Footprint', REPLACE(footprints.filename_3d, '%BASE%/models', '%FOOTPRINTS3D%' ), NOW(), NOW() FROM footprints " . |
|
60 | + 'INSERT IGNORE INTO attachments (element_id, type_id, name, class_name, path, last_modified, datetime_added) '. |
|
61 | + "SELECT footprints.id, 1001, 'Footprint 3D', 'Footprint', REPLACE(footprints.filename_3d, '%BASE%/models', '%FOOTPRINTS3D%' ), NOW(), NOW() FROM footprints ". |
|
62 | 62 | "WHERE footprints.filename_3d <> ''" |
63 | 63 | ); |
64 | 64 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | try { |
27 | 27 | //Check if we can use this migration method: |
28 | - $version = (int)$this->connection->fetchColumn("SELECT keyValue AS version FROM `internal` WHERE `keyName` = 'dbVersion'"); |
|
28 | + $version = (int) $this->connection->fetchColumn("SELECT keyValue AS version FROM `internal` WHERE `keyName` = 'dbVersion'"); |
|
29 | 29 | $this->abortIf($version !== 26, "This database migration can only be used if the database version is 26! Install Part-DB 0.5.6 and update database there!"); |
30 | 30 | } catch (DBALException $ex) { |
31 | 31 | //when the table was not found, then you can not use this migration |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | |
47 | 47 | /** Migrate the part locations for parts with known instock */ |
48 | 48 | $this->addSql( |
49 | - 'INSERT IGNORE INTO part_lots (id_part, id_store_location, amount, instock_unknown, last_modified, datetime_added) ' . |
|
50 | - 'SELECT parts.id, parts.id_storelocation, parts.instock, 0, NOW(), NOW() FROM parts ' . |
|
49 | + 'INSERT IGNORE INTO part_lots (id_part, id_store_location, amount, instock_unknown, last_modified, datetime_added) '. |
|
50 | + 'SELECT parts.id, parts.id_storelocation, parts.instock, 0, NOW(), NOW() FROM parts '. |
|
51 | 51 | 'WHERE parts.instock >= 0' |
52 | 52 | ); |
53 | 53 | |
54 | 54 | //Migrate part locations for parts with unknown instock |
55 | 55 | $this->addSql( |
56 | - 'INSERT IGNORE INTO part_lots (id_part, id_store_location, amount, instock_unknown, last_modified, datetime_added) ' . |
|
57 | - 'SELECT parts.id, parts.id_storelocation, 0, 1, NOW(), NOW() FROM parts ' . |
|
56 | + 'INSERT IGNORE INTO part_lots (id_part, id_store_location, amount, instock_unknown, last_modified, datetime_added) '. |
|
57 | + 'SELECT parts.id, parts.id_storelocation, 0, 1, NOW(), NOW() FROM parts '. |
|
58 | 58 | 'WHERE parts.instock = -2' |
59 | 59 | ); |
60 | 60 |
@@ -59,7 +59,7 @@ |
||
59 | 59 | $normalizers = [ |
60 | 60 | new ObjectNormalizer() |
61 | 61 | ]; |
62 | - $encoders = [ |
|
62 | + $encoders = [ |
|
63 | 63 | new JsonEncoder() |
64 | 64 | ]; |
65 | 65 | $serializer = new Serializer($normalizers, $encoders); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | protected function configureOptions(OptionsResolver $resolver) |
57 | 57 | { |
58 | 58 | $resolver->setDefaults([ |
59 | - 'limit' => 15, //Given only 15 entries |
|
59 | + 'limit' => 15, //Given only 15 entries |
|
60 | 60 | //'allowed_extensions' => [], //Filter the filenames. For example ['jpg', 'jpeg'] to only get jpegs. |
61 | 61 | //'placeholders' => Attachment::BUILTIN_PLACEHOLDER, //By default use all builtin ressources, |
62 | 62 | 'empty_returns_all' => false //Return the whole list of ressources when empty keyword is given |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | public function getListOfRessources() : array |
73 | 73 | { |
74 | 74 | try { |
75 | - return $this->cache->get('attachment_builtin_ressources', function () { |
|
75 | + return $this->cache->get('attachment_builtin_ressources', function() { |
|
76 | 76 | $results = []; |
77 | 77 | |
78 | 78 | $finder = new Finder(); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | } */ |
147 | 147 | |
148 | 148 | //Ignore case |
149 | - $regex = '/.*' . $keyword . '.*/i'; |
|
149 | + $regex = '/.*'.$keyword.'.*/i'; |
|
150 | 150 | |
151 | 151 | return preg_grep($regex, $base_list); |
152 | 152 | } |
@@ -76,13 +76,13 @@ |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | //$new_url = str_replace($request->getPathInfo(), '/' . $locale . $request->getPathInfo(), $request->getUri()); |
79 | - $new_url = $request->getUriForPath('/' . $locale . $request->getPathInfo()); |
|
79 | + $new_url = $request->getUriForPath('/'.$locale.$request->getPathInfo()); |
|
80 | 80 | |
81 | 81 | //If either mod_rewrite is not enabled or the index.php version is enforced, add index.php to the string |
82 | 82 | if (($this->enforce_index_php || !$this->checkIfModRewriteAvailable()) |
83 | 83 | && strpos($new_url, 'index.php') === false) { |
84 | 84 | //Like Request::getUriForPath only with index.php |
85 | - $new_url = $request->getSchemeAndHttpHost(). $request->getBaseUrl().'/index.php/' . $locale . $request->getPathInfo(); |
|
85 | + $new_url = $request->getSchemeAndHttpHost().$request->getBaseUrl().'/index.php/'.$locale.$request->getPathInfo(); |
|
86 | 86 | } |
87 | 87 | return $this->redirect($new_url); |
88 | 88 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'label' => $this->trans->trans('entity.edit.not_selectable'), |
97 | 97 | 'help' => $this->trans->trans('entity.edit.not_selectable.help'), |
98 | 98 | 'label_attr' => ['class' => 'checkbox-custom'], |
99 | - 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity) ]) |
|
99 | + 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]) |
|
100 | 100 | |
101 | 101 | ->add('comment', CKEditorType::class, ['required' => false, 'empty_data' => '', |
102 | 102 | 'label' => $this->trans->trans('comment.label'), |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | |
128 | 128 | //Buttons |
129 | 129 | $builder->add('save', SubmitType::class, [ |
130 | - 'label' => $is_new ? $this->trans->trans('entity.create') : $this->trans->trans('entity.edit.save'), |
|
130 | + 'label' => $is_new ? $this->trans->trans('entity.create') : $this->trans->trans('entity.edit.save'), |
|
131 | 131 | 'attr' => ['class' => $is_new ? 'btn-success' : ''], |
132 | 132 | 'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]) |
133 | 133 | ->add('reset', ResetType::class, ['label' => 'entity.edit.reset', |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | $resolver->setDefaults([ |
52 | 52 | 'filter' => 'picture', |
53 | 53 | 'attr' => ['class' => 'selectpicker'], |
54 | - 'choice_attr' => function (Options $options) { |
|
55 | - return function ($choice, $key, $value) use ($options) { |
|
54 | + 'choice_attr' => function(Options $options) { |
|
55 | + return function($choice, $key, $value) use ($options) { |
|
56 | 56 | /** @var Attachment $choice */ |
57 | 57 | $tmp = ['data-subtext' => $choice->getFilename() ?? 'URL']; |
58 | 58 | |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | }; |
65 | 65 | }, |
66 | 66 | 'choice_label' => 'name', |
67 | - 'class' => function (Options $options) { |
|
67 | + 'class' => function(Options $options) { |
|
68 | 68 | $short_class_name = (new \ReflectionClass($options['entity']))->getShortName(); |
69 | 69 | //Category becomes CategoryAttachment |
70 | - return 'App\\Entity\\Attachments\\' . $short_class_name . 'Attachment'; |
|
70 | + return 'App\\Entity\\Attachments\\'.$short_class_name.'Attachment'; |
|
71 | 71 | }, |
72 | - 'query_builder' => function (Options $options) { |
|
73 | - return function (EntityRepository $er) use ($options) { |
|
72 | + 'query_builder' => function(Options $options) { |
|
73 | + return function(EntityRepository $er) use ($options) { |
|
74 | 74 | $entity = $options['entity']; |
75 | 75 | if ($entity->getID() === null) { |
76 | 76 | //This query is always false, so we get empty results |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | if (isset($options['tag'])) { |
140 | - $builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%' . $options['tag'] . '%'); |
|
140 | + $builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%'.$options['tag'].'%'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | if (isset($options['search'])) { |
144 | 144 | $builder->AndWhere('part.name LIKE :search')->orWhere('part.description LIKE :search')->orWhere('part.comment LIKE :search') |
145 | - ->setParameter('search', '%' . $options['search'] . '%'); |
|
145 | + ->setParameter('search', '%'.$options['search'].'%'); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $dataTable |
156 | 156 | ->add('picture', TextColumn::class, [ |
157 | 157 | 'label' => '', |
158 | - 'render' => function ($value, Part $context) { |
|
158 | + 'render' => function($value, Part $context) { |
|
159 | 159 | $preview_attachment = $this->previewGenerator->getTablePreviewAttachment($context); |
160 | 160 | if ($preview_attachment === null) { |
161 | 161 | return ''; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | ]) |
172 | 172 | ->add('name', TextColumn::class, [ |
173 | 173 | 'label' => $this->translator->trans('part.table.name'), |
174 | - 'render' => function ($value, Part $context) { |
|
174 | + 'render' => function($value, Part $context) { |
|
175 | 175 | return sprintf( |
176 | 176 | '<a href="%s">%s</a>', |
177 | 177 | $this->urlGenerator->infoURL($context), |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | ]) |
201 | 201 | ->add('storelocation', TextColumn::class, [ |
202 | 202 | 'label' => $this->translator->trans('part.table.storeLocations'), |
203 | - 'render' => function ($value, Part $context) { |
|
203 | + 'render' => function($value, Part $context) { |
|
204 | 204 | $tmp = array(); |
205 | 205 | foreach ($context->getPartLots() as $lot) { |
206 | 206 | //Ignore lots without storelocation |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | ]) |
220 | 220 | ->add('amount', TextColumn::class, [ |
221 | 221 | 'label' => $this->translator->trans('part.table.amount'), |
222 | - 'render' => function ($value, Part $context) { |
|
222 | + 'render' => function($value, Part $context) { |
|
223 | 223 | $amount = $context->getAmountSum(); |
224 | 224 | return $this->amountFormatter->format($amount, $context->getPartUnit()); |
225 | 225 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | ->add('minamount', TextColumn::class, [ |
228 | 228 | 'label' => $this->translator->trans('part.table.minamount'), |
229 | 229 | 'visible' => false, |
230 | - 'render' => function ($value, Part $context) { |
|
230 | + 'render' => function($value, Part $context) { |
|
231 | 231 | return $this->amountFormatter->format($value, $context->getPartUnit()); |
232 | 232 | } |
233 | 233 | ]) |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | }, |
292 | 292 | 'entity' => Part::class, |
293 | 293 | 'criteria' => [ |
294 | - function (QueryBuilder $builder) use ($options) { |
|
294 | + function(QueryBuilder $builder) use ($options) { |
|
295 | 295 | $this->buildCriteria($builder, $options); |
296 | 296 | }, |
297 | 297 | new SearchCriteriaProvider() |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | $dataTable->add('picture', TextColumn::class, [ |
84 | 84 | 'label' => '', |
85 | - 'render' => function ($value, Attachment $context) { |
|
85 | + 'render' => function($value, Attachment $context) { |
|
86 | 86 | if ($context->isPicture() |
87 | 87 | && !$context->isExternal() |
88 | 88 | && $this->attachmentHelper->isFileExisting($context)) { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | $dataTable->add('name', TextColumn::class, [ |
102 | 102 | 'label' => $this->translator->trans('attachment.edit.name'), |
103 | - 'render' => function ($value, Attachment $context) { |
|
103 | + 'render' => function($value, Attachment $context) { |
|
104 | 104 | //Link to external source |
105 | 105 | if ($context->isExternal()) { |
106 | 106 | return sprintf( |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $dataTable->add('attachment_type', TextColumn::class, [ |
126 | 126 | 'field' => 'attachment_type.name', |
127 | - 'render' => function ($value, Attachment $context) { |
|
127 | + 'render' => function($value, Attachment $context) { |
|
128 | 128 | return sprintf( |
129 | 129 | '<a href="%s">%s</a>', |
130 | 130 | $this->entityURLGenerator->editURL($context->getAttachmentType()), |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $dataTable->add('element', TextColumn::class, [ |
137 | 137 | 'label' => $this->translator->trans('attachment.table.element'), |
138 | 138 | //'propertyPath' => 'element.name', |
139 | - 'render' => function ($value, Attachment $context) { |
|
139 | + 'render' => function($value, Attachment $context) { |
|
140 | 140 | return sprintf( |
141 | 141 | '<a href="%s">%s</a>', |
142 | 142 | $this->entityURLGenerator->infoURL($context->getElement()), |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | ]); |
151 | 151 | |
152 | 152 | $dataTable->add('filesize', TextColumn::class, [ |
153 | - 'render' => function ($value, Attachment $context) { |
|
153 | + 'render' => function($value, Attachment $context) { |
|
154 | 154 | if ($this->attachmentHelper->isFileExisting($context)) { |
155 | 155 | return $this->attachmentHelper->getHumanFileSize($context); |
156 | 156 | } |
157 | 157 | if ($context->isExternal()) { |
158 | - return '<i>' . $this->translator->trans('attachment.external') . '</i>'; |
|
158 | + return '<i>'.$this->translator->trans('attachment.external').'</i>'; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return sprintf( |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | $dataTable->createAdapter(ORMAdapter::class, [ |
216 | 216 | 'entity' => Attachment::class, |
217 | - 'query' => function (QueryBuilder $builder) { |
|
217 | + 'query' => function(QueryBuilder $builder) { |
|
218 | 218 | $this->getQuery($builder); |
219 | 219 | }, |
220 | 220 | ]); |