[puntoengine] r106 committed - Service index for default actions in ServiceControllers

0 views
Skip to first unread message

punto...@googlecode.com

unread,
Nov 5, 2011, 11:21:21 PM11/5/11
to punto...@googlegroups.com
Revision: 106
Author: jba...@gmail.com
Date: Sat Nov 5 20:20:14 2011
Log: Service index for default actions in ServiceControllers
http://code.google.com/p/puntoengine/source/detail?r=106

Modified:
/trunk/puntoengine/core/Kernel.php
/trunk/puntoengine/core/http/HttpController.php
/trunk/puntoengine/core/http/ServiceController.php
/trunk/puntoengine/core/http/ServiceResponse.php
/trunk/puntoengine/core/http/WebResponse.php

=======================================
--- /trunk/puntoengine/core/Kernel.php Fri Nov 4 20:50:00 2011
+++ /trunk/puntoengine/core/Kernel.php Sat Nov 5 20:20:14 2011
@@ -171,7 +171,7 @@
ob_clean();

$response->process($request);
-
+
if(ob_get_length() != 0) {
ob_end_flush();
}
=======================================
--- /trunk/puntoengine/core/http/HttpController.php Fri Nov 4 20:50:00 2011
+++ /trunk/puntoengine/core/http/HttpController.php Sat Nov 5 20:20:14 2011
@@ -83,4 +83,29 @@
public function setMasterPage($masterpage) {
$this->master = $masterpage;
}//setMasterPage
+
+
+
+ /**
+ * Get the action in the controller
+ * @return array
+ * @since 0.5.0
+ */
+ public function getActions() {
+ $reflex = new ReflectionObject($this);
+
+ $methods = $reflex->getMethods();
+ $methodsCount = count($methods);
+ $services = array();
+
+ for($i = 0; $i < $methodsCount; $i++) {
+ $method = $methods[$i];
+ $name = $method->getName();
+ if(substr($name, -6, 6) == 'Action') {
+ $services[] = $name;
+ }
+ }
+
+ return $services;
+ }//getActions
}//HttpController
=======================================
--- /trunk/puntoengine/core/http/ServiceController.php Fri Nov 4 20:50:00
2011
+++ /trunk/puntoengine/core/http/ServiceController.php Sat Nov 5 20:20:14
2011
@@ -31,4 +31,25 @@
}
return $this->response;
}//getResponse
+
+
+
+ /**
+ * Default action in service is a index of service methods for user view
+ * @since 0.5.0
+ */
+ public function defaultAction() {
+ $services = $this->getActions();
+
+ echo '<h1>Services</h1>';
+
+ echo '<ul>';
+ for($i = 0; $i < count($services); $i++) {
+ echo '<li>'.$services[$i].'</li>';
+ }
+ echo '</ul>';
+
+ $this->response = new WebResponse();
+ $this->response->setProcessView(false);
+ }//defaultAction
}//ServiceController
=======================================
--- /trunk/puntoengine/core/http/ServiceResponse.php Fri Nov 4 20:50:00
2011
+++ /trunk/puntoengine/core/http/ServiceResponse.php Sat Nov 5 20:20:14
2011
@@ -36,6 +36,7 @@
*/
public function process(HttpRequest $request) {
header('content-type: text/xml');
+
$tag = ucfirst($this->action);

$xml = '<' . $tag . '>';
=======================================
--- /trunk/puntoengine/core/http/WebResponse.php Fri Nov 4 20:50:00 2011
+++ /trunk/puntoengine/core/http/WebResponse.php Sat Nov 5 20:20:14 2011
@@ -27,6 +27,45 @@
protected $master;


+ /**
+ * Get if the response has a view o has a controller or render engine
content
+ * @var bool
+ * @since 0.5.0
+ */
+ protected $processView = true;
+
+
+
+ /**
+ * Content of the response
+ * @var string
+ * @since 0.5.0
+ */
+ protected $content;
+
+
+
+ /**
+ * Return if response need process view or uses a renderer engine
+ * @return bool Process view or not
+ * @since 0.5.0
+ */
+ public function getProcessView() {
+ return $this->processView;
+ }//getProcessView
+
+
+
+ /**
+ * Set if response need process view or uses a renderer engine
+ * @param bool $processView Process view or not
+ * @since 0.5.0
+ */
+ public function setProcessView($processView) {
+ $this->processView = $processView;
+ }//setProcessView
+
+

/**
* Return the master page
@@ -41,7 +80,7 @@

/**
* Set the master page
- * @param string Master page
+ * @param string $master Master page
* @since 0.5.0
*/
public function setMasterPage($masterpage) {
@@ -56,7 +95,11 @@
* @since 0.5.0
*/
public function process(HttpRequest $request) {
- $content = $this->processView($request);
+ $content = '';
+
+ if($this->processView === true) {
+ $content = $this->processView($request);
+ }

if($this->master != null) {
$master = $this->processMasterPage($request, $content);

Reply all
Reply to author
Forward
0 new messages