commit b16f9307cb8e5806a7ecb60662552efddc518664 Author: Lee Rowlands Date: Mon Jan 21 08:26:50 2013 +1000 Patch 57 diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php index 7a079a5..4f588a6 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php @@ -77,12 +77,13 @@ public function form(array $form, array &$form_state, EntityInterface $block) { ); $language_configuration = module_invoke('language', 'get_default_configuration', 'custom_block', $block->type->value); + $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', '#default_value' => $block->langcode->value, '#languages' => LANGUAGE_ALL, - '#access' => isset($language_configuration['language_hidden']) && !$language_configuration['language_hidden'], + '#access' => isset($language_configuration['language_show']) && !$language_configuration['language_show'], ); $form['additional_settings'] = array( diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php index 75484f9..0ef4a76 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php @@ -45,11 +45,26 @@ public function form(array $form, array &$form_state, EntityInterface $block_typ '#description' => t('Create a new revision by default for this block type.') ); - // @todo Remove this check once language settings are generalized. if (module_exists('translation_entity')) { - $translation_form = $form; - $translation_form_state['translation_entity']['key'] = 'language_configuration'; - $form += translation_entity_enable_widget('custom_block', $block_type->id(), $translation_form, $translation_form_state); + $form['language'] = array( + '#type' => 'details', + '#title' => t('Language settings'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#group' => 'additional_settings', + ); + + $language_configuration = language_get_default_configuration('custom_block', $block_type->id()); + $form['language']['language_configuration'] = array( + '#type' => 'language_configuration', + '#entity_information' => array( + 'entity_type' => 'custom_block', + 'bundle' => $block_type->id(), + ), + '#default_value' => $language_configuration, + ); + + $form['#submit'][] = 'language_configuration_element_submit'; } $form['actions'] = array('#type' => 'actions'); @@ -78,15 +93,6 @@ public function save(array $form, array &$form_state) { watchdog('custom_block', 'Custom block type %label has been added.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, l(t('Edit'), $uri['path'] . '/edit')); } - if (module_exists('translation_entity')) { - $key = 'language_configuration'; - $translation_form_state = array( - 'translation_entity' => array('key' => $key), - 'language' => array($key => array('entity_type' => 'custom_block', 'bundle' => $block_type->id())), - 'values' => array($key => array('translation_entity' => $form_state['values']['translation_entity'])), - ); - translation_entity_language_configuration_element_submit($form, $translation_form_state); - } $form_state['redirect'] = 'admin/structure/custom-blocks'; } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php index ad7a772..610c3dd 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php @@ -197,17 +197,6 @@ public function getTheme() { } /** - * The plain data values of the contained properties. - * - * Define default values. - * - * @var array - */ - protected $values = array( - 'langcode' => array(LANGUAGE_DEFAULT => array(0 => array('value' => LANGUAGE_NOT_SPECIFIED))), - ); - - /** * Initialize the object. Invoked upon construction and wake up. */ protected function init() { @@ -219,7 +208,6 @@ protected function init() { unset($this->log); unset($this->machine_name); unset($this->uuid); - unset($this->langcode); unset($this->type); unset($this->new); }