class ConfigurableContentLoader in YAML Content 8.2
A ContentLoader implementation supporting configuration options.
@todo Use service parameter for override-able default options.
Hierarchy
- class \Drupal\yaml_content\ContentLoader\ContentLoaderBase implements ContentLoaderInterface
- class \Drupal\yaml_content\ContentLoader\ConfigurableContentLoader implements ContentLoaderInterface
Expanded class hierarchy of ConfigurableContentLoader
See also
\Drupal\yaml_content\ContentLoader\ContentLoaderInterface
\Drupal\yaml_content\ContentLoader\ContentLoaderBase
1 string reference to 'ConfigurableContentLoader'
1 service uses ConfigurableContentLoader
File
- src/
ContentLoader/ ConfigurableContentLoader.php, line 17
Namespace
Drupal\yaml_content\ContentLoaderView source
class ConfigurableContentLoader extends ContentLoaderBase implements ContentLoaderInterface {
/**
* A collection of configurable options affecting execution behavior.
*
* @var array
*/
protected $options;
/**
* {@inheritdoc}
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager, SerializationInterface $parser, EventDispatcherInterface $dispatcher) {
parent::__construct($entityTypeManager, $parser, $dispatcher);
// Initialize with default configuration options.
$this->options = $this
->getDefaultOptions();
}
/**
* Set a configurable option value.
*
* @param string $option
* The name of the option being configured.
* @param mixed $value
* The value to assign into the option.
*
* @return \Drupal\yaml_content\ContentLoader\ContentLoaderInterface
* The called object.
*/
public function setOption($option, $value) {
$this->options[$option] = $value;
return $this;
}
/**
* Get the value from a configured option.
*
* @param string $option
* The name of the option value to retrieve.
*
* @return mixed|null
* The value of the specified option or NULL if the option is unset.
*/
public function getOption($option) {
$value = NULL;
if (isset($this->options[$option])) {
$value = $this->options[$option];
}
return $value;
}
/**
* Fetch all configured options.
*
* @return array
* All configured options for this ContentLoader.
*/
public function getOptions() {
return $this->options + $this
->getDefaultOptions();
}
/**
* Set multiple configuration options.
*
* @param array $options
* A collection of configuration values to assign. These are used to
* override currently set or default values.
*
* @return $this
* The called object.
*/
public function setOptions(array $options) {
$this->options = $options + $this->options + $this
->getDefaultOptions();
return $this;
}
/**
* Fetch all default configuration options.
*
* @return array
* A collection of all default options for this ContentLoader.
*
* @todo Integrate default options with service parameters.
*/
public function getDefaultOptions() {
return [];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigurableContentLoader:: |
protected | property | A collection of configurable options affecting execution behavior. | |
ConfigurableContentLoader:: |
public | function | Fetch all default configuration options. | |
ConfigurableContentLoader:: |
public | function | Get the value from a configured option. | |
ConfigurableContentLoader:: |
public | function | Fetch all configured options. | |
ConfigurableContentLoader:: |
public | function | Set a configurable option value. | |
ConfigurableContentLoader:: |
public | function | Set multiple configuration options. | |
ConfigurableContentLoader:: |
public | function |
Constructs a ContentLoaderBase object. Overrides ContentLoaderBase:: |
|
ContentLoaderBase:: |
protected | property | The file path for the content file currently being loaded. | |
ContentLoaderBase:: |
protected | property | Event dispatcher service to report events throughout the loading process. | |
ContentLoaderBase:: |
protected | property | Entity type manager service to dynamically handle entities. | |
ContentLoaderBase:: |
protected | property | The array of content parsed from the content file being loaded. | |
ContentLoaderBase:: |
protected | property | Content file parser utility. | |
ContentLoaderBase:: |
protected | property | The file path where content files should be loaded from. | |
ContentLoaderBase:: |
public | function | Set or assign a field value based on field cardinality. | |
ContentLoaderBase:: |
public | function |
Build an entity from the provided content data. Overrides ContentLoaderInterface:: |
|
ContentLoaderBase:: |
public | function | Load an entity from a loaded import data outline. | 1 |
ContentLoaderBase:: |
public | function | Process import data into an appropriate field value and assign it. | 1 |
ContentLoaderBase:: |
public | function | Process import data for an individual field list item value. | 1 |
ContentLoaderBase:: |
public | function |
Load all demo content for a set of parsed data. Overrides ContentLoaderInterface:: |
1 |
ContentLoaderBase:: |
public | function |
Load a batch of content files. Overrides ContentLoaderInterface:: |
|
ContentLoaderBase:: |
public | function |
Parse the given yaml content file into an array. Overrides ContentLoaderInterface:: |
|
ContentLoaderBase:: |
public | function | Set a path prefix for all content files to be loaded from. |