|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright (c) 2013-2014 David Negrier |
|
4
|
|
|
* |
|
5
|
|
|
* See the file LICENSE.txt for copying permission. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Mouf\Html\Utils\WebLibraryManager; |
|
9
|
|
|
|
|
10
|
|
|
use Mouf\Installer\PackageInstallerInterface; |
|
11
|
|
|
use Mouf\MoufManager; |
|
12
|
|
|
use Mouf\Html\Renderer\RendererUtils; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* An installer class for the WebLibraryManager library. |
|
16
|
|
|
*/ |
|
17
|
|
|
class WebLibraryManagerInstaller implements PackageInstallerInterface { |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* (non-PHPdoc) |
|
21
|
|
|
* @see \Mouf\Installer\PackageInstallerInterface::install() |
|
22
|
|
|
*/ |
|
23
|
|
|
public static function install(MoufManager $moufManager) { |
|
24
|
|
|
// Let's create the instances |
|
25
|
|
|
if (!$moufManager->instanceExists("defaultWebLibraryManager")) { |
|
26
|
|
|
$defaultWebLibraryManager = $moufManager->createInstance("Mouf\\Html\\Utils\\WebLibraryManager\\WebLibraryManager"); |
|
27
|
|
|
$defaultWebLibraryManager->setName("defaultWebLibraryManager"); |
|
28
|
|
|
|
|
29
|
|
|
if (!$moufManager->instanceExists("rootUrlInlineWebLibrary")) { |
|
30
|
|
|
if (!$moufManager->instanceExists("rootUrlJsFile")) { |
|
31
|
|
|
$rootUrlJsFile = $moufManager->createInstance("Mouf\\Html\\HtmlElement\\HtmlFromFile"); |
|
32
|
|
|
$rootUrlJsFile->setName("rootUrlJsFile"); |
|
33
|
|
|
$rootUrlJsFile->getProperty("fileName")->setValue("vendor/mouf/html.utils.weblibrarymanager/javascript/rootUrl.php"); |
|
34
|
|
|
} else { |
|
35
|
|
|
$rootUrlJsFile = $moufManager->getInstanceDescriptor("rootUrlJsFile"); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
$rootUrl = $moufManager->createInstance("Mouf\\Html\\Utils\\WebLibraryManager\\InlineWebLibrary"); |
|
39
|
|
|
$rootUrl->setName("rootUrlInlineWebLibrary"); |
|
40
|
|
|
$rootUrl->getProperty("jsElement")->setValue($rootUrlJsFile); |
|
41
|
|
|
|
|
42
|
|
|
$defaultWebLibraryManager->getProperty("webLibraries")->setValue(array($rootUrl)); |
|
43
|
|
|
} |
|
44
|
|
|
} else { |
|
45
|
|
|
$defaultWebLibraryManager = $moufManager->getInstanceDescriptor('defaultWebLibraryManager'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
if ($moufManager->has("defaultRenderer") && $defaultWebLibraryManager->getConstructorArgumentProperty("renderer")->getValue() === null) { |
|
49
|
|
|
$defaultWebLibraryManager->getConstructorArgumentProperty("renderer")->setValue($moufManager->getInstanceDescriptor('defaultRenderer')); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
RendererUtils::createPackageRenderer($moufManager, "mouf/html.utils.weblibrarymanager"); |
|
54
|
|
|
|
|
55
|
|
|
// Let's rewrite the MoufComponents.php file to save the component |
|
56
|
|
|
$moufManager->rewriteMouf(); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|