abstract class AbstractYamlPatternsDeriver in UI Patterns 8
Class AbstractYamlPatternsDeriver.
Derive pattern plugin definitions stored in YAML files.
@package Drupal\ui_patterns\Deriver
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\ui_patterns\Plugin\Deriver\AbstractPatternsDeriver implements ContainerDeriverInterface, PatternsDeriverInterface uses StringTranslationTrait
- class \Drupal\ui_patterns\Plugin\Deriver\AbstractYamlPatternsDeriver implements YamlPatternsDeriverInterface
- class \Drupal\ui_patterns\Plugin\Deriver\AbstractPatternsDeriver implements ContainerDeriverInterface, PatternsDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of AbstractYamlPatternsDeriver
1 file declares its use of AbstractYamlPatternsDeriver
- LibraryDeriver.php in modules/
ui_patterns_library/ src/ Plugin/ Deriver/ LibraryDeriver.php
File
- src/
Plugin/ Deriver/ AbstractYamlPatternsDeriver.php, line 18
Namespace
Drupal\ui_patterns\Plugin\DeriverView source
abstract class AbstractYamlPatternsDeriver extends AbstractPatternsDeriver implements YamlPatternsDeriverInterface {
/**
* File system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* Constructor.
*
* @param string $base_plugin_id
* The base plugin ID.
* @param \Drupal\Core\TypedData\TypedDataManager $typed_data_manager
* Typed data manager service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* Messenger.
* @param \Drupal\Core\File\FileSystemInterface $file_system
* File system service.
*/
public function __construct($base_plugin_id, TypedDataManager $typed_data_manager, MessengerInterface $messenger, FileSystemInterface $file_system) {
parent::__construct($base_plugin_id, $typed_data_manager, $messenger);
$this->fileSystem = $file_system;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('typed_data_manager'), $container
->get('messenger'), $container
->get('file_system'));
}
/**
* {@inheritdoc}
*/
public function fileScanDirectory($directory) {
if (!is_dir($directory)) {
return [];
}
$options = [
'nomask' => $this
->getNoMask(),
];
$extensions = $this
->getFileExtensions();
$extensions = array_map('preg_quote', $extensions);
$extensions = implode('|', $extensions);
$files = $this->fileSystem
->scanDirectory($directory, "/{$extensions}\$/", $options);
// In different file systems order of files in a folder can be different
// that can break tests. So let's sort them alphabetically manually.
ksort($files);
return $files;
}
/**
* Returns a regular expression for directories to be excluded in a file scan.
*
* @return string
* Regular expression.
*/
protected function getNoMask() {
$ignore = Settings::get('file_scan_ignore_directories', []);
// We add 'tests' directory to the ones found in settings.
$ignore[] = 'tests';
array_walk($ignore, function (&$value) {
$value = preg_quote($value, '/');
});
return '/^' . implode('|', $ignore) . '$/';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AbstractPatternsDeriver:: |
protected | property | The messenger. | |
AbstractPatternsDeriver:: |
protected | property | Typed data manager service. | |
AbstractPatternsDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
AbstractPatternsDeriver:: |
protected | function | Get pattern data object. | |
AbstractPatternsDeriver:: |
protected | function | Validate pattern definition. | |
AbstractYamlPatternsDeriver:: |
protected | property | File system service. | |
AbstractYamlPatternsDeriver:: |
public static | function |
Creates a new class instance. Overrides AbstractPatternsDeriver:: |
1 |
AbstractYamlPatternsDeriver:: |
public | function |
Wrapper method for global function call. Overrides YamlPatternsDeriverInterface:: |
|
AbstractYamlPatternsDeriver:: |
protected | function | Returns a regular expression for directories to be excluded in a file scan. | |
AbstractYamlPatternsDeriver:: |
public | function |
Constructor. Overrides AbstractPatternsDeriver:: |
1 |
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
PatternsDeriverInterface:: |
public | function | Get pattern definition objects. | 1 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
YamlPatternsDeriverInterface:: |
public | function | Get list of possible yaml definition file extensions. | 1 |