Comments

sidharthap’s picture

Status: Active » Needs review
StatusFileSize
new9.49 KB

Here is the first attempt to create the class.

tim.plunkett’s picture

  1. +++ b/core/modules/language/language.module
    @@ -180,103 +180,6 @@ function language_process_language_select($element) {
    - * Process handler for the language_configuration form element.
    
    +++ b/core/modules/language/src/Element/LanguageConfig.php
    @@ -0,0 +1,119 @@
    +  /**
    +   * @param array $element
    

    Copy this one liner here.

  2. +++ b/core/modules/language/language.module
    @@ -180,103 +180,6 @@ function language_process_language_select($element) {
    -      language_save_default_configuration($values['entity_type'], $values['bundle'],  $form_state->getValue($element_name));
    
    +++ b/core/modules/language/src/Element/LanguageConfig.php
    @@ -0,0 +1,119 @@
    +        \Drupal::config('language.settings')->set(language_get_default_configuration_settings_key($values['entity_type'], $values['bundle']), array('langcode' => $values['langcode'], 'language_show' => $values['language_show']))->save();
    

    I don't think changing this is in scope.

  3. +++ b/core/modules/language/src/Element/LanguageConfig.php
    @@ -0,0 +1,119 @@
    +* provides language element configuration.
    +*/
    

    This should be indented one space, and start with a capital P. Also, it needs an @FormElement("language_configuration") annotation

  4. +++ b/core/modules/language/src/Element/LanguageConfig.php
    @@ -0,0 +1,119 @@
    +class LanguageConfig extends FormElement {
    

    This class should be LanguageConfiguration

  5. +++ b/core/modules/language/src/Element/LanguageConfig.php
    @@ -0,0 +1,119 @@
    +    $types['language_configuration'] = array(
    ...
    +    return $types;
    

    You can just return array(, no need for a $types array

  6. +++ b/core/modules/language/src/Element/LanguageConfig.php
    @@ -0,0 +1,119 @@
    +      '#process' => array(array($class, 'LanguageConfigprocess')),
    ...
    +  public static function LanguageConfigprocess($element, FormStateInterface $form_state, &$form) {
    

    Please rename this 'processLanguageConfig'

  7. +++ b/core/modules/language/src/Element/LanguageConfig.php
    @@ -0,0 +1,119 @@
    +        $form['actions']['submit']['#submit'][] = 'LanguageConfigElementSubmit';
    ...
    +        $form['#submit'][] = 'LanguageConfigElementSubmit';
    ...
    +  protected static function LanguageConfigElementSubmit(&$form, FormStateInterface $form_state) {
    

    submitLanguageConfiguration

  8. +++ b/core/modules/language/src/Element/LanguageConfig.php
    @@ -0,0 +1,119 @@
    +   * @return array
    +   * Returns default language list.
    

    Switch this order.

  9. +++ b/core/modules/language/src/Element/LanguageConfig.php
    @@ -0,0 +1,119 @@
    +  protected static function LanguageConfigDefaultOptions() {
    

    getDefaultOptions

Status: Needs review » Needs work

The last submitted patch, 1: language-element-info-2326885-1.patch, failed testing.

sidharthap’s picture

Status: Needs work » Needs review
StatusFileSize
new9.38 KB

Thank You @tim.plunkett.
Corrected #2 and here is the patch.

Status: Needs review » Needs work

The last submitted patch, 4: language-element-info-2326885-4.patch, failed testing.

almaudoh’s picture

+++ b/core/modules/language/src/Element/LanguageConfig.php
@@ -0,0 +1,121 @@
+  public static function processLanguageConfig($element, FormStateInterface $form_state, &$form) {

For consistency with #2.7, processLanguageConfig() should be processLanguageConfiguration()

sidharthap’s picture

Status: Needs work » Needs review
StatusFileSize
new9.4 KB

Thank you @almaudoh.
Updated comment #6.

Status: Needs review » Needs work

The last submitted patch, 7: language-element-info-2326885-7.patch, failed testing.

tim.plunkett’s picture

+++ b/core/modules/language/src/Element/LanguageConfig.php
@@ -0,0 +1,121 @@
+        $form['actions']['submit']['#submit'][] = 'submitLanguageConfiguration';
...
+        $form['#submit'][] = 'submitLanguageConfiguration';
...
+  protected static function submitLanguageConfiguration(&$form, FormStateInterface $form_state) {

This is not valid PHP. It should be array(get_called_class(), 'submitLanguageConfiguration')

And the method must be public.

sidharthap’s picture

Status: Needs work » Needs review
StatusFileSize
new9.44 KB

Corrected #9. Thank you @tim.plunkett.

Status: Needs review » Needs work

The last submitted patch, 10: language-element-info-2326885-10.patch, failed testing.

vijaycs85’s picture

Issue tags: +D8MI
tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new5.32 KB
new8.83 KB

So it turns out that language_configuration_element_submit() is still used in several places in core, so we should not move it into this element yet.

Also, the file was named incorrectly.

This will still fail the CMI tests.

Status: Needs review » Needs work

The last submitted patch, 13: language-2326885-13.patch, failed testing.

vijaycs85’s picture

Issue tags: +sprint

Let's add to D8MI sprint.

tim.plunkett’s picture

Reminder that there is nothing to do here until #2326409: Annotate render element plugins is done.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new8.99 KB

Rerolled for now without the hook_element_info() removal in light of #2326409: Annotate render element plugins

Status: Needs review » Needs work

The last submitted patch, 17: 2326885-language-17.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new9.05 KB
new581 bytes

Status: Needs review » Needs work

The last submitted patch, 19: 2326885-language-19.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new9.42 KB

Shouldn't have removed language_configuration_element_submit().

jibran’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/language/src/Element/LanguageConfiguration.php
    @@ -0,0 +1,107 @@
    +      // Determine where to attach the language_configuration element submit handler.
    +      // @todo Form API: Allow form widgets/sections to declare #submit handlers.
    

    more then 80 chars.

  2. +++ b/core/modules/language/src/Element/LanguageConfiguration.php
    @@ -0,0 +1,107 @@
    +      'site_default' => t("Site's default language (!language)", array('!language' => \Drupal::languageManager()->getDefaultLanguage()->name)),
    ...
    +    $languages = \Drupal::languageManager()->getLanguages(LanguageInterface::STATE_ALL);
    

    We can inject these.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new9.64 KB

Messed up the interdiff, sorry.

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the fixes.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

  • webchick committed f57fa98 on 8.0.x
    Issue #2326885 by tim.plunkett, sidharthap: Convert...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

gábor hojtsy’s picture

Issue tags: -sprint +language-base

Thanks all!