@@ -15,13 +15,13 @@ |
||
| 15 | 15 | return [ |
| 16 | 16 | new Twig_SimpleTest( |
| 17 | 17 | 'admin', |
| 18 | - function (BaseUser $user) { |
|
| 18 | + function(BaseUser $user) { |
|
| 19 | 19 | return $user instanceof Admin; |
| 20 | 20 | } |
| 21 | 21 | ), |
| 22 | 22 | new Twig_SimpleTest( |
| 23 | 23 | 'user', |
| 24 | - function (BaseUser $user) { |
|
| 24 | + function(BaseUser $user) { |
|
| 25 | 25 | return $user instanceof User; |
| 26 | 26 | } |
| 27 | 27 | ), |
@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | // cache the result when we're in production environment |
| 39 | 39 | if ($this->container->get('kernel')->getEnvironment() === 'prod') { |
| 40 | - $webDir = $this->get('kernel')->getRootDir() . '/../web/'; |
|
| 40 | + $webDir = $this->get('kernel')->getRootDir().'/../web/'; |
|
| 41 | 41 | $fs = new Filesystem(); |
| 42 | 42 | $fs->dumpfile( |
| 43 | - $webDir . $request->getLocale() . '/locale.json', |
|
| 43 | + $webDir.$request->getLocale().'/locale.json', |
|
| 44 | 44 | json_encode($translations) |
| 45 | 45 | ); |
| 46 | 46 | } |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | $dirs = []; |
| 88 | 88 | foreach ($this->container->getParameter('kernel.bundles') as $bundle) { |
| 89 | 89 | $reflection = new \ReflectionClass($bundle); |
| 90 | - if (is_dir($dir = dirname($reflection->getFilename()) . '/Resources/translations')) { |
|
| 90 | + if (is_dir($dir = dirname($reflection->getFilename()).'/Resources/translations')) { |
|
| 91 | 91 | $dirs[] = $dir; |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if (is_dir($dir = $this->container->getParameter('kernel.root_dir') . '/Resources/translations')) { |
|
| 95 | + if (is_dir($dir = $this->container->getParameter('kernel.root_dir').'/Resources/translations')) { |
|
| 96 | 96 | $dirs[] = $dir; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -51,6 +51,6 @@ |
||
| 51 | 51 | |
| 52 | 52 | private function convertToJsFormat(string $intlFormat): string |
| 53 | 53 | { |
| 54 | - return str_replace(['y', 'MM', 'dd', 'H', 'i'], ['YYYY','MM', 'DD', 'HH', 'mm'], $intlFormat); |
|
| 54 | + return str_replace(['y', 'MM', 'dd', 'H', 'i'], ['YYYY', 'MM', 'DD', 'HH', 'mm'], $intlFormat); |
|
| 55 | 55 | } |
| 56 | 56 | } |
@@ -52,6 +52,6 @@ |
||
| 52 | 52 | |
| 53 | 53 | private function convertToJsFormat(string $intlFormat): string |
| 54 | 54 | { |
| 55 | - return str_replace(['y', 'MM', 'dd'], ['YYYY','MM', 'DD'], $intlFormat); |
|
| 55 | + return str_replace(['y', 'MM', 'dd'], ['YYYY', 'MM', 'DD'], $intlFormat); |
|
| 56 | 56 | } |
| 57 | 57 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $builder |
| 39 | 39 | ->addEventListener( |
| 40 | 40 | FormEvents::PRE_SET_DATA, |
| 41 | - function (FormEvent $event) use ($options) { |
|
| 41 | + function(FormEvent $event) use ($options) { |
|
| 42 | 42 | $imageIsEmpty = ($event->getData() === null || empty($event->getData()->getFileName())); |
| 43 | 43 | $required = $imageIsEmpty && $options['required']; |
| 44 | 44 | $fileFieldOptions = [ |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | ) |
| 59 | 59 | ->addModelTransformer( |
| 60 | 60 | new CallbackTransformer( |
| 61 | - function (AbstractImage $image = null) { |
|
| 61 | + function(AbstractImage $image = null) { |
|
| 62 | 62 | return $image; |
| 63 | 63 | }, |
| 64 | - function ($image) use ($options) { |
|
| 64 | + function($image) use ($options) { |
|
| 65 | 65 | if (!$image instanceof AbstractImage && !$image instanceof stdClass) { |
| 66 | 66 | throw new TransformationFailedException('Invalid class for the image'); |
| 67 | 67 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $resolver->setDefaults( |
| 96 | 96 | [ |
| 97 | 97 | 'data_class' => AbstractImage::class, |
| 98 | - 'empty_data' => function () { |
|
| 98 | + 'empty_data' => function() { |
|
| 99 | 99 | return new class extends StdClass { |
| 100 | 100 | /** @var UploadedFile */ |
| 101 | 101 | protected $file; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | array_map( |
| 172 | - function ($optionName) use ($options, &$view) { |
|
| 172 | + function($optionName) use ($options, &$view) { |
|
| 173 | 173 | if (array_key_exists($optionName, $options) && !empty($options[$optionName])) { |
| 174 | 174 | $view->vars[$optionName] = $options[$optionName]; |
| 175 | 175 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $builder |
| 39 | 39 | ->addEventListener( |
| 40 | 40 | FormEvents::PRE_SET_DATA, |
| 41 | - function (FormEvent $event) use ($options) { |
|
| 41 | + function(FormEvent $event) use ($options) { |
|
| 42 | 42 | $fileIsEmpty = ($event->getData() === null || empty($event->getData()->getFileName())); |
| 43 | 43 | $required = $fileIsEmpty && $options['required']; |
| 44 | 44 | $fileFieldOptions = [ |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | ) |
| 59 | 59 | ->addModelTransformer( |
| 60 | 60 | new CallbackTransformer( |
| 61 | - function (AbstractFile $file = null) { |
|
| 61 | + function(AbstractFile $file = null) { |
|
| 62 | 62 | return $file; |
| 63 | 63 | }, |
| 64 | - function ($file) use ($options) { |
|
| 64 | + function($file) use ($options) { |
|
| 65 | 65 | if (!$file instanceof AbstractFile && !$file instanceof stdClass) { |
| 66 | 66 | throw new TransformationFailedException('Invalid class for the file'); |
| 67 | 67 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | 'data_class' => AbstractFile::class, |
| 98 | 98 | 'preview_label' => 'forms.labels.viewCurrentFile', |
| 99 | 99 | 'remove_file_label' => 'forms.labels.removeFile', |
| 100 | - 'empty_data' => function () { |
|
| 100 | + 'empty_data' => function() { |
|
| 101 | 101 | return new class extends StdClass |
| 102 | 102 | { |
| 103 | 103 | /** @var UploadedFile */ |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | $view->vars['preview_url'] = $form->getData()->getWebPath(); |
| 170 | 170 | } |
| 171 | 171 | array_map( |
| 172 | - function ($optionName) use ($options, &$view) { |
|
| 172 | + function($optionName) use ($options, &$view) { |
|
| 173 | 173 | if (array_key_exists($optionName, $options) && !empty($options[$optionName])) { |
| 174 | 174 | $view->vars[$optionName] = $options[$optionName]; |
| 175 | 175 | } |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | public function getAbsolutePath(): ?string |
| 56 | 56 | { |
| 57 | - return $this->fileName === null ? null : $this->getUploadRootDir() . '/' . $this->fileName; |
|
| 57 | + return $this->fileName === null ? null : $this->getUploadRootDir().'/'.$this->fileName; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public function getWebPath(): string |
| 61 | 61 | { |
| 62 | 62 | $file = $this->getAbsolutePath(); |
| 63 | 63 | if (is_file($file) && file_exists($file)) { |
| 64 | - return '/' . $this->getUploadDir() . '/' . $this->fileName; |
|
| 64 | + return '/'.$this->getUploadDir().'/'.$this->fileName; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return ''; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | protected function getUploadRootDir(): string |
| 71 | 71 | { |
| 72 | 72 | // the absolute directory path where uploaded documents should be saved |
| 73 | - return __DIR__ . '/../../../../web/files/' . $this->getTrimmedUploadDir(); |
|
| 73 | + return __DIR__.'/../../../../web/files/'.$this->getTrimmedUploadDir(); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | protected function getTrimmedUploadDir(): string |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | // do whatever you want to generate a unique name |
| 145 | 145 | $filename = sha1(uniqid(mt_rand(), true)); |
| 146 | 146 | if ($this->namePrefix !== null) { |
| 147 | - $filename = Urlizer::urlize($this->namePrefix) . '_' . $filename; |
|
| 147 | + $filename = Urlizer::urlize($this->namePrefix).'_'.$filename; |
|
| 148 | 148 | } |
| 149 | - $this->fileName = $filename . '.' . $this->getFile()->guessExtension(); |
|
| 149 | + $this->fileName = $filename.'.'.$this->getFile()->guessExtension(); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | protected function removeOldFile(): void |
| 177 | 177 | { |
| 178 | 178 | // delete the old file |
| 179 | - $oldFile = $this->getUploadRootDir() . '/' . $this->oldFileName; |
|
| 179 | + $oldFile = $this->getUploadRootDir().'/'.$this->oldFileName; |
|
| 180 | 180 | if (is_file($oldFile) && file_exists($oldFile)) { |
| 181 | 181 | unlink($oldFile); |
| 182 | 182 | } |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | return (string) $this->fileName; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - public static function fromString(?string $fileName): ?self |
|
| 215 | + public static function fromString(?string $fileName) : ?self |
|
| 216 | 216 | { |
| 217 | 217 | return $fileName !== null ? new static($fileName) : null; |
| 218 | 218 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | $file = $this->getAbsolutePath(); |
| 31 | 31 | |
| 32 | 32 | if (is_file($file) && file_exists($file)) { |
| 33 | - return $webPath . $this->fileName; |
|
| 33 | + return $webPath.$this->fileName; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | return static::FALLBACK_IMAGE; |