You are here

public static function Utility::render in Basic cart 8.3

Same name and namespace in other branches
  1. 8.6 src/Utility.php \Drupal\basic_cart\Utility::render()
  2. 8 src/Utility.php \Drupal\basic_cart\Utility::render()
  3. 8.0 src/Utility.php \Drupal\basic_cart\Utility::render()
  4. 8.2 src/Utility.php \Drupal\basic_cart\Utility::render()
  5. 8.4 src/Utility.php \Drupal\basic_cart\Utility::render()
  6. 8.5 src/Utility.php \Drupal\basic_cart\Utility::render()

Render function.

Parameters

string $template_name: Name of the template.

3 calls to Utility::render()
CartBlock::build in src/Plugin/Block/CartBlock.php
Builds and returns the renderable array for this block plugin.
CartController::addToCart in src/Controller/CartController.php
Add node to cart.
CartForm::buildForm in src/Form/CartForm.php
Form constructor.

File

src/Utility.php, line 336

Class

Utility
Utilty functions for basic cart.

Namespace

Drupal\basic_cart

Code

public static function render($template_name = 'basic-cart-cart-template.html.twig', $variable = NULL) {
  $twig = \Drupal::service('twig');
  $template = $twig
    ->loadTemplate(drupal_get_path('module', 'basic_cart') . '/templates/' . $template_name);
  return $template
    ->render([
    'basic_cart' => $variable ? $variable : self::getCartData(),
  ]);
}