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

Process which copies components from their source to the components folder. More...

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

Public Member Functions

 process ()
 {{Called when running through the process.
Returns
boolean True or false depending on whether the process was successful.
}} More...
 
 copy ($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
 __construct (Composer $composer, IOInterface $io)
 Create a new Process. More...
 
 init ()
 Initialize the process before its run. More...
 
 process ()
 Called when running through the process. More...
 

Additional Inherited Members

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

Detailed Description

Process which copies components from their source to the components folder.

Definition at line 17 of file CopyProcess.php.

Member Function Documentation

◆ copy()

ComponentInstaller\Process\CopyProcess::copy (   $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 CopyProcess.php.

35 {
36 // Iterate over each package that should be processed.
37 foreach ($packages as $package) {
38 // Retrieve some information about the package.
39 $packageDir = $this->getVendorDir($package);
40 $name = isset($package['name']) ? $package['name'] : '__component__';
41 $extra = isset($package['extra']) ? $package['extra'] : array();
42 $componentName = $this->getComponentName($name, $extra);
43
44 // Cycle through each asset type.
45 $fileType = array('scripts', 'styles', 'files');
46 foreach ($fileType as $type) {
47 // Only act on the files if they're available.
48 if (isset($extra['component'][$type]) && is_array($extra['component'][$type])) {
49 foreach ($extra['component'][$type] as $file) {
50 // Make sure the file itself is available.
51 $source = $packageDir.DIRECTORY_SEPARATOR.$file;
52
53 // Perform a recursive glob file search on the pattern.
54 foreach ($this->fs->recursiveGlobFiles($source) as $filesource) {
55 // Find the final destination without the package directory.
56 $withoutPackageDir = str_replace($packageDir.DIRECTORY_SEPARATOR, '', $filesource);
57
58 // Construct the final file destination.
59 $destination = $this->componentDir.DIRECTORY_SEPARATOR.$componentName.DIRECTORY_SEPARATOR.$withoutPackageDir;
60
61 // Ensure the directory is available.
62 $this->fs->ensureDirectoryExists(dirname($destination));
63
64 // Copy the file to its destination.
65 copy($filesource, $destination);
66 }
67 }
68 }
69 }
70 }
71
72 return true;
73 }
copy($packages)
Copy file assets from the given packages to the component directory.
Definition: CopyProcess.php:34
getComponentName($prettyName, array $extra=array())
Retrieves the component name for the component.
Definition: Process.php:154
getVendorDir(array $package)
Retrieves the given package's vendor directory, where it's installed.
Definition: Process.php:199
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $file, ComponentInstaller\Process\Process\$packages, ComponentInstaller\Process\CopyProcess\copy(), ComponentInstaller\Process\Process\getComponentName(), and ComponentInstaller\Process\Process\getVendorDir().

Referenced by ComponentInstaller\Process\CopyProcess\copy(), and ComponentInstaller\Process\CopyProcess\process().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ process()

ComponentInstaller\Process\CopyProcess::process ( )

{{Called when running through the process.

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

Reimplemented from ComponentInstaller\Process\Process.

Definition at line 22 of file CopyProcess.php.

23 {
24 return $this->copy($this->packages);
25 }

References ComponentInstaller\Process\CopyProcess\copy().

+ Here is the call graph for this function:

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