/** * Apply default NextEuropa configuration to a specific content type. * * This method is usually called into hook_install(). * * @param string $type * Content type machine name. * * @see nexteuropa_pages_install() */ public function applyDefaultConfigurationToContentType($type) { // Replace title field. multisite_config_service('title')->replaceTitleField('node', $type, 'title'); multisite_config_service('entity_translation')->enableEntityTranslation($type); // Add Organic Group fields. multisite_config_service('og')->createOgGroupAudienceField('node', $type); multisite_config_service('og')->createOgContentAccessField('node', $type); // Enable Workbench Moderation. multisite_config_service('workbench_moderation')->enableWorkbenchModeration($type); // Grant OG permissions if NextEuropa Editorial feature is enabled. if (module_exists('nexteuropa_editorial')) { $og_permissions = array(); $og_permissions['contributor'] = array('create ' . $type . ' content', 'update own ' . $type . ' content', 'delete own ' . $type . ' content'); $og_permissions['validator'] = $og_permissions['publisher'] = $og_permissions['administrator member'] = array('create ' . $type . ' content', 'update own ' . $type . ' content', 'delete own ' . $type . ' content', 'update any ' . $type . ' content', 'delete any ' . $type . ' content'); foreach ($og_permissions as $role => $permissions) { multisite_config_service('og')->grantOgPermissions($role, $permissions, 'node', 'editorial_team', 'og'); } } // Enable Linkchecker control for "Page" content type. multisite_config_service('linkchecker')->enableLinkcheckerForContentType($type); // Enable default scheduling options for a specific content type. multisite_config_service('scheduler')->enableSchedulerForContentType($type); // Set unpublish moderation state to "expired". // This call cannot be included in the API method above since it is // a configuration specific to NextEuropa . variable_set('scheduler_unpublish_moderation_state_' . $type, 'expired'); }
/** * Test base field saving. * * @dataProvider fieldDataProvider */ public function testFieldSaving($field_name, $vocabulary_name) { $service = multisite_config_service('field'); $service->createBaseField($field_name, 'taxonomy_term_reference')->setVocabulary($vocabulary_name)->save(); $field = field_info_field($field_name); $this->assertEquals('taxonomy_term_reference', $field['type']); $this->assertEquals($field_name, $field['field_name']); $this->assertEquals('taxonomy', $field['module']); $this->assertEquals(1, $field['cardinality']); $this->assertEquals($vocabulary_name, $field['settings']['allowed_values'][0]['vocabulary']); field_delete_field($field_name); }
/** * Test case when both service class and module do not exist. * * @expectedException \Exception * * @expectedExceptionMessage Service class "\Drupal\not_existing_module\Config" and module "not_existing_module" does not exists. */ public function testNotExistingServiceClassAndModule() { $service = multisite_config_service('not_existing_module'); $this->assertEquals('Drupal\\multisite_config\\ConfigBase', get_class($service)); }
/** * Enables translation for a field. * * @param string $field * The name of the field. * * @When I enable translation for field :field */ public function enableTranslationForField($field) { multisite_config_service('field')->enableFieldTranslation($field); }