public function FeaturesUIController::detect in Features 8.3
Same name and namespace in other branches
- 8.4 modules/features_ui/src/Controller/FeaturesUIController.php \Drupal\features_ui\Controller\FeaturesUIController::detect()
Returns a list of auto-detected config items for a feature.
Parameters
string $name: Short machine name of feature to process.
Return value
array List of auto-detected config items, keyed by type and short name.
1 string reference to 'FeaturesUIController::detect'
- features_ui.routing.yml in modules/
features_ui/ features_ui.routing.yml - modules/features_ui/features_ui.routing.yml
File
- modules/
features_ui/ src/ Controller/ FeaturesUIController.php, line 62
Class
- FeaturesUIController
- Returns ajax responses for the Features UI.
Namespace
Drupal\features_ui\ControllerCode
public function detect($name) {
$detected = [];
$this->assigner
->assignConfigPackages();
$config_collection = $this->featuresManager
->getConfigCollection();
$items = $_POST['items'];
if (!empty($items)) {
$excluded = !empty($_POST['excluded']) ? $_POST['excluded'] : [];
$selected = [];
foreach ($items as $key) {
preg_match('/^([^\\[]+)(\\[.+\\])?\\[(.+)\\]\\[(.+)\\]$/', $key, $matches);
if (!empty($matches[1]) && !empty($matches[4])) {
$component = $matches[1];
$item = $this
->domDecode($matches[4]);
if (!isset($excluded[$component][$item])) {
$selected[] = $this->featuresManager
->getFullName($component, $item);
}
}
}
$detected = !empty($selected) ? $this
->getConfigDependents($selected, $name) : [];
$detected = array_merge($detected, $selected);
}
$result = [];
foreach ($detected as $config_name) {
$item = $config_collection[$config_name];
$result[$item
->getType()][$item
->getShortName()] = $item
->getName();
}
return new JsonResponse($result);
}