@@ -138,7 +138,7 @@ |
||
138 | 138 | */ |
139 | 139 | public function getIDString(): string |
140 | 140 | { |
141 | - return 'P' . sprintf('%06d', $this->getID()); |
|
141 | + return 'P'.sprintf('%06d', $this->getID()); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $attachments = $form['attachments']; |
91 | 91 | foreach ($attachments as $attachment) { |
92 | 92 | /** @var $attachment FormInterface */ |
93 | - $attachmentHelper->upload( $attachment->getData(), $attachment['file']->getData()); |
|
93 | + $attachmentHelper->upload($attachment->getData(), $attachment['file']->getData()); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $this->addFlash('info', $translator->trans('part.edited_flash')); |
100 | 100 | //Reload form, so the SIUnitType entries use the new part unit |
101 | 101 | $form = $this->createForm(PartBaseType::class, $part); |
102 | - } elseif ($form->isSubmitted() && ! $form->isValid()) { |
|
102 | + } elseif ($form->isSubmitted() && !$form->isValid()) { |
|
103 | 103 | $this->addFlash('error', $translator->trans('part.edited_flash.invalid')); |
104 | 104 | } |
105 | 105 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | { |
122 | 122 | $this->denyAccessUnlessGranted('delete', $part); |
123 | 123 | |
124 | - if ($this->isCsrfTokenValid('delete' . $part->getId(), $request->request->get('_token'))) { |
|
124 | + if ($this->isCsrfTokenValid('delete'.$part->getId(), $request->request->get('_token'))) { |
|
125 | 125 | $entityManager = $this->getDoctrine()->getManager(); |
126 | 126 | |
127 | 127 | //Remove part |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $attachments = $form['attachments']; |
166 | 166 | foreach ($attachments as $attachment) { |
167 | 167 | /** @var $attachment FormInterface */ |
168 | - $attachmentHelper->upload( $attachment->getData(), $attachment['file']->getData()); |
|
168 | + $attachmentHelper->upload($attachment->getData(), $attachment['file']->getData()); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | $em->persist($new_part); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | return $this->redirectToRoute('part_edit', ['id' => $new_part->getID()]); |
176 | 176 | } |
177 | 177 | |
178 | - if ($form->isSubmitted() && ! $form->isValid()) { |
|
178 | + if ($form->isSubmitted() && !$form->isValid()) { |
|
179 | 179 | $this->addFlash('error', $translator->trans('part.created_flash.invalid')); |
180 | 180 | } |
181 | 181 |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | //Show permissions to user |
143 | - $builder = $this->createFormBuilder()->add('permissions',PermissionsType::class, [ |
|
143 | + $builder = $this->createFormBuilder()->add('permissions', PermissionsType::class, [ |
|
144 | 144 | 'mapped' => false, |
145 | 145 | 'disabled' => true, |
146 | 146 | 'inherit' => true, |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | $user = $this->getUser(); |
166 | 166 | |
167 | - if(!$user instanceof User) { |
|
167 | + if (!$user instanceof User) { |
|
168 | 168 | return new \RuntimeException("This controller only works only for Part-DB User objects!"); |
169 | 169 | } |
170 | 170 |
@@ -68,7 +68,7 @@ |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | //$new_url = str_replace($request->getPathInfo(), '/' . $locale . $request->getPathInfo(), $request->getUri()); |
71 | - $new_url = $request->getUriForPath('/' . $locale . $request->getPathInfo()); |
|
71 | + $new_url = $request->getUriForPath('/'.$locale.$request->getPathInfo()); |
|
72 | 72 | return $this->redirect($new_url); |
73 | 73 | } |
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | protected function configureOptions(OptionsResolver $resolver) |
53 | 53 | { |
54 | 54 | $resolver->setDefaults([ |
55 | - 'show_prefix' => function (Options $options) { |
|
55 | + 'show_prefix' => function(Options $options) { |
|
56 | 56 | if ($options['measurement_unit'] !== null) { |
57 | 57 | /** @var MeasurementUnit $unit */ |
58 | 58 | $unit = $options['measurement_unit']; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | return false; |
62 | 62 | }, |
63 | - 'is_integer' => function (Options $options) { |
|
63 | + 'is_integer' => function(Options $options) { |
|
64 | 64 | if ($options['measurement_unit'] !== null) { |
65 | 65 | /** @var MeasurementUnit $unit */ |
66 | 66 | $unit = $options['measurement_unit']; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | return true; |
70 | 70 | }, |
71 | - 'unit' => function (Options $options) { |
|
71 | + 'unit' => function(Options $options) { |
|
72 | 72 | if ($options['measurement_unit'] !== null) { |
73 | 73 | /** @var MeasurementUnit $unit */ |
74 | 74 | $unit = $options['measurement_unit']; |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | return ''; |
78 | 78 | }, |
79 | 79 | 'decimals' => 2, |
80 | - 'error_mapping' => [ '.' => 'value'] |
|
80 | + 'error_mapping' => ['.' => 'value'] |
|
81 | 81 | ]); |
82 | 82 | |
83 | 83 | $resolver->setAllowedTypes('decimals', 'int'); |
84 | 84 | |
85 | - $resolver->setNormalizer('decimals', function (Options $options, $value) { |
|
85 | + $resolver->setNormalizer('decimals', function(Options $options, $value) { |
|
86 | 86 | // If the unit is integer based, then dont show any decimals |
87 | 87 | if ($options['is_integer']) { |
88 | 88 | return 0; |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | |
126 | 126 | //Otherwise just output it |
127 | 127 | if (!empty($options['unit'])) { |
128 | - $format_string = '%.' . $options['decimals'] . 'f ' . $options['unit']; |
|
128 | + $format_string = '%.'.$options['decimals'].'f '.$options['unit']; |
|
129 | 129 | } else { //Dont add space after number if no unit was specified |
130 | - $format_string = '%.' . $options['decimals'] . 'f'; |
|
130 | + $format_string = '%.'.$options['decimals'].'f'; |
|
131 | 131 | } |
132 | 132 | return sprintf($format_string, $value); |
133 | 133 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function getPrefixByMagnitude(int $magnitude) : array |
57 | 57 | { |
58 | - $prefixes_pos = ['' ,'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']; |
|
59 | - $prefixes_neg = ['' ,'m', 'μ', 'n', 'p', 'f', 'a', 'z', 'y']; |
|
58 | + $prefixes_pos = ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']; |
|
59 | + $prefixes_neg = ['', 'm', 'μ', 'n', 'p', 'f', 'a', 'z', 'y']; |
|
60 | 60 | |
61 | 61 | if ($magnitude >= 0) { |
62 | 62 | $nearest = (int) floor(abs($magnitude) / 3); |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | $value /= $divisor; |
106 | 106 | //Build the format string, e.g.: %.2d km |
107 | 107 | if ($unit !== '' || $symbol !== '') { |
108 | - $format_string = '%.' . $decimals . 'f ' . $symbol . $unit; |
|
108 | + $format_string = '%.'.$decimals.'f '.$symbol.$unit; |
|
109 | 109 | } else { |
110 | - $format_string = '%.' . $decimals . 'f'; |
|
110 | + $format_string = '%.'.$decimals.'f'; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return sprintf($format_string, $value); |
@@ -50,15 +50,15 @@ |
||
50 | 50 | |
51 | 51 | //Add a attachment for each footprint attachment |
52 | 52 | $this->addSql( |
53 | - 'INSERT 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 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 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 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 |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $attachments = $form['attachments']; |
102 | 102 | foreach ($attachments as $attachment) { |
103 | 103 | /** @var $attachment FormInterface */ |
104 | - $this->attachmentHelper->upload( $attachment->getData(), $attachment['file']->getData()); |
|
104 | + $this->attachmentHelper->upload($attachment->getData(), $attachment['file']->getData()); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | $em->persist($entity); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | //Rebuild form, so it is based on the updated data. Important for the parent field! |
112 | 112 | //We can not use dynamic form events here, because the parent entity list is build from database! |
113 | 113 | $form = $this->createForm($this->form_class, $entity, ['attachment_class' => $this->attachment_class]); |
114 | - } elseif ($form->isSubmitted() && ! $form->isValid()) { |
|
114 | + } elseif ($form->isSubmitted() && !$form->isValid()) { |
|
115 | 115 | $this->addFlash('error', $this->translator->trans('entity.edit_flash.invalid')); |
116 | 116 | } |
117 | 117 | |
@@ -146,17 +146,17 @@ discard block |
||
146 | 146 | $attachments = $form['attachments']; |
147 | 147 | foreach ($attachments as $attachment) { |
148 | 148 | /** @var $attachment FormInterface */ |
149 | - $this->attachmentHelper->upload( $attachment->getData(), $attachment['file']->getData()); |
|
149 | + $this->attachmentHelper->upload($attachment->getData(), $attachment['file']->getData()); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | $em->persist($new_entity); |
153 | 153 | $em->flush(); |
154 | 154 | $this->addFlash('success', $this->translator->trans('entity.created_flash')); |
155 | 155 | |
156 | - return $this->redirectToRoute($this->route_base . '_edit', ['id' => $new_entity->getID()]); |
|
156 | + return $this->redirectToRoute($this->route_base.'_edit', ['id' => $new_entity->getID()]); |
|
157 | 157 | } |
158 | 158 | |
159 | - if ($form->isSubmitted() && ! $form->isValid()) { |
|
159 | + if ($form->isSubmitted() && !$form->isValid()) { |
|
160 | 160 | $this->addFlash('error', $this->translator->trans('entity.created_flash.invalid')); |
161 | 161 | } |
162 | 162 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | foreach ($errors as $name => $error) { |
178 | 178 | /** @var $error ConstraintViolationList */ |
179 | - $this->addFlash('error', $name . ':' . $error); |
|
179 | + $this->addFlash('error', $name.':'.$error); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | //Show errors to user: |
196 | 196 | foreach ($errors as $name => $error) { |
197 | 197 | /** @var $error ConstraintViolationList */ |
198 | - $this->addFlash('error', $name . ':' . $error); |
|
198 | + $this->addFlash('error', $name.':'.$error); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $this->addFlash('success', 'attachment_type.deleted'); |
240 | 240 | } |
241 | 241 | |
242 | - return $this->redirectToRoute($this->route_base . '_new'); |
|
242 | + return $this->redirectToRoute($this->route_base.'_new'); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | protected function _exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request) |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | |
251 | 251 | $entities = $em->getRepository($this->entity_class)->findAll(); |
252 | 252 | |
253 | - return $exporter->exportEntityFromRequest($entities,$request); |
|
253 | + return $exporter->exportEntityFromRequest($entities, $request); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | protected function _exportEntity(NamedDBElement $entity, EntityExporter $exporter, Request $request) |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | if ($fs->isAbsolutePath($tmp_base_path)) { |
75 | 75 | $this->base_path = $tmp_base_path; |
76 | 76 | } else { |
77 | - $this->base_path = realpath($kernel->getProjectDir() . DIRECTORY_SEPARATOR . $tmp_base_path); |
|
77 | + $this->base_path = realpath($kernel->getProjectDir().DIRECTORY_SEPARATOR.$tmp_base_path); |
|
78 | 78 | } |
79 | 79 | |
80 | - $this->footprints_path = realpath($kernel->getProjectDir() . "/public/img/footprints"); |
|
80 | + $this->footprints_path = realpath($kernel->getProjectDir()."/public/img/footprints"); |
|
81 | 81 | //TODO |
82 | 82 | $this->footprints_3d_path = "TODO"; |
83 | 83 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $placeholder_path = str_replace($placeholders, $targets, $placeholder_path); |
122 | 122 | |
123 | 123 | //Normalize path and remove .. |
124 | - $placeholder_path = str_replace(['\\','..'], ['/',''], $placeholder_path); |
|
124 | + $placeholder_path = str_replace(['\\', '..'], ['/', ''], $placeholder_path); |
|
125 | 125 | |
126 | 126 | return $placeholder_path; |
127 | 127 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | $sz = 'BKMGTP'; |
222 | 222 | $factor = (int) floor((strlen($bytes) - 1) / 3); |
223 | - return sprintf("%.{$decimals}f", $bytes / 1024 ** $factor) . @$sz[$factor]; |
|
223 | + return sprintf("%.{$decimals}f", $bytes / 1024 ** $factor).@$sz[$factor]; |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | MeasurementUnitAttachment::class => 'measurement_unit', StorelocationAttachment::class => 'storelocation', |
238 | 238 | SupplierAttachment::class => 'supplier', UserAttachment::class => 'user']; |
239 | 239 | |
240 | - $path = $this->base_path . DIRECTORY_SEPARATOR . $mapping[get_class($attachment)] . DIRECTORY_SEPARATOR . $attachment->getElement()->getID(); |
|
240 | + $path = $this->base_path.DIRECTORY_SEPARATOR.$mapping[get_class($attachment)].DIRECTORY_SEPARATOR.$attachment->getElement()->getID(); |
|
241 | 241 | return $path; |
242 | 242 | } |
243 | 243 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | //Sanatize filename |
260 | 260 | $originalFilename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME); |
261 | - $newFilename = $attachment->getName() . '-' . uniqid('', false) . '.' . $file->guessExtension(); |
|
261 | + $newFilename = $attachment->getName().'-'.uniqid('', false).'.'.$file->guessExtension(); |
|
262 | 262 | |
263 | 263 | //Move our temporay attachment to its final location |
264 | 264 | $file_path = $file->move($folder, $newFilename)->getRealPath(); |