View source
<?php
namespace Drupal\social_group_secret;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ConfigFactoryOverrideInterface;
use Drupal\Core\Config\StorageInterface;
class SocialGroupSecretConfigOverride implements ConfigFactoryOverrideInterface {
protected $configFactory;
public function __construct(ConfigFactoryInterface $config_factory) {
$this->configFactory = $config_factory;
}
public function loadOverrides($names) {
$overrides = [];
$config_names = [
'search_api.index.social_all',
'search_api.index.social_groups',
];
foreach ($config_names as $config_name) {
if (in_array($config_name, $names)) {
$overrides[$config_name] = [
'field_settings' => [
'rendered_item' => [
'configuration' => [
'view_mode' => [
'entity:group' => [
'secret_group' => 'teaser',
],
],
],
],
],
];
}
}
$config_names = [
'views.view.search_all',
'views.view.search_groups',
];
foreach ($config_names as $config_name) {
if (in_array($config_name, $names)) {
$overrides[$config_name] = [
'display' => [
'default' => [
'display_options' => [
'row' => [
'options' => [
'view_modes' => [
'entity:group' => [
'secret_group' => 'teaser',
],
],
],
],
],
],
],
];
}
}
$config_names = [
'views.view.group_members',
'views.view.group_manage_members',
];
foreach ($config_names as $config_name) {
if (in_array($config_name, $names)) {
$overrides[$config_name] = [
'dependencies' => [
'config' => [
'secret_group-group_membership' => 'group.content_type.secret_group-group_membership',
],
],
'display' => [
'default' => [
'display_options' => [
'filters' => [
'type' => [
'value' => [
'secret_group-group_membership' => 'secret_group-group_membership',
],
],
],
],
],
],
];
}
}
$config_names = [
'views.view.group_events' => 'secret_group-group_node-event',
'views.view.group_topics' => 'secret_group-group_node-topic',
];
foreach ($config_names as $config_name => $content_type) {
if (in_array($config_name, $names)) {
$overrides[$config_name] = [
'dependencies' => [
'config' => [
'group-content-type' => 'group.content_type.' . $content_type,
'group-type' => 'group.type',
],
],
'display' => [
'default' => [
'display_options' => [
'arguments' => [
'gid' => [
'validate_options' => [
'bundles' => [
'secret_group' => 'secret_group',
],
],
],
],
'filters' => [
'type' => [
'value' => [
$content_type => $content_type,
],
],
],
],
],
],
];
}
}
$config_name = 'message.template.create_content_in_joined_group';
if (in_array($config_name, $names, FALSE)) {
$overrides[$config_name]['third_party_settings']['activity_logger']['activity_bundle_entities'] = [
'group_content-secret_group-group_node-event' => 'group_content-secret_group-group_node-event',
'group_content-secret_group-group_node-topic' => 'group_content-secret_group-group_node-topic',
];
}
$config_name = 'message.template.join_to_group';
if (in_array($config_name, $names, FALSE)) {
$overrides[$config_name]['third_party_settings']['activity_logger']['activity_bundle_entities'] = [
'group_content-secret_group-group_membership' => 'group_content-secret_group-group_membership',
];
}
$config_name = 'message.template.invited_to_join_group';
if (in_array($config_name, $names, FALSE)) {
$overrides[$config_name]['third_party_settings']['activity_logger']['activity_bundle_entities'] = [
'group_content-secret_group-group_invitation' => 'group_content-secret_group-group_invitation',
];
}
$config_name = 'views.view.newest_groups';
$displays = [
'page_all_groups',
'block_newest_groups',
];
if (in_array($config_name, $names)) {
foreach ($displays as $display_name) {
$overrides[$config_name] = [
'display' => [
$display_name => [
'cache_metadata' => [
'contexts' => [
'user' => 'user',
],
],
],
],
];
}
}
return $overrides;
}
public function getCacheSuffix() {
return 'SocialGroupSecretConfigOverride';
}
public function getCacheableMetadata($name) {
return new CacheableMetadata();
}
public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
return NULL;
}
}