public static function Utility::render in Basic cart 8.4
Same name and namespace in other branches
- 8.6 src/Utility.php \Drupal\basic_cart\Utility::render()
- 8 src/Utility.php \Drupal\basic_cart\Utility::render()
- 8.0 src/Utility.php \Drupal\basic_cart\Utility::render()
- 8.2 src/Utility.php \Drupal\basic_cart\Utility::render()
- 8.3 src/Utility.php \Drupal\basic_cart\Utility::render()
- 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_cartCode
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(),
]);
}