Engine.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Tool
  17. * @subpackage Framework
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Tool_Project_Context_Content_Engine_CodeGenerator
  24. */
  25. require_once 'Zend/Tool/Project/Context/Content/Engine/CodeGenerator.php';
  26. /**
  27. * @see Zend_Tool_Project_Context_Content_Engine_Phtml
  28. */
  29. require_once 'Zend/Tool/Project/Context/Content/Engine/Phtml.php';
  30. /**
  31. * This class is the front most class for utilizing Zend_Tool_Project
  32. *
  33. * A profile is a hierarchical set of resources that keep track of
  34. * items within a specific project.
  35. *
  36. * @category Zend
  37. * @package Zend_Tool
  38. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  39. * @license http://framework.zend.com/license/new-bsd New BSD License
  40. */
  41. class Zend_Tool_Project_Context_Content_Engine
  42. {
  43. /**
  44. * @var Zend_Tool_Framework_Client_Storage
  45. */
  46. protected $_storage = null;
  47. /**
  48. * @var string
  49. */
  50. protected $_keyInStorage = 'project/content';
  51. /**
  52. * @var array
  53. */
  54. protected $_engines = array();
  55. /**
  56. * __construct()
  57. *
  58. * @param Zend_Tool_Framework_Client_Storage $storage
  59. */
  60. public function __construct(Zend_Tool_Framework_Client_Storage $storage)
  61. {
  62. $this->_storage = $storage;
  63. $this->_engines = array(
  64. new Zend_Tool_Project_Context_Content_Engine_CodeGenerator($storage, $this->_keyInStorage),
  65. new Zend_Tool_Project_Context_Content_Engine_Phtml($storage, $this->_keyInStorage),
  66. );
  67. }
  68. /**
  69. * getContent()
  70. *
  71. * @param Zend_Tool_Project_Context_Interface $context
  72. * @param string $methodName
  73. * @param mixed $parameters
  74. * @return string
  75. */
  76. public function getContent(Zend_Tool_Project_Context_Interface $context, $methodName, $parameters)
  77. {
  78. $content = null;
  79. foreach ($this->_engines as $engine) {
  80. if ($engine->hasContent($context, $methodName, $parameters)) {
  81. $content = $engine->getContent($context, $methodName, $parameters);
  82. if ($content != null) {
  83. break;
  84. }
  85. }
  86. }
  87. if ($content == null) {
  88. return false;
  89. }
  90. return $content;
  91. }
  92. }