Skip to content

Commit

Permalink
Update drupal command annotation. (#3584)
Browse files Browse the repository at this point in the history
* [console] Validate extensionType as {'module', 'theme', 'profile', 'library'}.

* [console] Add bootstrap enum valid options are {'none', 'site', 'install'}.

* [console] Update DrupalCommandAnnotationReader class.
  • Loading branch information
jmolivas authored Nov 13, 2017
1 parent f27d0c2 commit 428c771
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/Annotations/DrupalCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ class DrupalCommand
public $extension;

/**
* @var string
* @Enum({"module", "theme", "profile", "library"})
*/
public $extensionType;

/**
* @var array
*/
public $dependencies;

/**
* @Enum({"none", "site", "install"})
*/
public $bootstrap;
}
12 changes: 9 additions & 3 deletions src/Annotations/DrupalCommandAnnotationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@ class DrupalCommandAnnotationReader
*/
public function readAnnotation($class)
{
$annotation = [];
$annotation = [
'extension' => null,
'extensionType' => null,
'dependencies' => [],
'bootstrap' => 'installed'
];
$reader = new AnnotationReader();
$drupalCommandAnnotation = $reader->getClassAnnotation(
new \ReflectionClass($class),
'Drupal\\Console\\Annotations\\DrupalCommand'
);
if ($drupalCommandAnnotation) {
$annotation['extension'] = $drupalCommandAnnotation->extension?:'';
$annotation['extensionType'] = $drupalCommandAnnotation->extensionType?:'';
$annotation['extension'] = $drupalCommandAnnotation->extension?:null;
$annotation['extensionType'] = $drupalCommandAnnotation->extensionType?:null;
$annotation['dependencies'] = $drupalCommandAnnotation->dependencies?:[];
$annotation['bootstrap'] = $drupalCommandAnnotation->bootstrap?:'install';
}

return $annotation;
Expand Down

0 comments on commit 428c771

Please sign in to comment.