ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ComponentInstaller\Process\BuildJsProcess Class Reference

Builds all JavaScript Components into one require-built.js. More...

+ Inheritance diagram for ComponentInstaller\Process\BuildJsProcess:
+ Collaboration diagram for ComponentInstaller\Process\BuildJsProcess:

Public Member Functions

 process ()
 {Called when running through the process.
Returns
boolean True or false depending on whether the process was successful.
} More...
 
 compile ($packages)
 Copy file assets from the given packages to the component directory. More...
 
- Public Member Functions inherited from ComponentInstaller\Process\Process
 __construct (Composer $composer=null, IOInterface $io=null)
 {Create a new Process.
Parameters
Composer$composerThe Composer object to act on.
IOInterface$ioInput/Output object to act on.
} More...
 
 process ()
 {Called when running through the process.
Returns
boolean True or false depending on whether the process was successful.
} More...
 
 getComponentName ($prettyName, array $extra=array())
 Retrieves the component name for the component. More...
 
 getComponentDir ()
 Retrieves the component directory. More...
 
 setComponentDir ($dir)
 Sets the component directory. More...
 
 getVendorDir (array $package)
 Retrieves the given package's vendor directory, where it's installed. More...
 
- Public Member Functions inherited from ComponentInstaller\Process\ProcessInterface
 init ()
 Initialize the process before its run. More...
 

Protected Member Functions

 definePrefix ($componentName)
 Provide the initial definition prefix. More...
 
 definePostfix ()
 Finish the module definition. More...
 

Additional Inherited Members

- Protected Attributes inherited from ComponentInstaller\Process\Process
 $composer
 
 $io
 
 $config
 
 $packages = array()
 
 $componentDir = 'components'
 
 $fs
 
 $installationManager
 

Detailed Description

Builds all JavaScript Components into one require-built.js.

Definition at line 17 of file BuildJsProcess.php.

Member Function Documentation

◆ compile()

ComponentInstaller\Process\BuildJsProcess::compile (   $packages)

Copy file assets from the given packages to the component directory.

Parameters
array$packagesAn array of packages.
Returns
bool

Definition at line 34 of file BuildJsProcess.php.

References $output, ComponentInstaller\Process\Process\$packages, array, ComponentInstaller\Process\BuildJsProcess\definePostfix(), ComponentInstaller\Process\BuildJsProcess\definePrefix(), and ComponentInstaller\Process\Process\getComponentName().

Referenced by ComponentInstaller\Process\BuildJsProcess\process().

35  {
36  // Set up the initial require-build.js file.
37  $destination = $this->componentDir.DIRECTORY_SEPARATOR.'require-built.js';
38  $require = $this->componentDir.DIRECTORY_SEPARATOR.'require.js';
39  copy($require, $destination);
40 
41  // Cycle through each package and add it to the built require.js file.
42  foreach ($packages as $package) {
43  // Retrieve some information about the package
44  $name = isset($package['name']) ? $package['name'] : '__component__';
45  $extra = isset($package['extra']) ? $package['extra'] : array();
46  $componentName = $this->getComponentName($name, $extra);
47 
48  // Find where the source file is located.
49  $packageDir = $this->componentDir.DIRECTORY_SEPARATOR.$componentName;
50  $source = $packageDir.DIRECTORY_SEPARATOR.$componentName.'-built.js';
51 
52  // Make sure the source script is available.
53  if (file_exists($source)) {
54  // Build the compiled script.
55  $content = file_get_contents($source);
56  $output = $this->definePrefix($componentName) . $content . $this->definePostfix();
57 
58  // Append the module definition to the destination file.
59  file_put_contents($destination, $output, FILE_APPEND);
60  }
61  }
62 
63  return true;
64  }
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
getComponentName($prettyName, array $extra=array())
Retrieves the component name for the component.
Definition: Process.php:154
definePostfix()
Finish the module definition.
Create styles array
The data for the language used.
definePrefix($componentName)
Provide the initial definition prefix.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ definePostfix()

ComponentInstaller\Process\BuildJsProcess::definePostfix ( )
protected

Finish the module definition.

Returns
string Close brackets to finish the module.

Definition at line 83 of file BuildJsProcess.php.

Referenced by ComponentInstaller\Process\BuildJsProcess\compile().

84  {
85  return "\n});\n";
86  }
+ Here is the caller graph for this function:

◆ definePrefix()

ComponentInstaller\Process\BuildJsProcess::definePrefix (   $componentName)
protected

Provide the initial definition prefix.

Parameters
string$componentName
Returns
string Begin the module definition.

Definition at line 72 of file BuildJsProcess.php.

Referenced by ComponentInstaller\Process\BuildJsProcess\compile().

73  {
74  // Define the module using the simplified CommonJS wrapper.
75  return "\ndefine('$componentName', function (require, exports, module) {\n";
76  }
+ Here is the caller graph for this function:

◆ process()

ComponentInstaller\Process\BuildJsProcess::process ( )

{Called when running through the process.

Returns
boolean True or false depending on whether the process was successful.
}

Implements ComponentInstaller\Process\ProcessInterface.

Definition at line 22 of file BuildJsProcess.php.

References ComponentInstaller\Process\BuildJsProcess\compile().

23  {
24  return $this->compile($this->packages);
25  }
compile($packages)
Copy file assets from the given packages to the component directory.
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: