Browse Source

TLD-543 @fixed tests + patch

raphael 3 years ago
parent
commit
b59a9d592c

+ 38
- 0
src/Phoenix/Command/ClearThumbCommand.php View File

@@ -0,0 +1,38 @@
1
+<?php
2
+
3
+namespace Logipro\Phoenix\Command;
4
+
5
+use Symfony\Component\Console\Command\Command;
6
+use Liip\ImagineBundle\Imagine\Cache\CacheManager;
7
+use Symfony\Component\Console\Input\InputInterface;
8
+use Symfony\Component\Console\Output\OutputInterface;
9
+
10
+class ClearThumbCommand extends Command
11
+{
12
+	private $uploader;
13
+	private $entityManager;
14
+	private $cacheManager;
15
+
16
+	public function __construct(CacheManager $cacheManager)
17
+	{
18
+		parent::__construct();
19
+
20
+		$this->cacheManager = $cacheManager;
21
+	}
22
+	/**
23
+	 *
24
+	 * {@inheritDoc}
25
+	 * @see \Symfony\Component\Console\Command\Command::configure()
26
+	 */
27
+	protected function configure()
28
+	{
29
+		$this->setName('phoenix:thumb:clear');
30
+		$this->setDescription("Supprime les miniatures des images");
31
+		$this->setHelp("");
32
+	}
33
+
34
+	protected function execute(InputInterface $input, OutputInterface $output)
35
+	{
36
+		$this->cacheManager->remove();
37
+	}
38
+}

+ 16
- 5
src/Phoenix/DoctrineMigrations/Version20191209165250.php View File

@@ -3,25 +3,36 @@
3 3
 namespace Logipro\Phoenix\DoctrineMigrations;
4 4
 
5 5
 use Doctrine\DBAL\Schema\Schema;
6
-use Symfony\Component\Finder\Finder;
7 6
 use Doctrine\Migrations\AbstractMigration;
8 7
 use Symfony\Component\DependencyInjection\ContainerAwareInterface;
9
-use Liip\ImagineBundle\Imagine\Cache\CacheManager;
10 8
 use Symfony\Component\DependencyInjection\ContainerInterface;
9
+use Symfony\Component\Console\Input\ArrayInput;
10
+use Symfony\Component\Console\Output\BufferedOutput;
11
+use Symfony\Bundle\FrameworkBundle\Console\Application;
11 12
 
12 13
 final class Version20191209165250 extends AbstractMigration
13 14
 implements ContainerAwareInterface
14 15
 {
15
-    private $cacheManager;
16
+    private $kernel;
16 17
 
17 18
     public function setContainer(ContainerInterface $container = null)
18 19
     {
19
-        $this->cacheManager = $container->get('liip_imagine.cache.manager');
20
+        $this->kernel = $container->get('kernel');
20 21
     }
21 22
 
22 23
     public function up(Schema $schema): void
23 24
     {
24
-        $this->cacheManager->remove();
25
+        $application = new Application($this->kernel);
26
+        $application->setAutoExit(false);
27
+
28
+        $input = new ArrayInput([
29
+            'command' => 'phoenix:thumb:clear'
30
+        ]);
31
+
32
+        $output = new BufferedOutput();
33
+        $application->run($input, $output);
34
+
35
+        $this->write($output->fetch());
25 36
     }
26 37
 
27 38
     public function down(Schema $schema): void

Loading…
Cancel
Save