@@ -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) |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $io = new SymfonyStyle($input, $output); |
50 | 50 | |
51 | 51 | $mediaPath = $this->pathResolver->getMediaPath(); |
52 | - $io->note("The media path is " . $mediaPath); |
|
52 | + $io->note("The media path is ".$mediaPath); |
|
53 | 53 | |
54 | 54 | $finder = new Finder(); |
55 | 55 | //We look for files in the media folder only |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function removeEmptySubFolders($path) |
108 | 108 | { |
109 | - $empty=true; |
|
110 | - foreach (glob($path . DIRECTORY_SEPARATOR . "*") as $file) |
|
109 | + $empty = true; |
|
110 | + foreach (glob($path.DIRECTORY_SEPARATOR."*") as $file) |
|
111 | 111 | { |
112 | 112 | $empty &= is_dir($file) && $this->removeEmptySubFolders($file); |
113 | 113 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | //Otherwise prepend the project path |
117 | - $tmp = realpath($this->project_dir . DIRECTORY_SEPARATOR . $param_path); |
|
117 | + $tmp = realpath($this->project_dir.DIRECTORY_SEPARATOR.$param_path); |
|
118 | 118 | |
119 | 119 | //If path does not exist then disable the placeholder |
120 | 120 | if ($tmp === false) { |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | foreach ($array as $item) { |
140 | 140 | $item = str_replace(['\\'], ['/'], $item); |
141 | - $ret[] = '/' . preg_quote($item, '/') . '/'; |
|
141 | + $ret[] = '/'.preg_quote($item, '/').'/'; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | return $ret; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | //Older path entries are given via %BASE% which was the project root |
158 | 158 | |
159 | 159 | $count = 0; |
160 | - $placeholder_path = preg_replace($this->placeholders_regex, $this->pathes, $placeholder_path,-1,$count); |
|
160 | + $placeholder_path = preg_replace($this->placeholders_regex, $this->pathes, $placeholder_path, -1, $count); |
|
161 | 161 | |
162 | 162 | //A valid placeholder can have only one |
163 | 163 | if ($count !== 1) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | $sz = 'BKMGTP'; |
149 | 149 | $factor = (int) floor((strlen($bytes) - 1) / 3); |
150 | - return sprintf("%.{$decimals}f", $bytes / 1024 ** $factor) . @$sz[$factor]; |
|
150 | + return sprintf("%.{$decimals}f", $bytes / 1024 ** $factor).@$sz[$factor]; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | MeasurementUnitAttachment::class => 'measurement_unit', StorelocationAttachment::class => 'storelocation', |
165 | 165 | SupplierAttachment::class => 'supplier', UserAttachment::class => 'user']; |
166 | 166 | |
167 | - $path = $this->base_path . DIRECTORY_SEPARATOR . $mapping[get_class($attachment)] . DIRECTORY_SEPARATOR . $attachment->getElement()->getID(); |
|
167 | + $path = $this->base_path.DIRECTORY_SEPARATOR.$mapping[get_class($attachment)].DIRECTORY_SEPARATOR.$attachment->getElement()->getID(); |
|
168 | 168 | return $path; |
169 | 169 | } |
170 | 170 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | //Sanatize filename |
187 | 187 | $originalFilename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME); |
188 | - $newFilename = $attachment->getName() . '-' . uniqid('', false) . '.' . $file->guessExtension(); |
|
188 | + $newFilename = $attachment->getName().'-'.uniqid('', false).'.'.$file->guessExtension(); |
|
189 | 189 | |
190 | 190 | //Move our temporay attachment to its final location |
191 | 191 | $file_path = $file->move($folder, $newFilename)->getRealPath(); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | { |
23 | 23 | try { |
24 | 24 | //Check if we can use this migration method: |
25 | - $version = (int)$this->connection->fetchColumn("SELECT keyValue AS version FROM `internal` WHERE `keyName` = 'dbVersion'"); |
|
25 | + $version = (int) $this->connection->fetchColumn("SELECT keyValue AS version FROM `internal` WHERE `keyName` = 'dbVersion'"); |
|
26 | 26 | $this->skipIf(true, "Old Part-DB Database detected! Continue with upgrade..."); |
27 | 27 | } catch (DBALException $ex) { |
28 | 28 | //when the table was not found, we can proceed, because we have an empty DB! |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | |
87 | 87 | //Create table for user logs: |
88 | - $sql = $updateSteps[] = "CREATE TABLE `log` ". |
|
88 | + $sql = $updateSteps[] = "CREATE TABLE `log` ". |
|
89 | 89 | "( `id` INT NOT NULL AUTO_INCREMENT , `datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP() ,". |
90 | 90 | " `id_user` INT NOT NULL ,". |
91 | 91 | " `level` TINYINT NOT NULL ,". |
@@ -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 | } |