Skip to content

Commit 8d05f72

Browse files
committed
Provide drupal:scaffold command. Keep drupal-scaffold as BC layer
1 parent 2b06b73 commit 8d05f72

File tree

3 files changed

+61
-15
lines changed

3 files changed

+61
-15
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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
->setAliases(['drupal-scaffold'])
19+
->setDescription('Update the Drupal scaffold files.');
20+
}
21+
22+
/**
23+
* {@inheritdoc}
24+
*/
25+
protected function execute(InputInterface $input, OutputInterface $output) {
26+
$handler = new Handler($this->getComposer(), $this->getIO());
27+
$handler->downloadScaffold();
28+
// Generate the autoload.php file after generating the scaffold files.
29+
$handler->generateAutoload();
30+
}
31+
32+
}

src/Plugin.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
use Composer\IO\IOInterface;
1414
use Composer\Plugin\CommandEvent;
1515
use Composer\Plugin\PluginEvents;
16+
use Composer\Plugin\Capable;
1617
use Composer\Plugin\PluginInterface;
1718
use Composer\Script\ScriptEvents;
1819

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
);
@@ -78,16 +86,4 @@ public function postCmd(\Composer\Script\Event $event) {
7886
$this->handler->onPostCmdEvent($event);
7987
}
8088

81-
/**
82-
* Script callback for putting in composer scripts to download the
83-
* scaffold files.
84-
*
85-
* @param \Composer\Script\Event $event
86-
*/
87-
public static function scaffold(\Composer\Script\Event $event) {
88-
$handler = new Handler($event->getComposer(), $event->getIO());
89-
$handler->downloadScaffold();
90-
// Generate the autoload.php file after generating the scaffold files.
91-
$handler->generateAutoload();
92-
}
9389
}

0 commit comments

Comments
 (0)