/** * {@inheritdoc} */ public function setUp() { parent::setUp(); // Add the languages. $this->installConfig(['language']); $this->installEntitySchema('tmgmt_job'); $this->installEntitySchema('tmgmt_job_item'); $this->installEntitySchema('tmgmt_message'); $this->installSchema('system', array('router')); $this->installSchema('locale', array('locales_location', 'locales_source', 'locales_target')); \Drupal::service('router.builder')->rebuild(); tmgmt_translator_auto_create(\Drupal::service('plugin.manager.tmgmt.translator')->getDefinition('test_translator')); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); // Add the languages. $this->installConfig(['language']); ConfigurableLanguage::createFromLangcode('de')->save(); ConfigurableLanguage::createFromLangcode('cs')->save(); $this->installEntitySchema('tmgmt_job'); $this->installEntitySchema('tmgmt_job_item'); $this->installEntitySchema('tmgmt_remote'); $this->installEntitySchema('tmgmt_message'); $this->installEntitySchema('entity_test_rev'); $this->installEntitySchema('entity_test_mulrev'); $this->installEntitySchema('entity_test_mul'); $this->container->get('content_translation.manager')->setEnabled('entity_test_mul', 'entity_test_mul', TRUE); $this->installSchema('system', array('router')); $this->installSchema('node', array('node_access')); \Drupal::moduleHandler()->loadInclude('entity_test', 'install'); entity_test_install(); // Make the test field translatable. $field_storage = FieldStorageConfig::loadByName('entity_test_mul', 'field_test_text'); $field_storage->setCardinality(2); $field_storage->save(); $field = FieldConfig::loadByName('entity_test_mul', 'entity_test_mul', 'field_test_text'); $field->setTranslatable(TRUE); $field->save(); // Add an image field and make it translatable. $this->installEntitySchema('file'); $this->installSchema('file', array('file_usage')); $this->installConfig(array('node')); \Drupal::service('router.builder')->rebuild(); $field_storage = FieldStorageConfig::create(array('field_name' => 'image_test', 'entity_type' => $this->entityTypeId, 'type' => 'image', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'translatable' => TRUE)); $field_storage->save(); FieldConfig::create(array('entity_type' => $this->entityTypeId, 'field_storage' => $field_storage, 'bundle' => $this->entityTypeId, 'label' => $this->image_label = $this->randomMachineName()))->save(); file_unmanaged_copy(DRUPAL_ROOT . '/core/misc/druplicon.png', 'public://example.jpg'); $this->image = entity_create('file', array('uri' => 'public://example.jpg')); $this->image->save(); tmgmt_translator_auto_create(\Drupal::service('plugin.manager.tmgmt.translator')->getDefinition('test_translator')); }
/** * Auto creates a translator from a translator plugin definition. * * @param string $plugin * The machine-readable name of a translator plugin. */ public function createDefaultTranslatorFromPlugin($plugin) { drupal_static_reset('_tmgmt_plugin_info'); tmgmt_translator_auto_create($plugin); }