title: Drupal 8: Custom Module Block default configuration not working
body: <p>I am learning how to create a custom module in <code>Drupal 8</code>. I am stuck in creating the default configuration for a block of the module.</p>
  
  <p>The name of my module is <code>hello</code>. As required, I have created a file <code>hello/config/install/hello.settings.yml</code>. Then as required I also created the <code>defaultConfiguration()</code> method in my <code>HelloBlock</code> class.</p>
  
  <p>I tried deleting the module, reinstalling it and also tried clearing the cache. But still, after I install the module and place the block, it just says <code>Hello !</code> instead of <code>Hello, Batman!</code></p>
  
  <p>Here is the required code -</p>
  
  <p><strong>hello/config/install/hello.settings.yml</strong></p>
  
  <pre><code>hello:
    name: 'Batman'
  </code></pre>
  
  <p><strong>hello\src\Plugin\Block\HelloBlock.php</strong></p>
  
  <p>Here is the defaultConfigurtion() function -</p>
  
  <pre><code>public function defaultConfiguration() {
     $default_config=\Drupal::config('hello.settings');
     return array(
     'name'=&gt;$default_config-&gt;get('hello.name'),
    );
   }
  </code></pre>
  
  <p>Here is the entire HelloBlock class -</p>
  
  <pre><code>class HelloBlock extends BlockBase implements BlockPluginInterface {
  /**
  * {@inheritdoc}
  */
  public function defaultConfiguration() {
    $default_config=\Drupal::config('hello.settings');
    return array(
      'name'=&gt;$default_config-&gt;get('hello.name'),
    );
  }
  
  
  //Submit the form and save the form value into block configuration
  public function blockSubmit($form, FormStateInterface $form_state) {
    parent::blockSubmit($form,$form_state);
    $values=$form_state-&gt;getValues();
    $this-&gt;configuration['hello_block_name'] = 
    $values['hello_block_name'];
  }
  
  //Add the form
  public function blockForm($form, FormStateInterface $form_state) {
    $form = parent::blockForm($form,$form_state);
    $config = $this-&gt;getConfiguration();
    $form['hello_block_name'] = array(
      '#type'=&gt; 'textfield',
      '#title'=&gt; 'Who',
      '#description'=&gt;$this-&gt;t('Who do you want to say hello to?'),
      '#default_value'=&gt;isset($config['hello_block_name'])?
      $config['hello_block_name'] : ' ',
    );
    return $form;
  }
  
  //Build the module i.e. Control the view of block
  public function build() {
    $config = $this-&gt;getConfiguration();
  
   if (!empty($config['hello_block_name'])) {
     $name = $config['hello_block_name'];
   }
   else {
     $name = $this-&gt;t('to no one');
   }
   return array(
     '#markup' =&gt; $this-&gt;t('Hello @name!', array (
         '@name' =&gt; $name,
       )),
   );
  }
  }
  </code></pre>