xfRetortDirectRoute.class.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * This file is part of the sfSearch package.
  4. * (c) Carl Vondrick <carl.vondrick@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * A retort to generate a route.
  11. *
  12. * @package sfSearch
  13. * @subpackage Result
  14. * @author Carl Vondrick
  15. */
  16. final class xfRetortDirectRoute implements xfRetort {
  17. /**
  18. * The method bound to
  19. *
  20. * @var string
  21. */
  22. private $method = 'getRoute';
  23. /**
  24. * Constructor
  25. *
  26. * @param string $template The route template
  27. */
  28. public function __construct()
  29. {
  30. }
  31. /**
  32. * The method to accept
  33. *
  34. * @param string $method
  35. */
  36. public function setMethod($method)
  37. {
  38. $this->method = $method;
  39. }
  40. /**
  41. *
  42. * @see xfRetort
  43. */
  44. public function can(xfDocumentHit $hit, $method, array $args = array())
  45. {
  46. return $this->method == $method;
  47. }
  48. /**
  49. *
  50. * @see xfRetort
  51. */
  52. public function respond(xfDocumentHit $hit, $method, array $args = array())
  53. {
  54. $ContentTree = ContentTree::instance();
  55. $ContentTree->build();
  56. // $ContentTreeNode = $ContentTree->getContentTreeNodeById($hit->getDocument()->getField('id')->getValue());
  57. $ContentTreeNode = $ContentTree->getContentTreeNodeById($hit->getDocument()->getField('node_id')->getValue());
  58. return $ContentTreeNode->getUrl();
  59. }
  60. }