Skip to content

Commit 877ae16

Browse files
authored
Provide drupal:scaffold command. Keep drupal-scaffold as BC layer (#61)
2 parents 2b06b73 + f5dd00e commit 877ae16

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed

src/CommandProvider.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace DrupalComposer\DrupalScaffold;
4+
5+
use Composer\Plugin\Capability\CommandProvider as CommandProviderCapability;
6+
7+
class CommandProvider implements CommandProviderCapability {
8+
9+
/**
10+
* {@inheritdoc}
11+
*/
12+
public function getCommands() {
13+
return [
14+
new DrupalScaffoldCommand()
15+
];
16+
}
17+
18+
}

src/DrupalScaffoldCommand.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace DrupalComposer\DrupalScaffold;
4+
5+
use Composer\Command\BaseCommand;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
9+
class DrupalScaffoldCommand extends BaseCommand {
10+
11+
/**
12+
* {@inheritdoc}
13+
*/
14+
protected function configure() {
15+
parent::configure();
16+
$this
17+
->setName('drupal:scaffold')
18+
->setDescription('Update the Drupal scaffold files.');
19+
}
20+
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
protected function execute(InputInterface $input, OutputInterface $output) {
25+
$handler = new Handler($this->getComposer(), $this->getIO());
26+
$handler->downloadScaffold();
27+
// Generate the autoload.php file after generating the scaffold files.
28+
$handler->generateAutoload();
29+
}
30+
31+
}

src/Plugin.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Composer\Installer\PackageEvent;
1212
use Composer\Installer\PackageEvents;
1313
use Composer\IO\IOInterface;
14+
use Composer\Plugin\Capable;
1415
use Composer\Plugin\CommandEvent;
1516
use Composer\Plugin\PluginEvents;
1617
use Composer\Plugin\PluginInterface;
@@ -19,7 +20,7 @@
1920
/**
2021
* Composer plugin for handling drupal scaffold.
2122
*/
22-
class Plugin implements PluginInterface, EventSubscriberInterface {
23+
class Plugin implements PluginInterface, EventSubscriberInterface, Capable {
2324

2425
/**
2526
* @var \DrupalComposer\DrupalScaffold\Handler
@@ -37,15 +38,22 @@ public function activate(Composer $composer, IOInterface $io) {
3738
$this->handler = new Handler($composer, $io);
3839
}
3940

41+
/**
42+
* {@inheritdoc}
43+
*/
44+
public function getCapabilities() {
45+
return array(
46+
'Composer\Plugin\Capability\CommandProvider' => 'DrupalComposer\DrupalScaffold\CommandProvider',
47+
);
48+
}
49+
4050
/**
4151
* {@inheritdoc}
4252
*/
4353
public static function getSubscribedEvents() {
4454
return array(
4555
PackageEvents::POST_PACKAGE_INSTALL => 'postPackage',
4656
PackageEvents::POST_PACKAGE_UPDATE => 'postPackage',
47-
//PackageEvents::POST_PACKAGE_UNINSTALL => 'postPackage',
48-
//ScriptEvents::POST_INSTALL_CMD => 'postCmd',
4957
ScriptEvents::POST_UPDATE_CMD => 'postCmd',
5058
PluginEvents::COMMAND => 'cmdBegins',
5159
);
@@ -83,11 +91,16 @@ public function postCmd(\Composer\Script\Event $event) {
8391
* scaffold files.
8492
*
8593
* @param \Composer\Script\Event $event
94+
*
95+
* @deprecated since version 2.5.0, to be removed in 3.0. Use the command
96+
* "composer drupal:scaffold" instead.
8697
*/
8798
public static function scaffold(\Composer\Script\Event $event) {
99+
@trigger_error('\DrupalComposer\DrupalScaffold\Plugin::scaffold is deprecated since version 2.5.0 and will be removed in 3.0. Use "composer drupal:scaffold" instead.', E_USER_DEPRECATED);
88100
$handler = new Handler($event->getComposer(), $event->getIO());
89101
$handler->downloadScaffold();
90102
// Generate the autoload.php file after generating the scaffold files.
91103
$handler->generateAutoload();
92104
}
105+
93106
}

0 commit comments

Comments
 (0)