41 $rootPackage = isset($this->composer) ? $this->composer->getPackage() : null;
42 if (isset($rootPackage)) {
44 while ($rootPackage instanceof AliasPackage) {
45 $rootPackage = $rootPackage->getAliasOf();
49 if (method_exists($rootPackage,
'setScripts')) {
50 $scripts = $rootPackage->getScripts();
53 $scripts[
'post-autoload-dump'][
'component-installer'] =
'ComponentInstaller\\Installer::postAutoloadDump';
54 $rootPackage->setScripts($scripts);
59 return $packageType ==
'component';
72 $name = $prettyName = $package->getPrettyName();
73 if (strpos($prettyName,
'/') !==
false) {
74 list($vendor, $name) = explode(
'/', $prettyName);
79 $rootPackage = $this->composer->getPackage();
80 $rootExtras = $rootPackage ? $rootPackage->getExtra() :
array();
81 $customComponents = isset($rootExtras[
'component']) ? $rootExtras[
'component'] :
array();
83 if (isset($customComponents[$prettyName]) && is_array($customComponents[$prettyName])) {
84 $component = $customComponents[$prettyName];
87 $extra = $package->getExtra();
88 $component = isset($extra[
'component']) ? $extra[
'component'] :
array();
92 if (isset($component[
'name'])) {
93 $name = $component[
'name'];
97 return $this->getComponentDir() . DIRECTORY_SEPARATOR . $name;
105 $this->componentDir = $this->getComponentDir();
106 $this->filesystem->ensureDirectoryExists($this->componentDir);
107 parent::initializeVendorDir();
115 $config = $this->composer->getConfig();
116 return $config->has(
'component-dir') ?
$config->get(
'component-dir') :
'components';
126 $this->removeComponent($package);
127 parent::removeCode($package);
138 $path = $this->getComponentPath($package);
139 return $this->filesystem->remove(
$path);
149 $this->removeComponent($package);
150 parent::installCode($package);
158 public static function postAutoloadDump(Event $event)
162 $composer = $event->getComposer();
163 $io = $event->getIO();
164 $io->write(
'<info>Compiling component files</info>');
169 "ComponentInstaller\\Process\\CopyProcess",
171 "ComponentInstaller\\Process\\RequireJsProcess",
173 "ComponentInstaller\\Process\\RequireCssProcess",
175 "ComponentInstaller\\Process\\BuildJsProcess",
179 foreach ($processes as $class) {
180 if(!class_exists($class)){
181 $io->write(
"<warning>Process class '$class' not found, skipping this process</warning>");
186 $process =
new $class($composer, $io);
188 if (!$process->init()) {
189 $io->write(
"<warning>An error occurred while initializing the '$class' process.</warning>");
initializeVendorDir()
Initialize the Component directory, as well as the vendor directory.
installCode(PackageInterface $package)
Before installing the Component, be sure its destination is clear first.
getComponentPath(PackageInterface $package)
Gets the destination Component directory.
removeCode(PackageInterface $package)
Remove both the installed code and files from the Component directory.
$componentDir
The location where Components are to be installed.
Create styles array
The data for the language used.
getComponentDir()
Retrieves the Installer's provided component directory.
removeComponent(PackageInterface $package)
Remove a Component's files from the Component directory.
Component Installer for Composer.