[Sungrazr-svn] [91] Sungrazr_Server_Handler: [NEW] Abstract class for externally-facing API classes to extend.

0 views
Skip to first unread message

cl...@killersoft.com

unread,
Dec 17, 2007, 2:50:02 PM12/17/07
to Sungra...@googlegroups.com
Revision
91
Author
clay
Date
2007-12-17 11:50:01 -0800 (Mon, 17 Dec 2007)

Log Message

Sungrazr_Server_Handler: [NEW] Abstract class for externally-facing API classes to extend.

Added Paths

Diff

Added: trunk/Sungrazr/Server/Handler.php (0 => 91)


--- trunk/Sungrazr/Server/Handler.php	                        (rev 0)
+++ trunk/Sungrazr/Server/Handler.php	2007-12-17 19:50:01 UTC (rev 91)
@@ -0,0 +1,106 @@
+<?php
+/**
+ * 
+ * Abstract class for Server handlers.
+ * 
+ * Provides a base for building external API wrapper classes.
+ * 
+ * Developed for, and then donated by, Mashery.com <http://mashery.com>.
+ * 
+ * @category Sungrazr
+ * 
+ * @package Sungrazr_Server
+ * 
+ * @author Clay Loveless <cl...@killersoft.com>
+ * 
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * 
+ * @version SVN: $Id$
+ * 
+ */
+
+abstract class Sungrazr_Server_Handler extends Solar_Base {
+    
+    /**
+     * 
+     * User-provided configuration.
+     * 
+     * Config keys are ...
+     * 
+     * `caller`
+     * : (Sungrazr_Server_Adapter) The server adapter that loaded this class.
+     * 
+     * @var array
+     * 
+     */
+    protected $_Sungrazr_Server_Handler = array(
+        'caller'    => null,
+    );
+    
+    /**
+     * 
+     * Flag to enable checking for fault responses.
+     * 
+     * @var bool
+     * 
+     */
+    public $isFault;
+    
+    /**
+     * 
+     * Fault details.
+     * 
+     * @var array
+     * 
+     */
+    protected $_fault = array(
+        'message' => null,
+        'code' => 0
+    );
+    
+    /**
+     * 
+     * Return the fault
+     * 
+     * @return array
+     * 
+     */
+    public function getFault()
+    {
+        return $this->_fault;
+    }
+    
+    /**
+     * 
+     * Raise the fault flag.
+     * 
+     * @param mixed $fault A description of the fault. Will be serialized by
+     * the server adapter before it is returned.
+     * 
+     * @param int $code Fault code
+     * 
+     * @return void
+     * 
+     */
+    protected function _raiseFault($fault = null, $code = 404)
+    {
+        $this->isFault = true;
+        $this->_fault['message'] = $fault;
+        $this->_fault['code'] = (int) $code;
+    }
+
+    /**
+     * 
+     * Clear the fault.
+     * 
+     * @return void
+     * 
+     */
+    protected function _clearFault()
+    {
+        $this->isFault = false;
+        $this->_fault['message'] = null;
+        $this->_fault['code'] = 0;
+    }
+    
+}
\ No newline at end of file
Property changes on: trunk/Sungrazr/Server/Handler.php
___________________________________________________________________
Name: svn:keywords
   + Id
Reply all
Reply to author
Forward
0 new messages