@@ -145,6 +145,9 @@ |
||
| 145 | 145 | return $this->fileSystem->has($path); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | + /** |
|
| 149 | + * @param string $customStyleString |
|
| 150 | + */ |
|
| 148 | 151 | public function createCustomStyledImage(ResponsiveImageInterface $image, $customStyleString, $forceGenerate = false) |
| 149 | 152 | { |
| 150 | 153 | // @TODO: To avoid creating images, that already exist, check if it exists, need a way to disable this checking |
@@ -123,8 +123,7 @@ |
||
| 123 | 123 | { |
| 124 | 124 | if (!empty($style)) { |
| 125 | 125 | $path = $this->styleManager->getStylePath($image, $style); |
| 126 | - } |
|
| 127 | - else { |
|
| 126 | + } else { |
|
| 128 | 127 | $path = $image->getPath(); |
| 129 | 128 | } |
| 130 | 129 | $this->fileSystem->delete($path); |
@@ -60,6 +60,9 @@ |
||
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | + /** |
|
| 64 | + * @param string $src |
|
| 65 | + */ |
|
| 63 | 66 | public function setImageAttributes(ResponsiveImageInterface $image, $styleName = null, $src = null) |
| 64 | 67 | { |
| 65 | 68 | // Use the style data to figure out the width and height for this image |
@@ -98,8 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | if (empty($coordinates)) { |
| 100 | 100 | $geometry = new CoordinateGeometry(0, 0, $image->getWidth(), $image->getHeight()); |
| 101 | - } |
|
| 102 | - else { |
|
| 101 | + } else { |
|
| 103 | 102 | $cropCoordinates = explode(':', $coordinates)[0]; |
| 104 | 103 | $points = explode(',', $cropCoordinates); |
| 105 | 104 | $geometry = new CoordinateGeometry( |
@@ -145,8 +144,7 @@ discard block |
||
| 145 | 144 | if (strpos($styleName, 'custom_') === 0) { |
| 146 | 145 | return $this->styleDataFromCustomStyleString($styleName); |
| 147 | 146 | } |
| 148 | - } |
|
| 149 | - else { |
|
| 147 | + } else { |
|
| 150 | 148 | return $this->styles[$styleName]; |
| 151 | 149 | } |
| 152 | 150 | |
@@ -240,8 +238,7 @@ discard block |
||
| 240 | 238 | // We need to derive the width. |
| 241 | 239 | $scaledDimensions = $this->getScaledDimensions($image, $styleData); |
| 242 | 240 | $width = $scaledDimensions['width']; |
| 243 | - } |
|
| 244 | - else { |
|
| 241 | + } else { |
|
| 245 | 242 | $width = $styleData['width']; |
| 246 | 243 | } |
| 247 | 244 | |
@@ -268,8 +265,7 @@ discard block |
||
| 268 | 265 | |
| 269 | 266 | if (!empty($styleName)) { |
| 270 | 267 | $stylePath = $this->buildStylePath($styleName, $filename); |
| 271 | - } |
|
| 272 | - else { |
|
| 268 | + } else { |
|
| 273 | 269 | $stylePath = $filename; |
| 274 | 270 | } |
| 275 | 271 | |
@@ -60,6 +60,9 @@ |
||
| 60 | 60 | return $this->path; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | + /** |
|
| 64 | + * @param string $path |
|
| 65 | + */ |
|
| 63 | 66 | public function setPath($path) |
| 64 | 67 | { |
| 65 | 68 | $this->path = $path; |
@@ -77,6 +77,9 @@ |
||
| 77 | 77 | return $exitCode; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | + /** |
|
| 81 | + * @param string $serviceName |
|
| 82 | + */ |
|
| 80 | 83 | protected function getService($serviceName) |
| 81 | 84 | { |
| 82 | 85 | if (empty($this->testKernel)) { |
@@ -47,8 +47,7 @@ |
||
| 47 | 47 | foreach ($files as $file) { |
| 48 | 48 | if (is_dir($file)) { |
| 49 | 49 | self::deleteDirectory($file); |
| 50 | - } |
|
| 51 | - else { |
|
| 50 | + } else { |
|
| 52 | 51 | unlink($file); |
| 53 | 52 | } |
| 54 | 53 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | - * @return array |
|
| 54 | + * @return \Twig_SimpleFunction[] |
|
| 55 | 55 | */ |
| 56 | 56 | public function getFunctions() |
| 57 | 57 | { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @param $pictureSetName |
| 102 | 102 | * @param $selector |
| 103 | 103 | * |
| 104 | - * @return mixed|string |
|
| 104 | + * @return string |
|
| 105 | 105 | */ |
| 106 | 106 | public function generateBackgroundImage(\Twig_Environment $environment, ResponsiveImageInterface $image, $pictureSetName, $selector) |
| 107 | 107 | { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * @param $pictureSetName |
| 126 | 126 | * @param bool $generate |
| 127 | 127 | * |
| 128 | - * @return mixed|string |
|
| 128 | + * @return string |
|
| 129 | 129 | */ |
| 130 | 130 | public function generatePictureImage(\Twig_Environment $environment, ResponsiveImageInterface $image, $pictureSetName, $generate = false) |
| 131 | 131 | { |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @internal |
| 147 | 147 | * |
| 148 | 148 | * @param array $data |
| 149 | - * @param array $keys |
|
| 149 | + * @param string[] $keys |
|
| 150 | 150 | */ |
| 151 | 151 | private function convertPathsToUrls(array &$data, array $keys) |
| 152 | 152 | { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * @param $pictureSetName |
| 189 | 189 | * @param bool $generate |
| 190 | 190 | * |
| 191 | - * @return mixed|string |
|
| 191 | + * @return string |
|
| 192 | 192 | */ |
| 193 | 193 | public function generateSizesImage(\Twig_Environment $environment, ResponsiveImageInterface $image, $pictureSetName, $generate = false) |
| 194 | 194 | { |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * @param null $styleName |
| 217 | 217 | * @param bool $generate |
| 218 | 218 | * |
| 219 | - * @return mixed|string |
|
| 219 | + * @return string |
|
| 220 | 220 | */ |
| 221 | 221 | public function generateStyledImage(\Twig_Environment $environment, ResponsiveImageInterface $image, $styleName = null, $generate = false) |
| 222 | 222 | { |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param string $width |
| 232 | 232 | * @param null $height |
| 233 | 233 | * |
| 234 | - * @return mixed|string |
|
| 234 | + * @return string |
|
| 235 | 235 | */ |
| 236 | 236 | public function cropImage(\Twig_Environment $environment, ResponsiveImageInterface $image, $width = '', $height = null) |
| 237 | 237 | { |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * @param string $width |
| 251 | 251 | * @param string $height |
| 252 | 252 | * |
| 253 | - * @return mixed|string |
|
| 253 | + * @return string |
|
| 254 | 254 | */ |
| 255 | 255 | public function scaleImage(\Twig_Environment $environment, ResponsiveImageInterface $image, $width = '', $height = '') |
| 256 | 256 | { |
@@ -266,9 +266,9 @@ discard block |
||
| 266 | 266 | /** |
| 267 | 267 | * @param \Twig_Environment $environment |
| 268 | 268 | * @param ResponsiveImageInterface $image |
| 269 | - * @param null $styleName |
|
| 269 | + * @param null|string $styleName |
|
| 270 | 270 | * |
| 271 | - * @return mixed|string |
|
| 271 | + * @return string |
|
| 272 | 272 | */ |
| 273 | 273 | protected function renderImage(\Twig_Environment $environment, ResponsiveImageInterface $image, $styleName = null) |
| 274 | 274 | { |
@@ -157,8 +157,7 @@ discard block |
||
| 157 | 157 | $subData[$item] = $this->createPublicFileUrl($path); |
| 158 | 158 | } |
| 159 | 159 | $data[$key] = $subData; |
| 160 | - } |
|
| 161 | - else { |
|
| 160 | + } else { |
|
| 162 | 161 | $data[$key] = $this->createPublicFileUrl($data[$key]); |
| 163 | 162 | } |
| 164 | 163 | } |
@@ -274,8 +273,7 @@ discard block |
||
| 274 | 273 | { |
| 275 | 274 | if (!empty($styleName)) { |
| 276 | 275 | $path = $this->styleManager->getStylePath($image, $styleName); |
| 277 | - } |
|
| 278 | - else { |
|
| 276 | + } else { |
|
| 279 | 277 | $path = $image->getPath(); |
| 280 | 278 | } |
| 281 | 279 | |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | $response->setExpires(date_create()->modify('+1 years')); |
| 59 | 59 | |
| 60 | 60 | $response->setCallback( |
| 61 | - function () use ($stream) { |
|
| 61 | + function() use ($stream) { |
|
| 62 | 62 | if (ftell($stream['stream']) !== 0) { |
| 63 | 63 | rewind($stream['stream']); |
| 64 | 64 | } |
@@ -68,12 +68,10 @@ |
||
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | 70 | return $response; |
| 71 | - } |
|
| 72 | - else { |
|
| 71 | + } else { |
|
| 73 | 72 | throw $this->createNotFoundException('Derived image could not be created'); |
| 74 | 73 | } |
| 75 | - } |
|
| 76 | - else { |
|
| 74 | + } else { |
|
| 77 | 75 | throw $this->createNotFoundException('The file does not exist'); |
| 78 | 76 | } |
| 79 | 77 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | $question->setValidator(['Sensio\Bundle\GeneratorBundle\Command\Validators', 'validateBundleName']); |
| 155 | 155 | $question->setNormalizer( |
| 156 | - function ($value) { |
|
| 156 | + function($value) { |
|
| 157 | 157 | return $value ? trim($value) : ''; |
| 158 | 158 | } |
| 159 | 159 | ); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | $input->getOption('entity_name') |
| 177 | 177 | ); |
| 178 | 178 | $question->setValidator( |
| 179 | - function ($answer) { |
|
| 179 | + function($answer) { |
|
| 180 | 180 | // Should only contain letters. |
| 181 | 181 | $valid = preg_match('/^[a-zA-Z]+$/', $answer); |
| 182 | 182 | if (!$valid) { |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | ); |
| 191 | 191 | $question->setNormalizer( |
| 192 | - function ($value) { |
|
| 192 | + function($value) { |
|
| 193 | 193 | return $value ? trim($value) : ''; |
| 194 | 194 | } |
| 195 | 195 | ); |
@@ -269,18 +269,18 @@ discard block |
||
| 269 | 269 | ), 'yes' |
| 270 | 270 | ); |
| 271 | 271 | $question->setNormalizer( |
| 272 | - function ($value) { |
|
| 272 | + function($value) { |
|
| 273 | 273 | return $value[0] == 'y' ? 'y' : 'n'; |
| 274 | 274 | } |
| 275 | 275 | ); |
| 276 | 276 | $question->setValidator( |
| 277 | - function ($answer) { |
|
| 277 | + function($answer) { |
|
| 278 | 278 | // Should only contain letters. |
| 279 | 279 | $allowed = [ |
| 280 | 280 | 'y', |
| 281 | 281 | 'n', |
| 282 | 282 | ]; |
| 283 | - $valid = in_array($answer, $allowed); |
|
| 283 | + $valid = in_array($answer, $allowed); |
|
| 284 | 284 | if (!$valid) { |
| 285 | 285 | throw new \RuntimeException( |
| 286 | 286 | 'Only allowed values are ' . implode(', ', $allowed) |
@@ -138,8 +138,7 @@ |
||
| 138 | 138 | throw new \RuntimeException( |
| 139 | 139 | 'Aborting, overwrite permission is needed.' |
| 140 | 140 | ); |
| 141 | - } |
|
| 142 | - else { |
|
| 141 | + } else { |
|
| 143 | 142 | $this->overwrite = true; |
| 144 | 143 | } |
| 145 | 144 | } |
@@ -141,8 +141,7 @@ |
||
| 141 | 141 | $output->write('Updating the routing: '); |
| 142 | 142 | if ('annotation' != $format) { |
| 143 | 143 | $runner($this->updateRouting($questionHelper, $input, $output, $bundle, $format, $entity, $prefix)); |
| 144 | - } |
|
| 145 | - else { |
|
| 144 | + } else { |
|
| 146 | 145 | $runner($this->updateAnnotationRouting($bundle, $entity, $prefix)); |
| 147 | 146 | } |
| 148 | 147 | |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | |
| 45 | 45 | $builder->addEventListener( |
| 46 | 46 | FormEvents::PRE_SET_DATA, |
| 47 | - function (FormEvent $event) { |
|
| 47 | + function(FormEvent $event) { |
|
| 48 | 48 | $image = $event->getData(); |
| 49 | 49 | $form = $event->getForm(); |
| 50 | 50 | // Conditionally add form elements. |
@@ -56,8 +56,7 @@ |
||
| 56 | 56 | 'data' => $image, |
| 57 | 57 | ] |
| 58 | 58 | ); |
| 59 | - } |
|
| 60 | - else { |
|
| 59 | + } else { |
|
| 61 | 60 | $form->add('file', FileType::class, ['label' => 'Upload an image']); |
| 62 | 61 | } |
| 63 | 62 | } |