|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Cdf\BiCoreBundle\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Command\Command; |
|
6
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
8
|
|
|
use Symfony\Component\Finder\Finder; |
|
9
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
|
10
|
|
|
|
|
11
|
|
|
class BiCoreBundlePubblicamanualeCommand extends Command |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
protected static $defaultName = 'bicorebundle:pubblicamanuale'; |
|
15
|
|
|
|
|
16
|
|
|
protected function configure() |
|
17
|
|
|
{ |
|
18
|
|
|
$this |
|
19
|
|
|
->setDescription('Copia il manuale dalla cartella Doc alla cartella Web') |
|
20
|
|
|
->setHelp('Estende la pubblicazione degli assets al manuale'); |
|
21
|
|
|
} |
|
22
|
|
|
public function __construct($projectdir, Filesystem $fs) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->projectdir = $projectdir; |
|
|
|
|
|
|
25
|
|
|
$this->fs = $fs; |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
// you *must* call the parent constructor |
|
28
|
|
|
parent::__construct(); |
|
29
|
|
|
} |
|
30
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
31
|
|
|
{ |
|
32
|
|
|
$projectDir = $this->projectdir; |
|
|
|
|
|
|
33
|
|
|
$manuale = "manuale.pdf"; |
|
|
|
|
|
|
34
|
|
|
$originDir = $projectDir . DIRECTORY_SEPARATOR . 'doc' . DIRECTORY_SEPARATOR . 'manuale'; |
|
|
|
|
|
|
35
|
|
|
$manualepath = $originDir . DIRECTORY_SEPARATOR . $manuale; |
|
36
|
|
|
if ($this->fs->exists($manualepath)) { |
|
37
|
|
|
$targetDir = $projectDir . DIRECTORY_SEPARATOR . 'public'; |
|
38
|
|
|
|
|
39
|
|
|
$this->fs->mkdir($targetDir, 0777); |
|
40
|
|
|
// // We use a custom iterator to ignore VCS files |
|
41
|
|
|
$this->fs->mirror($originDir, $targetDir, Finder::create()->name($manuale)->in($originDir)); |
|
42
|
|
|
} else { |
|
43
|
|
|
throw new \Exception("Attenzione, non è presente il file " . $manualepath); |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|