Task/Generate.php
public function generateComponent($component_data, $existing_module_files = []) {
    // Add the top-level component to the data.
    $component_type = $this->base;
    $component_data['base'] = $component_type;

    // The component name is just the same as the type for the base generator.
    $component_name = $component_type;

    // Assemble the component list from the request data.
    $component_collection = $this->getHelper('ComponentCollector')->assembleComponentList($component_data);
    // Backward-compatiblity.
    // TODO: replace this.
    $this->component_list = $component_collection->getComponents();

    \DrupalCodeBuilder\Factory::getEnvironment()->log(array_keys($this->component_list), "Complete component list names");

    // Let each component detect whether it already exists in the given module
    // files.
    $this->detectExistence($this->component_list, $existing_module_files);

    // Now assemble them into a tree.
    // Calls containingComponent() on everything and puts it into a 2-D array
    // of parent => [children].
    // TODO: replace use of $tree with accessor on the collection.
    $tree = $component_collection->assembleContainmentTree();

    \DrupalCodeBuilder\Factory::getEnvironment()->log($tree, "Component tree");

    $files_assembled = $this->component_list = $this->getHelper('FileAssembler')->generateFiles(
      $component_data,
      $component_collection
    );

    return $files_assembled;
  }
public function generateComponent($component_data, $existing_module_files = []) {
    // Add the top-level component to the data.
    $component_type = $this->base;
    $component_data['base'] = $component_type;

    // The component name is just the same as the type for the base generator.
    $component_name = $component_type;

    // Assemble the component list from the request data.
    $component_collection = $this->getHelper('ComponentCollector')->assembleComponentList($component_data);
    // Backward-compatiblity.
    // TODO: replace this.
    $this->component_list = $component_collection->getComponents();

    \DrupalCodeBuilder\Factory::getEnvironment()->log(array_keys($this->component_list), "Complete component list names");

    // Let each component detect whether it already exists in the given module
    // files.
    $this->detectExistence($this->component_list, $existing_module_files);

    // Now assemble them into a tree.
    // Calls containingComponent() on everything and puts it into a 2-D array
    // of parent => [children].
    // TODO: replace use of $tree with accessor on the collection.
    $tree = $component_collection->assembleContainmentTree();

    \DrupalCodeBuilder\Factory::getEnvironment()->log($tree, "Component tree");

    $files_assembled = $this->component_list = $this->getHelper('FileAssembler')->generateFiles(
      $component_data,
      $component_collection
    );

    return $files_assembled;
  }
public function generateComponent ( $ component_data , $ existing_module_files = [ ] ) { // Add the top-level component to the data. $ component_type = $ this -> base ; $ component_data [ 'base' ] = $ component_type ; // The component name is just the same as the type for the base generator. $ component_name = $ component_type ; // Assemble the component list from the request data. $ component_collection = $ this -> getHelper ( 'ComponentCollector' ) -> assembleComponentList ( $ component_data ) ; // Backward-compatiblity. // TODO: replace this. $ this -> component_list = $ component_collection -> getComponents ( ) ; \ DrupalCodeBuilder \ Factory :: getEnvironment ( ) -> log ( array_keys ( $ this -> component_list ) , "Complete component list names" ) ; // Let each component detect whether it already exists in the given module // files. $ this -> detectExistence ( $ this -> component_list , $ existing_module_files ) ; // Now assemble them into a tree. // Calls containingComponent() on everything and puts it into a 2-D array // of parent => [children]. // TODO: replace use of $tree with accessor on the collection. $ tree = $ component_collection -> assembleContainmentTree ( ) ; \ DrupalCodeBuilder \ Factory :: getEnvironment ( ) -> log ( $ tree , "Component tree" ) ; $ files_assembled = $ this -> component_list = $ this -> getHelper ( 'FileAssembler' ) -> generateFiles ( $ component_data , $ component_collection ) ; return $ files_assembled ; }
Generate the files for a component.

@param $component_data
An associative array of data for the component. Values depend on the
component class. For details, see the constructor of the generator, of the
form DrupalCodeBuilder\Generator\COMPONENT, e.g.
DrupalCodeBuilder\Generator\Module::__construct().
@param $existing_module_files
(optional) An array of existing files for this module. Keys should be
file paths relative to the module, values absolute paths.

@return
A files array whose keys are filepaths (relative to the module folder) and
values are the code destined for each file.

@throws \DrupalCodeBuilder\Exception\InvalidInputException
Throws an exception if the given data is invalid.
Generate the files for a component .