Task/Generate/FileAssembler.php
protected function assembleFiles(ComponentCollection $component_collection, $files) {
    $return = array();

    foreach ($files as $file_id => $file_info) {
      if (!empty($file_info['path'])) {
        $filepath = $file_info['path'] . '/' . $file_info['filename'];
      }
      else {
        $filepath = $file_info['filename'];
      }

      $code = implode("\n", $file_info['body']);

      // Replace tokens in file contents and file path.
      // We get the tokens from the root component that was the nearest
      // requester.
      // TODO: consider changing this to be nearest root component; though
      // would require a change to File::containingComponent() among other
      // things.
      $file_component = $component_collection->getComponent($file_info['source_component_id']);
      $closest_requesting_root = $component_collection->getClosestRequestingRootComponent($file_component);
      $variables = $closest_requesting_root->getReplacements();
      $code = strtr($code, $variables);
      $filepath = strtr($filepath, $variables);

      $return[$filepath] = $code;
    }

    return $return;
  }
protected function assembleFiles(ComponentCollection $component_collection, $files) {
    $return = array();

    foreach ($files as $file_id => $file_info) {
      if (!empty($file_info['path'])) {
        $filepath = $file_info['path'] . '/' . $file_info['filename'];
      }
      else {
        $filepath = $file_info['filename'];
      }

      $code = implode("\n", $file_info['body']);

      // Replace tokens in file contents and file path.
      // We get the tokens from the root component that was the nearest
      // requester.
      // TODO: consider changing this to be nearest root component; though
      // would require a change to File::containingComponent() among other
      // things.
      $file_component = $component_collection->getComponent($file_info['source_component_id']);
      $closest_requesting_root = $component_collection->getClosestRequestingRootComponent($file_component);
      $variables = $closest_requesting_root->getReplacements();
      $code = strtr($code, $variables);
      $filepath = strtr($filepath, $variables);

      $return[$filepath] = $code;
    }

    return $return;
  }
protected function assembleFiles ( ComponentCollection $ component_collection , $ files ) { $ return = array ( ) ; foreach ( $ files as $ file_id => $ file_info ) { if ( ! empty ( $ file_info [ 'path' ] ) ) { $ filepath = $ file_info [ 'path' ] . '/' . $ file_info [ 'filename' ] ; } else { $ filepath = $ file_info [ 'filename' ] ; } $ code = implode ( "\n" , $ file_info [ 'body' ] ) ; // Replace tokens in file contents and file path. // We get the tokens from the root component that was the nearest // requester. // TODO: consider changing this to be nearest root component; though // would require a change to File::containingComponent() among other // things. $ file_component = $ component_collection -> getComponent ( $ file_info [ 'source_component_id' ] ) ; $ closest_requesting_root = $ component_collection -> getClosestRequestingRootComponent ( $ file_component ) ; $ variables = $ closest_requesting_root -> getReplacements ( ) ; $ code = strtr ( $ code , $ variables ) ; $ filepath = strtr ( $ filepath , $ variables ) ; $ return [ $ filepath ] = $ code ; } return $ return ; }
Assemble file info into filename and code.

@param \DrupalCodeBuilder\Generator\Collection\ComponentCollection $component_collection
The component collection.
@param $files
An array of file info, as compiled by collectFiles().

@return
An array of files ready for output. Keys are the filepath and filename
relative to the module folder (eg, 'foo.module', 'tests/module.test');
values are strings of the contents for each file.
Assemble file info into filename and code .