PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/mocks/template/view/adapters/TestRenderer.php

http://github.com/UnionOfRAD/lithium
PHP | 42 lines | 29 code | 6 blank | 7 comment | 1 complexity | d9f2122256fa67d35117b8556e4a9cb0 MD5 | raw file
  1. <?php
  2. /**
  3. * li₃: the most RAD framework for PHP (http://li3.me)
  4. *
  5. * Copyright 2011, Union of RAD. All rights reserved. This source
  6. * code is distributed under the terms of the BSD 3-Clause License.
  7. * The full license text can be found in the LICENSE.txt file.
  8. */
  9. namespace lithium\tests\mocks\template\view\adapters;
  10. use lithium\util\Text;
  11. class TestRenderer extends \lithium\template\view\adapter\File implements \ArrayAccess {
  12. public static $templateData = [];
  13. public static $renderData = [];
  14. public function template($type, array $params) {
  15. foreach ((array) $this->_paths[$type] as $path) {
  16. if (!file_exists($path = Text::insert($path, $params))) {
  17. continue;
  18. }
  19. static::$templateData[] = compact('type', 'params') + [
  20. 'return' => $path
  21. ];
  22. return $path;
  23. }
  24. static::$templateData[] = compact('type', 'params') + [
  25. 'return' => false
  26. ];
  27. return false;
  28. }
  29. public function render($template, $data = [], array $options = []) {
  30. static::$renderData[] = compact('template', 'data', 'options');
  31. ob_start();
  32. include $template;
  33. return ob_get_clean();
  34. }
  35. }
  36. ?>