@@ -30,6 +30,10 @@ |
||
| 30 | 30 | |
| 31 | 31 | private $unitOfWork; |
| 32 | 32 | |
| 33 | + /** |
|
| 34 | + * @param string $class |
|
| 35 | + * @param string $property |
|
| 36 | + */ |
|
| 33 | 37 | public function __construct(EntityManager $em, $class, $property, $queryBuilder, $multiple) |
| 34 | 38 | { |
| 35 | 39 | if (!(null === $queryBuilder || $queryBuilder instanceof QueryBuilder || $queryBuilder instanceof \Closure)) { |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | /** |
| 127 | 127 | * Sets the value of uri. |
| 128 | 128 | * |
| 129 | - * @param string $name $uri the uri |
|
| 130 | 129 | * |
| 130 | + * @param string $uri |
|
| 131 | 131 | * @return self |
| 132 | 132 | */ |
| 133 | 133 | public function setUri($uri) |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | /** |
| 151 | 151 | * Sets the value of secretKey. |
| 152 | 152 | * |
| 153 | - * @param string $name $secretKey the secret key |
|
| 154 | 153 | * |
| 154 | + * @param string $secretKey |
|
| 155 | 155 | * @return self |
| 156 | 156 | */ |
| 157 | 157 | public function setSecretKey($secretKey) |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | /** |
| 175 | 175 | * Sets the value of mime. |
| 176 | 176 | * |
| 177 | - * @param string $name $mime the mime |
|
| 178 | 177 | * |
| 178 | + * @param string $mime |
|
| 179 | 179 | * @return self |
| 180 | 180 | */ |
| 181 | 181 | public function setMime($mime) |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | /** |
| 199 | 199 | * Sets the value of lifetime. |
| 200 | 200 | * |
| 201 | - * @param string $label $lifetime the lifetime |
|
| 202 | 201 | * |
| 202 | + * @param null|\DateTime $lifetime |
|
| 203 | 203 | * @return self |
| 204 | 204 | */ |
| 205 | 205 | public function setLifetime($lifetime) |
@@ -60,6 +60,9 @@ |
||
| 60 | 60 | return (array_key_exists($mime, $this->previewIcon)) ? $this->previewIcon[$mime] : $this->previewIcon['unknown']; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | + /** |
|
| 64 | + * @param boolean $isIcon |
|
| 65 | + */ |
|
| 63 | 66 | protected function generatePath($isIcon, $str) |
| 64 | 67 | { |
| 65 | 68 | if($isIcon === true) { |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | public function configure() |
| 16 | 16 | { |
| 17 | 17 | $this->setName('alpixel:media:cleanup') |
| 18 | - ->setDescription('Cleaning unused media'); |
|
| 18 | + ->setDescription('Cleaning unused media'); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function execute(InputInterface $input, OutputInterface $output) |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | { |
| 17 | 17 | parent::configure(); |
| 18 | 18 | $this->setName('alpixel:media:liip_cleanup') |
| 19 | - ->setDescription('Cleaning liip cache folders'); |
|
| 19 | + ->setDescription('Cleaning liip cache folders'); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function execute(InputInterface $input, OutputInterface $output) |
@@ -48,6 +48,9 @@ |
||
| 48 | 48 | return $url; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | + /** |
|
| 52 | + * @param string $url |
|
| 53 | + */ |
|
| 51 | 54 | protected function downloadMedia($url) |
| 52 | 55 | { |
| 53 | 56 | $filepath = sys_get_temp_dir().'/tmp.jpg'; |
@@ -56,17 +56,17 @@ discard block |
||
| 56 | 56 | $url .= 'g/'; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - $url .= $dimensions['w'] . '/' . $dimensions['h']; |
|
| 59 | + $url .= $dimensions['w'].'/'.$dimensions['h']; |
|
| 60 | 60 | |
| 61 | 61 | $category = ['abstract', 'city', 'nature', 'moutains']; |
| 62 | - $url .= '/' . $category[array_rand($category, 1)] . '/'; |
|
| 62 | + $url .= '/'.$category[array_rand($category, 1)].'/'; |
|
| 63 | 63 | |
| 64 | 64 | return $url; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | protected function downloadMedia($url) |
| 68 | 68 | { |
| 69 | - $filepath = sys_get_temp_dir() . '/' . uniqid() . '.jpg'; |
|
| 69 | + $filepath = sys_get_temp_dir().'/'.uniqid().'.jpg'; |
|
| 70 | 70 | $ch = curl_init($url); |
| 71 | 71 | $fp = fopen($filepath, 'wb'); |
| 72 | 72 | curl_setopt($ch, CURLOPT_FILE, $fp); |
@@ -81,16 +81,16 @@ discard block |
||
| 81 | 81 | protected function fetchFromCache($dimensions) |
| 82 | 82 | { |
| 83 | 83 | $fs = new Filesystem(); |
| 84 | - $cacheDir = $_SERVER['HOME'] . '/.symfony/media'; |
|
| 84 | + $cacheDir = $_SERVER['HOME'].'/.symfony/media'; |
|
| 85 | 85 | if (!$fs->exists($cacheDir)) { |
| 86 | 86 | $fs->mkdir($cacheDir, 0777); |
| 87 | 87 | } else { |
| 88 | - $cacheDir .= '/' . $dimensions['w'] . '-' . $dimensions['h']; |
|
| 88 | + $cacheDir .= '/'.$dimensions['w'].'-'.$dimensions['h']; |
|
| 89 | 89 | if (!$fs->exists($cacheDir)) { |
| 90 | 90 | $fs->mkdir($cacheDir, 0777); |
| 91 | 91 | } else { |
| 92 | 92 | $finder = new Finder(); |
| 93 | - $files = $finder->in($cacheDir . '/')->files(); |
|
| 93 | + $files = $finder->in($cacheDir.'/')->files(); |
|
| 94 | 94 | if ($files->count() === 3) { |
| 95 | 95 | $iterator = $finder->getIterator(); |
| 96 | 96 | $iterator->rewind(); |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | protected function storeInCache($dimensions, File $file) |
| 110 | 110 | { |
| 111 | 111 | $fs = new Filesystem(); |
| 112 | - $cacheDir = $_SERVER['HOME'] . '/.symfony/media/' . $dimensions['w'] . '-' . $dimensions['h']; |
|
| 112 | + $cacheDir = $_SERVER['HOME'].'/.symfony/media/'.$dimensions['w'].'-'.$dimensions['h']; |
|
| 113 | 113 | if (!$fs->exists($cacheDir)) { |
| 114 | 114 | $fs->mkdir($cacheDir, 0777); |
| 115 | 115 | } |
| 116 | - $fs->copy($file->getRealPath(), $cacheDir . '/' . $file->getFilename()); |
|
| 116 | + $fs->copy($file->getRealPath(), $cacheDir.'/'.$file->getFilename()); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $response = new Response(); |
| 80 | 80 | $response->setContent(file_get_contents($this->get('alpixel_media.manager')->getAbsolutePath($media))); |
| 81 | 81 | $response->headers->set('Content-Type', 'application/force-download'); |
| 82 | - $response->headers->set('Content-disposition', 'filename=' . $media->getName()); |
|
| 82 | + $response->headers->set('Content-disposition', 'filename='.$media->getName()); |
|
| 83 | 83 | |
| 84 | 84 | return $response; |
| 85 | 85 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $isImage = @getimagesize($src); |
| 102 | 102 | |
| 103 | 103 | if ($isImage) { |
| 104 | - $response->headers->set('Content-disposition', 'inline;filename=' . $media->getName()); |
|
| 104 | + $response->headers->set('Content-disposition', 'inline;filename='.$media->getName()); |
|
| 105 | 105 | if (!empty($filter) && $isImage) { |
| 106 | 106 | $src = $this->get('alpixel_media.manager')->getAbsolutePath($media, $filter); |
| 107 | 107 | $dataManager = $this->get('liip_imagine.data.manager'); // the data manager service |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | if (!is_file($src)) { |
| 112 | 112 | $fs = new Filesystem(); |
| 113 | - if (!$fs->exists($uploadDir . $media->getFolder())) { |
|
| 114 | - $fs->mkdir($uploadDir . $media->getFolder()); |
|
| 113 | + if (!$fs->exists($uploadDir.$media->getFolder())) { |
|
| 114 | + $fs->mkdir($uploadDir.$media->getFolder()); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $path = 'upload/' . $media->getUri(); |
|
| 117 | + $path = 'upload/'.$media->getUri(); |
|
| 118 | 118 | |
| 119 | 119 | // find the image and determine its type |
| 120 | 120 | $image = $dataManager->find($filter, $path); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | // run the filter |
| 123 | 123 | $responseData = $filterManager->applyFilter($image, $filter); |
| 124 | 124 | $data = $responseData->getContent(); |
| 125 | - file_put_contents($uploadDir . $media->getUri(), $data); |
|
| 125 | + file_put_contents($uploadDir.$media->getUri(), $data); |
|
| 126 | 126 | } else { |
| 127 | 127 | $data = file_get_contents($src); |
| 128 | 128 | $lastModified->setTimestamp(filemtime($src)); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } else { |
| 136 | 136 | $lastModified->setTimestamp(filemtime($src)); |
| 137 | 137 | $data = file_get_contents($src); |
| 138 | - $response->headers->set('Content-disposition', 'attachment;filename=' . basename($media->getUri())); |
|
| 138 | + $response->headers->set('Content-disposition', 'attachment;filename='.basename($media->getUri())); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $response->setLastModified($lastModified); |