RenderInterface.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @package Grav\Framework\Interfaces
  5. *
  6. * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
  7. * @license MIT License; see LICENSE file for details.
  8. */
  9. namespace Grav\Framework\Interfaces;
  10. use Grav\Framework\ContentBlock\ContentBlockInterface;
  11. use Grav\Framework\ContentBlock\HtmlBlock;
  12. /**
  13. * Defines common interface to render any object.
  14. *
  15. * @used-by \Grav\Framework\Flex\FlexObject
  16. * @since 1.6
  17. */
  18. interface RenderInterface
  19. {
  20. /**
  21. * Renders the object.
  22. *
  23. * @example $block = $object->render('custom', ['variable' => 'value']);
  24. * @example {% render object layout 'custom' with { variable: 'value' } %}
  25. *
  26. * @param string|null $layout Layout to be used.
  27. * @param array $context Extra context given to the renderer.
  28. *
  29. * @return ContentBlockInterface|HtmlBlock Returns `HtmlBlock` containing the rendered output.
  30. * @api
  31. */
  32. public function render(string $layout = null, array $context = []);
  33. }