You are here

public function CartBlock::build in Basic cart 8.2

Same name and namespace in other branches
  1. 8.6 src/Plugin/Block/CartBlock.php \Drupal\basic_cart\Plugin\Block\CartBlock::build()
  2. 8 src/Plugin/Block/CartBlock.php \Drupal\basic_cart\Plugin\Block\CartBlock::build()
  3. 8.0 src/Plugin/Block/CartBlock.php \Drupal\basic_cart\Plugin\Block\CartBlock::build()
  4. 8.3 src/Plugin/Block/CartBlock.php \Drupal\basic_cart\Plugin\Block\CartBlock::build()
  5. 8.4 src/Plugin/Block/CartBlock.php \Drupal\basic_cart\Plugin\Block\CartBlock::build()
  6. 8.5 src/Plugin/Block/CartBlock.php \Drupal\basic_cart\Plugin\Block\CartBlock::build()

Builds and returns the renderable array for this block plugin.

If a block should not be rendered because it has no content, then this method must also ensure to return no content: it must then only return an empty array, or an empty array with #cache set (with cacheability metadata indicating the circumstances for it being empty).

Return value

array A renderable array representing the content of the block.

Overrides BlockPluginInterface::build

See also

\Drupal\block\BlockViewBuilder

File

src/Plugin/Block/CartBlock.php, line 21

Class

CartBlock
Provides a 'Basic Cart' block.

Namespace

Drupal\basic_cart\Plugin\Block

Code

public function build() {
  $config = Utility::cartSettings();
  return array(
    // '#theme' => 'basic_cart_cart_template',
    // '#basic_cart' => array(),
    '#type' => 'markup',
    '#title' => $config
      ->get('cart_block_title'),
    '#markup' => Utility::render(),
    '#cache' => array(
      'max-age' => 0,
    ),
  );
}