|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Ivory CKEditor package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace FOS\CKEditorBundle\Composer; |
|
13
|
|
|
|
|
14
|
|
|
use Composer\Script\CommandEvent; |
|
15
|
|
|
use Composer\Script\Event; |
|
16
|
|
|
use Sensio\Bundle\DistributionBundle\Composer\ScriptHandler; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @author GeLo <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class CKEditorScriptHandler extends ScriptHandler |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @param CommandEvent|Event $event |
|
25
|
|
|
*/ |
|
26
|
|
|
public static function install($event) |
|
27
|
|
|
{ |
|
28
|
|
|
static::executeCommand( |
|
29
|
|
|
$event, |
|
30
|
|
|
static::getConsoleDir($event, 'Install CKEditor'), |
|
31
|
|
|
static::createCommand($event) |
|
32
|
|
|
); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param CommandEvent|Event $event |
|
37
|
|
|
* |
|
38
|
|
|
* @return string |
|
39
|
|
|
*/ |
|
40
|
|
|
protected static function createCommand($event) |
|
41
|
|
|
{ |
|
42
|
|
|
$extra = $event->getComposer()->getPackage()->getExtra(); |
|
43
|
|
|
$command = 'ckeditor:install'; |
|
44
|
|
|
|
|
45
|
|
|
if (isset($extra['ckeditor-path'])) { |
|
46
|
|
|
$command .= ' '.$extra['ckeditor-path']; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
if (isset($extra['ckeditor-release'])) { |
|
50
|
|
|
$command .= ' --release='.$extra['ckeditor-release']; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
if (isset($extra['ckeditor-tag'])) { |
|
54
|
|
|
$command .= ' --tag='.$extra['ckeditor-tag']; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
if (isset($extra['ckeditor-clear'])) { |
|
58
|
|
|
$command .= ' --clear='.$extra['ckeditor-clear']; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
if (isset($extra['ckeditor-exclude'])) { |
|
62
|
|
|
foreach ($extra['ckeditor-exclude'] as $exclude) { |
|
63
|
|
|
$command .= ' --exclude='.$exclude; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
return $command; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|