1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the PHPoole package. |
4
|
|
|
* |
5
|
|
|
* Copyright (c) Arnaud Ligny <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace PHPoole\Command; |
12
|
|
|
|
13
|
|
|
use PHPoole\Util\Plateform; |
14
|
|
|
use Zend\Console\Prompt\Confirm; |
15
|
|
|
|
16
|
|
|
class NewWebsite extends AbstractCommand |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var bool |
20
|
|
|
*/ |
21
|
|
|
protected $force; |
22
|
|
|
|
23
|
|
|
public function processCommand() |
24
|
|
|
{ |
25
|
|
|
$this->force = $this->getRoute()->getMatchedParam('force', false); |
26
|
|
|
|
27
|
|
|
try { |
28
|
|
|
if ($this->fs->exists($this->getPath().'/'.self::CONFIG_FILE) && !$this->force) { |
29
|
|
|
if (!Confirm::prompt('Website already exists. Do you want to override it? [y/n]', 'y', 'n')) { |
30
|
|
|
// throw new \Exception(sprintf('Config file already exists: "%s".', $this->getPath().'/'.self::CONFIG_FILE)); |
|
|
|
|
31
|
|
|
exit(0); |
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
$root = __DIR__.'/../../'; |
35
|
|
|
if (Plateform::isPhar()) { |
36
|
|
|
$root = Plateform::getPharPath().'/'; |
37
|
|
|
} |
38
|
|
|
$this->wlAnnonce('Creating a new website...'); |
39
|
|
|
$this->fs->copy($root.'skeleton/phpoole.yml', $this->getPath().'/'.self::CONFIG_FILE, true); |
40
|
|
|
$this->fs->mirror($root.'skeleton/content', $this->getPath().'/content'); |
41
|
|
|
$this->fs->mirror($root.'skeleton/layouts', $this->getPath().'/layouts'); |
42
|
|
|
$this->fs->mirror($root.'skeleton/static', $this->getPath().'/static'); |
43
|
|
|
$this->wlDone('Done!'); |
44
|
|
|
} catch (\Exception $e) { |
45
|
|
|
throw new \Exception(sprintf($e->getMessage())); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.