You are here

public function BlockUploadBlock::getDerivativeDefinitions in Block Upload 8

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/Derivative/BlockUploadBlock.php, line 18

Class

BlockUploadBlock
Provides block plugin definitions for mymodule blocks.

Namespace

Drupal\block_upload\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $blocks_count = \Drupal::state()
    ->get('block_upload_count');
  for ($i = 1; $i <= $blocks_count; $i++) {
    $this->derivatives['block_upload' . $i] = $base_plugin_definition;
    $this->derivatives['block_upload' . $i]['admin_label'] = 'Block upload ' . $i;
    $this->derivatives['block_upload' . $i]['cache'] = [
      'max_age' => 0,
    ];
  }
  return $this->derivatives;
}