class DrupalCodeBuilder in Module Builder 8.3
Service class that wraps around the DCB library, to make it injectable.
Hierarchy
- class \Drupal\module_builder\DrupalCodeBuilder
Expanded class hierarchy of DrupalCodeBuilder
5 files declare their use of DrupalCodeBuilder
- ComponentFormBase.php in src/
Form/ ComponentFormBase.php - DrupalCodeBuilderDevel.php in module_builder_devel/
src/ DrupalCodeBuilderDevel.php - DrupalCodeBuilderTestSampleData.php in tests/
modules/ test_dummy_module_write_location/ src/ DrupalCodeBuilderTestSampleData.php - DrupalCodeBuilderTestSamples.php in module_builder_devel/
src/ DrupalCodeBuilderTestSamples.php - TestDrupalCodeBuilder.php in tests/
modules/ module_builder_test_component_type/ src/ TestDrupalCodeBuilder.php
1 string reference to 'DrupalCodeBuilder'
1 service uses DrupalCodeBuilder
File
- src/
DrupalCodeBuilder.php, line 8
Namespace
Drupal\module_builderView source
class DrupalCodeBuilder {
/**
* Whether the library has been initialized.
*
* @var bool
*/
protected $loaded = FALSE;
/**
* Gets a task handler from the library.
*
* Same parameters as \DrupalCodeBuilder\Factory::getTask().
*
* @param string $task_name
* The task name.
* @param mixed $task_options
* (optional) Options for the task.
*
* @return
* The task object.
*/
public function getTask($task_name, $task_options = NULL) {
if (!$this->loaded) {
$this
->loadLibrary();
}
return \DrupalCodeBuilder\Factory::getTask($task_name, $task_options);
}
/**
* Loads the Drupal Coder Builder library and sets the environment.
*
* @throws \Exception
* Throws an exception if the library can't be found.
*/
public function loadLibrary() {
if (!class_exists(\DrupalCodeBuilder\Factory::class)) {
throw new \Exception("Mising library.");
}
$this
->doLoadLibrary();
$this->loaded = TRUE;
}
/**
* Helper for loadLibrary() for ease of overriding.
*/
protected function doLoadLibrary() {
// TODO: add an environment class with a more appropriate name.
\DrupalCodeBuilder\Factory::setEnvironmentLocalClass('DrupalLibrary')
->setCoreVersionNumber(\Drupal::VERSION);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalCodeBuilder:: |
protected | property | Whether the library has been initialized. | |
DrupalCodeBuilder:: |
protected | function | Helper for loadLibrary() for ease of overriding. | 4 |
DrupalCodeBuilder:: |
public | function | Gets a task handler from the library. | |
DrupalCodeBuilder:: |
public | function | Loads the Drupal Coder Builder library and sets the environment. |