function media_directories_install in Media Directories 8
Same name and namespace in other branches
- 3.x media_directories.install \media_directories_install()
- 2.x media_directories.install \media_directories_install()
Implements hook_install().
Throws
\Drupal\Core\Entity\EntityStorageException
File
- ./
media_directories.install, line 15 - Installation and update impementations.
Code
function media_directories_install() {
$filter = [
'id' => 'directory',
'table' => 'media_field_data',
'field' => 'directory',
'relationship' => 'none',
'group_type' => 'group',
'admin_label' => '',
'operator' => 'or',
'value' => [],
'group' => 1,
'exposed' => TRUE,
'expose' => [
'operator_id' => 'directory_op',
'label' => 'Directory',
'description' => '',
'use_operator' => FALSE,
'operator' => 'directory_op',
'identifier' => 'directory',
'required' => FALSE,
'remember' => FALSE,
'multiple' => FALSE,
'remember_roles' => [],
'reduce' => FALSE,
],
'is_grouped' => FALSE,
'group_info' => [],
'reduce_duplicates' => FALSE,
'error_message' => TRUE,
'entity_type' => 'media',
'entity_field' => 'directory',
'plugin_id' => 'media_directory',
];
// Alter Media library view configuration.
$view = View::load('media_library');
if ($view !== NULL) {
$default_display =& $view
->getDisplay('default');
$widget_display =& $view
->getDisplay('widget');
$widget_table_display =& $view
->getDisplay('widget_table');
$default_display['display_options']['filters'] = array_merge([
'directory' => $filter,
], $default_display['display_options']['filters']);
$widget_display['display_options']['filters'] = array_merge([
'directory' => $filter,
], $widget_display['display_options']['filters']);
$widget_table_display['display_options']['filters'] = array_merge([
'directory' => $filter,
], $widget_table_display['display_options']['filters']);
$view
->save();
unset($default_display);
}
// Alter default Media view configuration.
$view_table = View::load('media');
if ($view_table !== NULL) {
$default_display =& $view_table
->getDisplay('default');
$default_display['display_options']['filters'] = array_merge([
'directory' => $filter,
], $default_display['display_options']['filters']);
$view_table
->save();
}
}