2016-12-31 07:52:25 +01:00
|
|
|
<?php
|
2017-01-04 05:13:13 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the Magallanes package.
|
|
|
|
*
|
|
|
|
* (c) Andrés Montañez <andres@andresmontanez.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
2016-12-31 07:52:25 +01:00
|
|
|
|
|
|
|
namespace Mage\Task\BuiltIn\Composer;
|
|
|
|
|
|
|
|
use Symfony\Component\Process\Process;
|
|
|
|
use Mage\Task\AbstractTask;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Composer Task - Generate Autoload
|
|
|
|
*
|
|
|
|
* @author Andrés Montañez <andresmontanez@gmail.com>
|
|
|
|
*/
|
2017-01-06 00:38:42 +01:00
|
|
|
class DumpAutoloadTask extends AbstractTask
|
2016-12-31 07:52:25 +01:00
|
|
|
{
|
|
|
|
public function getName()
|
|
|
|
{
|
2017-01-06 00:38:42 +01:00
|
|
|
return 'composer/dump-autoload';
|
2016-12-31 07:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription()
|
|
|
|
{
|
2017-01-06 00:38:42 +01:00
|
|
|
return '[Composer] Dump Autoload';
|
2016-12-31 07:52:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function execute()
|
|
|
|
{
|
|
|
|
$options = $this->getOptions();
|
2017-01-06 00:38:42 +01:00
|
|
|
$command = sprintf('%s dump-autoload %s', $options['path'], $options['flags']);
|
2016-12-31 07:52:25 +01:00
|
|
|
|
|
|
|
/** @var Process $process */
|
2017-01-06 00:38:42 +01:00
|
|
|
$process = $this->runtime->runCommand(trim($command));
|
2016-12-31 07:52:25 +01:00
|
|
|
|
|
|
|
return $process->isSuccessful();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getOptions()
|
|
|
|
{
|
2016-12-31 21:35:16 +01:00
|
|
|
$userOptions = $this->runtime->getConfigOptions('composer', []);
|
2016-12-31 07:52:25 +01:00
|
|
|
$options = array_merge(
|
|
|
|
['path' => 'composer', 'flags' => '--optimize'],
|
2016-12-31 21:35:16 +01:00
|
|
|
(is_array($userOptions) ? $userOptions : []),
|
2016-12-31 07:52:25 +01:00
|
|
|
$this->options
|
|
|
|
);
|
|
|
|
|
|
|
|
return $options;
|
|
|
|
}
|
|
|
|
}
|