36 if ($this->config->has(
'component-baseurl')) {
37 $this->baseUrl = $this->config->get(
'component-baseurl');
49 $json = $this->
requireJson($this->packages, $this->config);
53 $destination = $this->componentDir .
'/require.config.js';
54 $this->fs->ensureDirectoryExists(dirname($destination));
55 if (file_put_contents($destination, $requireConfig) === FALSE) {
56 $this->io->write(
'<error>Error writing require.config.js</error>');
62 if (!file_exists(dirname(__DIR__) .
'/Resources/require.js')) {
63 $this->io->write(
'<error>Error reading in require.js</error>');
68 $assets = $this->newAssetCollection();
69 $assets->add(
new FileAsset(dirname(__DIR__) .
'/Resources/require.js'));
73 if (file_put_contents($this->componentDir .
'/require.js', $assets->dump()) === FALSE) {
74 $this->io->write(
'<error>Error writing require.js to the components directory</error>');
96 foreach ($packages as $package) {
98 $extra = isset($package[
'extra']) ? $package[
'extra'] :
array();
99 $options = isset($extra[
'component']) ? $extra[
'component'] :
array();
109 if (!empty($scripts)) {
115 $component[
'main'] = $name.
'-built.js';
118 $json[
'packages'][] = $component;
125 $json[
'shim'][$name] = $shim;
130 if (!empty($packageConfig)) {
131 $json[
'config'][$name] = $packageConfig;
139 if ($this->config->has(
'component')) {
140 $config = $this->config->get(
'component');
160 $assets = $this->newAssetCollection();
162 foreach ($scripts as $script) {
165 $matches = $this->fs->recursiveGlobFiles(
$path);
166 foreach ($matches as $match) {
170 $js = $assets->dump();
174 $destination = $this->componentDir.DIRECTORY_SEPARATOR.$file;
175 $this->fs->ensureDirectoryExists(dirname($destination));
177 return file_put_contents($destination,
$js);
195 $js = JsonFile::encode($json);
199 var components =
$js;
200 if (typeof require !==
"undefined" && require.config) {
201 require.config(components);
203 var require = components;
205 if (typeof exports !==
"undefined" && typeof module !==
"undefined") {
206 module.exports = components;
227 foreach ($array2 as $key => &$value) {
228 if(is_numeric($key)){
231 if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
235 $merged[$key] = $value;
246 protected function newAssetCollection()
250 if ($this->config->has(
'component-scriptFilters')) {
251 $filters = $this->config->get(
'component-scriptFilters');
252 if (isset($filters) && is_array($filters)) {
253 foreach ($filters as $filter => $filterParams) {
254 $reflection = new \ReflectionClass($filter);
256 $filter = $reflection->newInstanceArgs($filterParams);
257 $assets->ensureFilter($filter);
requireJs(array $json=array())
Constructs the require.js file from the provided require.js JSON array.
process()
{Called when running through the process.boolean True or false depending on whether the process was s...
$baseUrl
The base URL for the require.js configuration.
aggregateScripts($package, array $scripts, $file)
Concatenate all scripts together into one destination file.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
Builds the require.js configuration.
if(!is_array($argv)) $options
Represents an asset loaded from a file.
getComponentName($prettyName, array $extra=array())
Retrieves the component name for the component.
getVendorDir(array $package)
Retrieves the given package's vendor directory, where it's installed.
Create styles array
The data for the language used.
arrayMergeRecursiveDistinct(array &$array1, array &$array2)
Merges two arrays without changing string array keys.
requireJson(array $packages)
Creates a require.js configuration from an array of packages.
Represents a string asset.
init()
{Initialize the process before its run.boolean Whether or not the process should continue after initi...
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file