diff -r 000000000000 -r 4eba9c11703f web/Zend/Tool/Project/Context/Content/Engine/CodeGenerator.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/Zend/Tool/Project/Context/Content/Engine/CodeGenerator.php Mon Dec 13 18:29:26 2010 +0100 @@ -0,0 +1,98 @@ +_storage = $storage; + $this->_contentPrefix = $contentPrefix; + } + + /** + * hasContent() + * + * @param Zend_Tool_Project_Context_Interface $context + * @param string $method + * @return string + */ + public function hasContent(Zend_Tool_Project_Context_Interface $context, $method) + { + return $this->_storage->has($this->_contentPrefix . '/' . $context->getName() . '/' . $method . '.php'); + } + + /** + * getContent() + * + * @param Zend_Tool_Project_Context_Interface $context + * @param string $method + * @param mixed $parameters + * @return string + */ + public function getContent(Zend_Tool_Project_Context_Interface $context, $method, $parameters) + { + $streamUri = $this->_storage->getStreamUri($this->_contentPrefix . '/' . $context->getName() . '/' . $method . '.php'); + + if (method_exists($context, 'getCodeGenerator')) { + $codeGenerator = $context->getCodeGenerator(); + } else { + $codeGenerator = new Zend_CodeGenerator_Php_File(); + } + + $codeGenerator = include $streamUri; + + if (!$codeGenerator instanceof Zend_CodeGenerator_Abstract) { + throw new Zend_Tool_Project_Exception('Custom file at ' . $streamUri . ' did not return the $codeGenerator object.'); + } + + return $codeGenerator->generate(); + } + + +} \ No newline at end of file