public function ConfigSubscriber::onConfigExport in Menu Item Extras 8.2
Adds a module dependency for all config files that are associated with a view_mode field on the menu_link_content entity during the config export.
Parameters
\Drupal\Core\Config\StorageTransformEvent $event: The configuration event.
File
- src/
EventSubscriber/ ConfigSubscriber.php, line 49
Class
- ConfigSubscriber
- Provides a ConfigSubscriber that adds a module dependency for all configurations related to the view_mode field on menu_link_content entities during a config export.
Namespace
Drupal\menu_item_extras\EventSubscriberCode
public function onConfigExport(StorageTransformEvent $event) {
$storage = $event
->getStorage();
$export_configs = $storage
->listAll();
// add module dependency to all matching configs
foreach ($export_configs as $config_name) {
if (preg_match('@^.*\\.menu_link_content\\..*view_mode$@', $config_name)) {
$config = $storage
->read($config_name);
// do not duplicate an existing module dependency
if (empty($config['dependencies']['module']) || !in_array('menu_item_extras', $config['dependencies']['module'], TRUE)) {
$config['dependencies']['module'][] = 'menu_item_extras';
$storage
->write($config_name, $config);
}
}
}
}