protected function ViewConfigurationHandler::importFromJsonAsArray in Configuration Management 7.3
Overrides ConfigurationHandler::importFromJsonAsArray
File
- src/
Handlers/ ViewConfigurationHandler.php, line 56
Class
Namespace
Configuration\HandlersCode
protected function importFromJsonAsArray($file_content) {
// Load the view as an array, it will be converted to proper views objects later.
$array = json_decode($file_content, TRUE);
$configuration_data = $array['data'];
// Convert the array into objects that Views modules recognizes.
$view = $this->configuration_manager
->drupal()
->views_new_view();
$view->vid = NULL;
foreach ($configuration_data['display'] as $display) {
$view
->add_display($display['display_plugin'], $display['display_title'], $display['id']);
}
foreach ($configuration_data as $property => $value) {
if ($property != 'display') {
$view->{$property} = $value;
}
else {
foreach ($configuration_data['display'] as $id => $display_settings) {
foreach ($display_settings as $key => $value) {
$view->display[$id]->{$key} = $value;
}
}
}
}
$object = new \stdClass();
$object->identifier = $array['identifier'];
$object->notes = $array['notes'];
$object->tags = $array['tags'];
$object->dependencies = $array['dependencies'];
$object->parts = $array['parts'];
$object->modules = $array['modules'];
$object->data = $view;
unset($array);
return $object;
}