diff -u b/src/Form/JobForm.php b/src/Form/JobForm.php --- b/src/Form/JobForm.php +++ b/src/Form/JobForm.php @@ -422,12 +422,14 @@ // Load the selected translator. $translator = $job->getTranslator(); // Check translator availability. + $available_status = $translator->isAvailable(); + $translatable_status = $translator->canTranslate($job); if (!empty($translator)) { - if (!($translator->isAvailable()->getSuccess())) { - $form_state->setErrorByName('translator', $translator->isAvailable()->getMessage()); + if (!($available_status->getSuccess())) { + $form_state->setErrorByName('translator', $available_status->getMessage()); } - elseif (!$translator->canTranslate($job)->getSuccess()) { - $form_state->setErrorByName('translator', $translator->canTranslate($job)->getMessage()); + elseif (!$translatable_status->getSuccess()) { + $form_state->setErrorByName('translator', $translatable_status->getMessage()); } } } @@ -499,7 +501,7 @@ return $form; } $translator = $job->getTranslator(); - if (!$translator->isAvailable()) { + if (!$translator->isAvailable()->getSuccess()) { $result = AvailableResult::no(t('@translator is not available. Make sure it is properly :configured.', array('@translator' => $translator->label(), ':configured' => $translator->link(t('configured'))))); $form['#description'] = Xss::filter($result->getMessage()); } diff -u b/src/Translator/AvailableResult.php b/src/Translator/AvailableResult.php --- b/src/Translator/AvailableResult.php +++ b/src/Translator/AvailableResult.php @@ -21,20 +21,2 @@ class AvailableResult extends TranslatorResult { - - /** - * {@inheritdoc} - */ - public static function yes() { - $result = new AvailableResult(); - $result->setYes(); - return $result; -} - - /** - * {@inheritdoc} - */ - public static function no($message) { - $result = new AvailableResult(); - $result->setNo($message); - return $result; - } } diff -u b/src/Translator/TranslatableResult.php b/src/Translator/TranslatableResult.php --- b/src/Translator/TranslatableResult.php +++ b/src/Translator/TranslatableResult.php @@ -22,23 +22,2 @@ class TranslatableResult extends TranslatorResult { - - /** - * {@inheritdoc} - * - */ - public static function yes() { - $result = new TranslatableResult(); - $result->setYes(); - return $result; - } - - /** - * {@inheritdoc} - * - */ - public static function no($message) { - $result = new TranslatableResult(); - $result->setNo($message); - return $result; - } - } diff -u b/src/Translator/TranslatorResult.php b/src/Translator/TranslatorResult.php --- b/src/Translator/TranslatorResult.php +++ b/src/Translator/TranslatorResult.php @@ -29,7 +29,7 @@ /** * Returns the object message. */ - public static function getMessage() { + public function getMessage() { $argumented_message = t(self::$message); return $argumented_message; } @@ -37,7 +37,7 @@ /** * Returns the object state on success. */ - public static function getSuccess() { + public function getSuccess() { return self::$success; } @@ -47,7 +47,7 @@ * @param string $message * This is the value to be saved as message for object. */ - protected static function setNo($message) { + protected function setNo($message) { self::$success = FALSE; self::$message = $message; } @@ -55,7 +55,7 @@ /** * Sets the value success to TRUE. */ - protected static function setYes() { + protected function setYes() { self::$success = TRUE; } @@ -66,7 +66,9 @@ * This returns the instance of the object with desired values. */ public static function yes() { - return self; + $result = new static(); + $result->setYes(); + return $result; } /** @@ -77,5 +79,7 @@ */ public static function no($message) { - return self; + $result = new static(); + $result->setNo($message); + return $result; } } only in patch2: unchanged: --- a/sources/tmgmt_config/src/ConfigSourcePluginUi.php +++ b/sources/tmgmt_config/src/ConfigSourcePluginUi.php @@ -139,9 +139,7 @@ class ConfigSourcePluginUi extends SourcePluginUiBase { $row = array( 'id' => $entity->id(), - // If the entity type is FieldConfig, we list the field of the fieldable - // entity type which doesn't have a link. - 'title' => $entity->url('edit-form') ? $entity->link($label) : $label, + 'title' => $entity->link($label), ); // Load entity translation specific data. @@ -297,27 +295,18 @@ class ConfigSourcePluginUi extends SourcePluginUiBase { $item_id = $definition['id']; $items[$item_id]['label'] = $definition['title'];; $items[$item_id]['langcode'] = \Drupal::config($definition['names'][0])->get('langcode') ?: 'en'; - $items[$item_id]['type'] = $type; } } else { $entity_type = \Drupal::entityManager()->getDefinition($type); $entity_ids = str_replace($entity_type->getConfigPrefix() . '.', '', array_filter($form_state->getValue('items'))); + $entities = entity_load_multiple($type, $entity_ids); foreach ($entities as $entity) { /* @var $entity \Drupal\Core\Entity\EntityInterface */ $item_id = $entity->getConfigDependencyName(); $items[$item_id]['label'] = $entity->label(); $items[$item_id]['langcode'] = $entity->language()->getId(); - - // The type cannot be field_config, should be the id of the - // fieldable entity type. - if ($type == 'field_config') { - $items[$item_id]['type'] = $entity->get('entity_type') . '_fields'; - } - else { - $items[$item_id]['type'] = $type; - } } } $source_lang_registry = array(); @@ -332,7 +321,7 @@ class ConfigSourcePluginUi extends SourcePluginUiBase { // Create new job. $job = tmgmt_job_create($source_lang, LanguageInterface::LANGCODE_NOT_SPECIFIED, \Drupal::currentUser()->id()); // Add initial job item. - $job->addItem('config', $extra['type'], $id); + $job->addItem('config', $type, $id); // Add job identifier into registry $source_lang_registry[$source_lang] = $job->id(); // Add newly created job into jobs queue. @@ -341,7 +330,7 @@ class ConfigSourcePluginUi extends SourcePluginUiBase { // We have a job for given source lang, so just add new job item for the // existing job. else { - $jobs[$source_lang_registry[$source_lang]]->addItem('config', $extra['type'], $id); + $jobs[$source_lang_registry[$source_lang]]->addItem('config', $type, $id); } } catch (TMGMTException $e) { watchdog_exception('tmgmt', $e); only in patch2: unchanged: --- a/sources/tmgmt_config/src/Plugin/tmgmt/Source/ConfigSource.php +++ b/sources/tmgmt_config/src/Plugin/tmgmt/Source/ConfigSource.php @@ -126,7 +126,7 @@ class ConfigSource extends SourcePluginBase implements ContainerFactoryPluginInt $config_mapper = $this->configMapperManager->createInstance($job_item->getItemType()); /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type */ - $entity_type = $this->entityManager->getDefinition($config_mapper->getType()); + $entity_type = $this->entityManager->getDefinition($job_item->getItemType()); $pos = strpos($job_item->getItemId(), $entity_type->getConfigPrefix()); if (($pos !== FALSE)) { @@ -136,7 +136,7 @@ class ConfigSource extends SourcePluginBase implements ContainerFactoryPluginInt throw new TMGMTException(t('Item ID does not contain the full config object name.')); } - $entity = $this->entityManager->getStorage($config_mapper->getType())->load($entity_id); + $entity = $this->entityManager->getStorage($job_item->getItemType())->load($entity_id); if (!$entity) { throw new TMGMTException(t('Unable to load entity %type with id %id', array('%type' => $job_item->getItemType(), '%id' => $entity_id))); } @@ -298,9 +298,9 @@ class ConfigSource extends SourcePluginBase implements ContainerFactoryPluginInt $entity_types = $this->entityManager->getDefinitions(); $definitions = $this->configMapperManager->getDefinitions(); $types = array(); - foreach ($definitions as $definition_name => $definition) { - if (isset($definition['entity_type'])) { - $types[$definition['entity_type']] = (string) $entity_types[$definition['entity_type']]->getLabel(); + foreach ($entity_types as $entity_type_name => $entity_type) { + if (isset($definitions[$entity_type_name])) { + $types[$entity_type_name] = (string) $entity_type->getLabel(); } } $types[static::SIMPLE_CONFIG] = t('Simple configuration'); only in patch2: unchanged: --- a/sources/tmgmt_config/src/Tests/ConfigSourceListTest.php +++ b/sources/tmgmt_config/src/Tests/ConfigSourceListTest.php @@ -24,7 +24,7 @@ class ConfigSourceListTest extends EntityTestBase { * * @var array */ - public static $modules = array('tmgmt_config', 'tmgmt_content', 'config_translation', 'views', 'views_ui', 'field_ui'); + public static $modules = array('tmgmt_config', 'tmgmt_content', 'config_translation', 'views', 'views_ui'); protected $nodes = array(); @@ -330,21 +330,4 @@ class ConfigSourceListTest extends EntityTestBase { $this->assertEqual(count($this->xpath('//tbody/tr')), 1); } - /** - * Test for field configuration translation from source list. - */ - function testFieldConfigList() { - $this->drupalGet('admin/tmgmt/sources/config/field_config'); - - // Test submission. - $this->drupalPostForm(NULL, array('items[field.field.node.article.body]' => TRUE), t('Request translation')); - $this->assertText(t('One job needs to be checked out.')); - $this->drupalPostForm(NULL, array(), t('Submit to translator')); - - // Make sure that we're back on the originally defined destination URL. - $this->assertUrl('admin/tmgmt/sources/config/field_config'); - $this->assertText(t('Test translation created.')); - $this->assertText(t('The translation of Body to German is finished and can now be reviewed.')); - } - } only in patch2: unchanged: --- a/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php +++ b/sources/tmgmt_config/src/Tests/ConfigSourceUiTest.php @@ -24,7 +24,7 @@ class ConfigSourceUiTest extends EntityTestBase { * * @var array */ - public static $modules = array('tmgmt_config', 'views', 'views_ui', 'field_ui', 'config_translation'); + public static $modules = array('tmgmt_config', 'views', 'views_ui', 'config_translation'); /** * {@inheritdoc} @@ -252,28 +252,6 @@ class ConfigSourceUiTest extends EntityTestBase { } /** - * Test the field config entity type for a single checkout. - */ - function testFieldConfigTranslateTabSingleCheckout() { - $this->loginAsAdmin(array('translate configuration')); - - // Go to the translate tab. - $this->drupalGet('admin/structure/types/manage/article/fields/node.article.body/translate'); - - // Request a german translation. - $this->drupalPostForm(NULL, array('languages[de]' => TRUE), t('Request translation')); - - // Verify that we are on the checkout page. - $this->assertResponse(200); - $this->assertText(t('One job needs to be checked out.')); - $this->drupalPostForm(NULL, array(), t('Submit to translator')); - - // Verify that the pending translation is shown. - $this->clickLink(t('Needs review')); - $this->drupalPostForm(NULL, array(), t('Save as completed')); - - } - /** * Test the entity source specific cart functionality. */ function testCart() { only in patch2: unchanged: --- a/src/Form/TranslatorForm.php +++ b/src/Form/TranslatorForm.php @@ -143,7 +143,7 @@ class TranslatorForm extends EntityForm { '#required' => TRUE, '#disabled' => $busy, '#ajax' => array( - 'callback' => array($this, 'ajaxTranslatorPluginSelect'), + 'callback' => array($this, 'ajaxTranslaorPluginSelect'), 'wrapper' => 'tmgmt-plugin-wrapper', ), ); @@ -257,7 +257,7 @@ class TranslatorForm extends EntityForm { * Ajax callback for loading the translator plugin settings form for the * currently selected translator plugin. */ - function ajaxTranslatorPluginSelect(array $form, FormStateInterface $form_state) { + function ajaxTranslaorPluginSelect(array $form, FormStateInterface $form_state) { return $form['plugin_wrapper']; }