|
@@ -4,8 +4,6 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace Fgm\Drupal\Composer;
|
|
namespace Fgm\Drupal\Composer;
|
|
|
|
|
|
-require_once __DIR__ . '/../../../../vendor/autoload.php';
|
|
|
|
-
|
|
|
|
use Composer\Command\BaseCommand;
|
|
use Composer\Command\BaseCommand;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
@@ -49,14 +47,14 @@ abstract class BaseBuilderCommand extends BaseCommand {
|
|
* @param string $buildName
|
|
* @param string $buildName
|
|
* The template name as a composer.json extra section.
|
|
* The template name as a composer.json extra section.
|
|
*
|
|
*
|
|
- * @return array
|
|
|
|
|
|
+ * @return array{string,int}
|
|
* - string Template name
|
|
* - string Template name
|
|
* - int Error
|
|
* - int Error
|
|
*/
|
|
*/
|
|
public function validateTemplateName(
|
|
public function validateTemplateName(
|
|
InputInterface $input,
|
|
InputInterface $input,
|
|
OutputInterface $output,
|
|
OutputInterface $output,
|
|
- string $buildName
|
|
|
|
|
|
+ string $buildName,
|
|
): array {
|
|
): array {
|
|
$conf = $this->getComposer()->getPackage()->getExtra()[Builder::NAME] ?? [];
|
|
$conf = $this->getComposer()->getPackage()->getExtra()[Builder::NAME] ?? [];
|
|
$templateName = $conf['templates'][$buildName] ?? '';
|
|
$templateName = $conf['templates'][$buildName] ?? '';
|
|
@@ -77,19 +75,19 @@ abstract class BaseBuilderCommand extends BaseCommand {
|
|
*
|
|
*
|
|
* @param \Twig\TemplateWrapper $wrapper
|
|
* @param \Twig\TemplateWrapper $wrapper
|
|
* A Twig user-space template wrapper.
|
|
* A Twig user-space template wrapper.
|
|
- * @param array $context
|
|
|
|
|
|
+ * @param mixed[] $context
|
|
* The data context with which to perform the rendering.
|
|
* The data context with which to perform the rendering.
|
|
* @param string $destination
|
|
* @param string $destination
|
|
* The path where to write the rendering result.
|
|
* The path where to write the rendering result.
|
|
*
|
|
*
|
|
- * @return array
|
|
|
|
|
|
+ * @return array{string,int}
|
|
* - string message
|
|
* - string message
|
|
* - int status: 0 on success, other values on errors.
|
|
* - int status: 0 on success, other values on errors.
|
|
*/
|
|
*/
|
|
protected function render(
|
|
protected function render(
|
|
TemplateWrapper $wrapper,
|
|
TemplateWrapper $wrapper,
|
|
array $context,
|
|
array $context,
|
|
- string $destination
|
|
|
|
|
|
+ string $destination,
|
|
): array {
|
|
): array {
|
|
if (file_exists($destination)) {
|
|
if (file_exists($destination)) {
|
|
$ok = unlink($destination);
|
|
$ok = unlink($destination);
|
|
@@ -117,7 +115,7 @@ abstract class BaseBuilderCommand extends BaseCommand {
|
|
* @param string $buildName
|
|
* @param string $buildName
|
|
* Machine name of build process.
|
|
* Machine name of build process.
|
|
*
|
|
*
|
|
- * @return array
|
|
|
|
|
|
+ * @return array{?\Twig\TemplateWrapper,array<string,mixed>,string,int}
|
|
* - TemplateWrapper|NULL: Twig template wrapper
|
|
* - TemplateWrapper|NULL: Twig template wrapper
|
|
* - array: template parameters
|
|
* - array: template parameters
|
|
* - string: error message
|
|
* - string: error message
|
|
@@ -130,7 +128,7 @@ abstract class BaseBuilderCommand extends BaseCommand {
|
|
protected function prepare(
|
|
protected function prepare(
|
|
InputInterface $input,
|
|
InputInterface $input,
|
|
OutputInterface $output,
|
|
OutputInterface $output,
|
|
- string $buildName
|
|
|
|
|
|
+ string $buildName,
|
|
): array {
|
|
): array {
|
|
[
|
|
[
|
|
$templateName,
|
|
$templateName,
|
|
@@ -141,7 +139,7 @@ abstract class BaseBuilderCommand extends BaseCommand {
|
|
};
|
|
};
|
|
|
|
|
|
$settingsPath = $this->getSettingsPath();
|
|
$settingsPath = $this->getSettingsPath();
|
|
- $templatePath = "${settingsPath}/${templateName}";
|
|
|
|
|
|
+ $templatePath = "{$settingsPath}/{$templateName}";
|
|
$realTemplatePath = realpath($templatePath);
|
|
$realTemplatePath = realpath($templatePath);
|
|
if (empty($realTemplatePath)) {
|
|
if (empty($realTemplatePath)) {
|
|
return [
|
|
return [
|
|
@@ -172,7 +170,7 @@ abstract class BaseBuilderCommand extends BaseCommand {
|
|
/**
|
|
/**
|
|
* Get parameters as obtained from configuration.
|
|
* Get parameters as obtained from configuration.
|
|
*
|
|
*
|
|
- * @return array
|
|
|
|
|
|
+ * @return array{array<string,mixed>,string,int}
|
|
* - array: parameters
|
|
* - array: parameters
|
|
* - string: error message
|
|
* - string: error message
|
|
* - int: error, 0 if OK. If non-zero, only the error message is reliable.
|
|
* - int: error, 0 if OK. If non-zero, only the error message is reliable.
|