From 67d7db4262d271857f6de6f4794c08e1a696a70e Mon Sep 17 00:00:00 2001 From: babruix Date: Sat, 9 Mar 2013 12:56:47 +0100 Subject: [PATCH] Issue #1879396 by xjm: Added inline documentation to BlockBase::validate() and BlockBase::submit(). --- core/modules/block/lib/Drupal/block/BlockBase.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index 9c90a5a..87f6c3a 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -417,17 +417,20 @@ public function blockForm($form, &$form_state) { * Most block plugins should not override this method. To add validation * for a specific block type, override BlockBase::blockValdiate(). * - * @todo Add inline documentation to this method. - * * @see \Drupal\block\BlockBase::blockValidate() */ public function validate($form, &$form_state) { + // If machine_name was disabled. if (!empty($form['machine_name']['#disabled'])) { + // Explode machine_name using . separator. $config_id = explode('.', $form_state['values']['machine_name']); + // Set value of machine_name to the last value of exploded array. $form_state['values']['machine_name'] = array_pop($config_id); } + // All roles equal to false will be removed. $form_state['values']['visibility']['role']['roles'] = array_filter($form_state['values']['visibility']['role']['roles']); if ($form_state['entity']->isNew()) { + // If entity is new, change form id to entity_theme.machine_name. form_set_value($form['id'], $form_state['entity']->get('theme') . '.' . $form_state['values']['machine_name'], $form_state); } $this->blockValidate($form, $form_state); @@ -457,16 +460,18 @@ public function blockValidate($form, &$form_state) {} * Most block plugins should not override this method. To add submission * handling for a specific block type, override BlockBase::blockSubmit(). * - * @todo Add inline documentation to this method. - * * @see \Drupal\block\BlockBase::blockSubmit() */ public function submit($form, &$form_state) { + // Only process if no errors found. if (!form_get_errors()) { + // Add block type-specific submission handling for the block form. $this->blockSubmit($form, $form_state); drupal_set_message(t('The block configuration has been saved.')); + // Mark cache items from all bins with content tag as invalid cache_invalidate_tags(array('content' => TRUE)); + // Set redirect back $form_state['redirect'] = 'admin/structure/block/list/block_plugin_ui:' . $form_state['entity']->get('theme'); } } -- 1.7.12.1