TestRenderer.php 872 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace lithium\tests\mocks\template\view\adapters;
  3. use lithium\util\String;
  4. class TestRenderer extends \lithium\template\view\adapter\File implements \ArrayAccess {
  5. public static $templateData = array();
  6. public static $renderData = array();
  7. public function template($type, array $params) {
  8. foreach ((array) $this->_paths[$type] as $path) {
  9. if (!file_exists($path = String::insert($path, $params))) {
  10. continue;
  11. }
  12. self::$templateData[] = compact('type', 'params') + array(
  13. 'return' => $path
  14. );
  15. return $path;
  16. }
  17. self::$templateData[] = compact('type', 'params') + array(
  18. 'return' => false
  19. );
  20. return false;
  21. }
  22. public function render($template, $data = array(), array $options = array()) {
  23. self::$renderData[] = compact('template', 'data', 'options');
  24. ob_start();
  25. include $template;
  26. return ob_get_clean();
  27. }
  28. }
  29. ?>