Server.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  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_Amf
  17. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. */
  20. /** Zend_Server_Interface */
  21. require_once 'Zend/Server/Interface.php';
  22. /** Zend_Server_Reflection */
  23. require_once 'Zend/Server/Reflection.php';
  24. /** Zend_Amf_Constants */
  25. require_once 'Zend/Amf/Constants.php';
  26. /** Zend_Amf_Value_MessageBody */
  27. require_once 'Zend/Amf/Value/MessageBody.php';
  28. /** Zend_Amf_Value_MessageHeader */
  29. require_once 'Zend/Amf/Value/MessageHeader.php';
  30. /** Zend_Amf_Value_Messaging_CommandMessage */
  31. require_once 'Zend/Amf/Value/Messaging/CommandMessage.php';
  32. /** Zend_Amf_Parse_TypeLoader */
  33. require_once 'Zend/Amf/Parse/TypeLoader.php';
  34. /**
  35. * An AMF gateway server implementation to allow the connection of the Adobe Flash Player to
  36. * Zend Framework
  37. *
  38. * @todo Make the relection methods cache and autoload.
  39. * @package Zend_Amf
  40. * @subpackage Server
  41. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  42. * @license http://framework.zend.com/license/new-bsd New BSD License
  43. */
  44. class Zend_Amf_Server implements Zend_Server_Interface
  45. {
  46. /**
  47. * Array of dispatchables
  48. * @var array
  49. */
  50. protected $_methods = array();
  51. /**
  52. * Array of directories to search for loading classes dynamically
  53. * @var array
  54. */
  55. protected $_directories = array();
  56. /**
  57. * @var bool Production flag; whether or not to return exception messages
  58. */
  59. protected $_production = true;
  60. /**
  61. * Request processed
  62. * @var null|Zend_Amf_Request
  63. */
  64. protected $_request = null;
  65. /**
  66. * Class to use for responses
  67. * @var null|Zend_Amf_Response
  68. */
  69. protected $_response;
  70. /**
  71. * Dispatch table of name => method pairs
  72. * @var array
  73. */
  74. protected $_table = array();
  75. /**
  76. *
  77. * @var bool session flag; whether or not to add a session to each response.
  78. */
  79. protected $_session = false;
  80. /**
  81. * Namespace allows all AMF calls to not clobber other php session variables
  82. * @var Zend_Session_NameSpace default session namespace zend_amf
  83. */
  84. protected $_sesionNamespace = 'zend_amf';
  85. /**
  86. * Set the default session.name if php_
  87. * @var unknown_type
  88. */
  89. protected $_sessionName = 'PHPSESSID';
  90. /**
  91. * Set production flag
  92. *
  93. * @param bool $flag
  94. * @return Zend_Amf_Server
  95. */
  96. public function setProduction($flag)
  97. {
  98. $this->_production = (bool) $flag;
  99. return $this;
  100. }
  101. /**
  102. * Whether or not the server is in production
  103. *
  104. * @return bool
  105. */
  106. public function isProduction()
  107. {
  108. return $this->_production;
  109. }
  110. /**
  111. * @param namespace of all incoming sessions defaults to Zend_Amf
  112. * @return Zend_Amf_Server
  113. */
  114. public function setSession($namespace = 'Zend_Amf')
  115. {
  116. require_once 'Zend/Session.php';
  117. $this->_session = true;
  118. $this->_sesionNamespace = new Zend_Session_Namespace($namespace);
  119. return $this;
  120. }
  121. /**
  122. * Whether of not the server is using sessions
  123. * @return bool
  124. */
  125. public function isSession()
  126. {
  127. return $this->_session;
  128. }
  129. /**
  130. * Loads a remote class or method and executes the function and returns
  131. * the result
  132. *
  133. * @param string $method Is the method to execute
  134. * @param mixed $param values for the method
  135. * @return mixed $response the result of executing the method
  136. * @throws Zend_Amf_Server_Exception
  137. */
  138. protected function _dispatch($method, $params = null, $source = null)
  139. {
  140. if($source) {
  141. if(($mapped = Zend_Amf_Parse_TypeLoader::getMappedClassName($source)) !== false) {
  142. $source = $mapped;
  143. }
  144. }
  145. $qualifiedName = empty($source) ? $method : $source.".".$method;
  146. if (!isset($this->_table[$qualifiedName])) {
  147. // if source is null a method that was not defined was called.
  148. if ($source) {
  149. $classPath = array();
  150. $path = explode('.', $source);
  151. $className = array_pop($path);
  152. $uriclasspath = implode('/', $path);
  153. // Take the user supplied directories and add the unique service path to the end.
  154. foreach ($this->_directories as $dir) {
  155. $classPath[] = $dir . $uriclasspath;
  156. }
  157. if (!class_exists($className)) {
  158. try {
  159. require_once 'Zend/Loader.php';
  160. Zend_Loader::loadClass($className, $classPath);
  161. } catch (Exception $e) {
  162. require_once 'Zend/Amf/Server/Exception.php';
  163. throw new Zend_Amf_Server_Exception('Class "' . $className . '" does not exist');
  164. }
  165. }
  166. // Add the new loaded class to the server.
  167. $this->setClass($className, $source);
  168. } else {
  169. require_once 'Zend/Amf/Server/Exception.php';
  170. throw new Zend_Amf_Server_Exception('Method "' . $method . '" does not exist');
  171. }
  172. }
  173. $info = $this->_table[$qualifiedName];
  174. $argv = $info->getInvokeArguments();
  175. if (0 < count($argv)) {
  176. $params = array_merge($params, $argv);
  177. }
  178. if ($info instanceof Zend_Server_Reflection_Function) {
  179. $func = $info->getName();
  180. $return = call_user_func_array($func, $params);
  181. } elseif ($info instanceof Zend_Server_Reflection_Method) {
  182. // Get class
  183. $class = $info->getDeclaringClass()->getName();
  184. if ('static' == $info->isStatic()) {
  185. // for some reason, invokeArgs() does not work the same as
  186. // invoke(), and expects the first argument to be an object.
  187. // So, using a callback if the method is static.
  188. $return = call_user_func_array(array($class, $info->getName()), $params);
  189. } else {
  190. // Object methods
  191. try {
  192. $object = $info->getDeclaringClass()->newInstance();
  193. } catch (Exception $e) {
  194. require_once 'Zend/Amf/Server/Exception.php';
  195. throw new Zend_Amf_Server_Exception('Error instantiating class ' . $class . ' to invoke method ' . $info->getName(), 621);
  196. }
  197. $return = $info->invokeArgs($object, $params);
  198. }
  199. } else {
  200. require_once 'Zend/Amf/Server/Exception.php';
  201. throw new Zend_Amf_Server_Exception('Method missing implementation ' . get_class($info));
  202. }
  203. return $return;
  204. }
  205. /**
  206. * Handles each of the 11 different command message types.
  207. *
  208. * A command message is a flex.messaging.messages.CommandMessage
  209. *
  210. * @see Zend_Amf_Value_Messaging_CommandMessage
  211. * @param Zend_Amf_Value_Messaging_CommandMessage $message
  212. * @return Zend_Amf_Value_Messaging_AcknowledgeMessage
  213. */
  214. protected function _loadCommandMessage(Zend_Amf_Value_Messaging_CommandMessage $message)
  215. {
  216. switch($message->operation) {
  217. case Zend_Amf_Value_Messaging_CommandMessage::CLIENT_PING_OPERATION :
  218. require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
  219. $return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
  220. break;
  221. default :
  222. require_once 'Zend/Amf/Server/Exception.php';
  223. throw new Zend_Amf_Server_Exception('CommandMessage::' . $message->operation . ' not implemented');
  224. break;
  225. }
  226. return $return;
  227. }
  228. /**
  229. * Takes the deserialized AMF request and performs any operations.
  230. *
  231. * @todo should implement and SPL observer pattern for custom AMF headers
  232. * @todo implement AMF header authentication
  233. * @param Zend_Amf_Request $request
  234. * @return Zend_Amf_Response
  235. * @throws Zend_Amf_server_Exception|Exception
  236. */
  237. protected function _handle(Zend_Amf_Request $request)
  238. {
  239. // Get the object encoding of the request.
  240. $objectEncoding = $request->getObjectEncoding();
  241. // create a response object to place the output from the services.
  242. $response = $this->getResponse();
  243. // set reponse encoding
  244. $response->setObjectEncoding($objectEncoding);
  245. $responseBody = $request->getAmfBodies();
  246. // Iterate through each of the service calls in the AMF request
  247. foreach($responseBody as $body)
  248. {
  249. try {
  250. if ($objectEncoding == Zend_Amf_Constants::AMF0_OBJECT_ENCODING) {
  251. // AMF0 Object Encoding
  252. $targetURI = $body->getTargetURI();
  253. // Split the target string into its values.
  254. $source = substr($targetURI, 0, strrpos($targetURI, '.'));
  255. if ($source) {
  256. // Break off method name from namespace into source
  257. $method = substr(strrchr($targetURI, '.'), 1);
  258. $return = $this->_dispatch($method, $body->getData(), $source);
  259. } else {
  260. // Just have a method name.
  261. $return = $this->_dispatch($targetURI, $body->getData());
  262. }
  263. } else {
  264. // AMF3 read message type
  265. $message = $body->getData();
  266. if ($message instanceof Zend_Amf_Value_Messaging_CommandMessage) {
  267. // async call with command message
  268. $return = $this->_loadCommandMessage($message);
  269. } elseif ($message instanceof Zend_Amf_Value_Messaging_RemotingMessage) {
  270. require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
  271. $return = new Zend_Amf_Value_Messaging_AcknowledgeMessage($message);
  272. $return->body = $this->_dispatch($message->operation, $message->body, $message->source);
  273. } else {
  274. // Amf3 message sent with netConnection
  275. $targetURI = $body->getTargetURI();
  276. // Split the target string into its values.
  277. $source = substr($targetURI, 0, strrpos($targetURI, '.'));
  278. if ($source) {
  279. // Break off method name from namespace into source
  280. $method = substr(strrchr($targetURI, '.'), 1);
  281. $return = $this->_dispatch($method, $body->getData(), $source);
  282. } else {
  283. // Just have a method name.
  284. $return = $this->_dispatch($targetURI, $body->getData());
  285. }
  286. }
  287. }
  288. $responseType = Zend_AMF_Constants::RESULT_METHOD;
  289. } catch (Exception $e) {
  290. switch ($objectEncoding) {
  291. case Zend_Amf_Constants::AMF0_OBJECT_ENCODING :
  292. $return = array(
  293. 'description' => ($this->isProduction()) ? '' : $e->getMessage(),
  294. 'detail' => ($this->isProduction()) ? '' : $e->getTraceAsString(),
  295. 'line' => ($this->isProduction()) ? 0 : $e->getLine(),
  296. 'code' => $e->getCode(),
  297. );
  298. break;
  299. case Zend_Amf_Constants::AMF3_OBJECT_ENCODING :
  300. require_once 'Zend/Amf/Value/Messaging/ErrorMessage.php';
  301. $return = new Zend_Amf_Value_Messaging_ErrorMessage($message);
  302. $return->faultString = $this->isProduction() ? '' : $e->getMessage();
  303. $return->faultCode = $e->getCode();
  304. $return->faultDetail = $this->isProduction() ? '' : $e->getTraceAsString();
  305. break;
  306. }
  307. $responseType = Zend_AMF_Constants::STATUS_METHOD;
  308. }
  309. $responseURI = $body->getResponseURI() . $responseType;
  310. $newBody = new Zend_Amf_Value_MessageBody($responseURI, null, $return);
  311. $response->addAmfBody($newBody);
  312. }
  313. // Add a session header to the body if session is requested.
  314. if($this->isSession()) {
  315. $currentID = session_id();
  316. $joint = "?";
  317. if(isset($_SERVER['QUERY_STRING'])) {
  318. if(!strpos($_SERVER['QUERY_STRING'], $currentID) !== FALSE) {
  319. if(strrpos($_SERVER['QUERY_STRING'], "?") !== FALSE) {
  320. $joint = "&";
  321. }
  322. }
  323. }
  324. // create a new AMF message header with the session id as a variable.
  325. $sessionValue = $joint . $this->_sessionName . "=" . $currentID;
  326. $sessionHeader = new Zend_Amf_Value_MessageHeader("AppendToGatewayUrl", false, $sessionValue);
  327. $response->addAmfHeader($sessionHeader);
  328. }
  329. // serialize the response and return serialized body.
  330. $response->finalize();
  331. }
  332. /**
  333. * Handle an AMF call from the gateway.
  334. *
  335. * @param null|Zend_Amf_Request $request Optional
  336. * @return Zend_Amf_Response
  337. */
  338. public function handle($request = null)
  339. {
  340. // Check if request was passed otherwise get it from the server
  341. if (is_null($request) || !$request instanceof Zend_Amf_Request) {
  342. $request = $this->getRequest();
  343. } else {
  344. $this->setRequest($request);
  345. }
  346. if ($this->isSession()) {
  347. // Check if a session is being sent from the amf call
  348. if (isset($_COOKIE[$this->_sessionName])) {
  349. session_id($_COOKIE[$this->_sessionName]);
  350. }
  351. }
  352. // Check for errors that may have happend in deserialization of Request.
  353. try {
  354. // Take converted PHP objects and handle service call.
  355. // Serialize to Zend_Amf_response for output stream
  356. $this->_handle($request);
  357. $response = $this->getResponse();
  358. } catch (Exception $e) {
  359. // Handle any errors in the serialization and service calls.
  360. require_once 'Zend/Amf/Server/Exception.php';
  361. throw new Zend_Amf_Server_Exception('Handle error: ' . $e->getMessage() . ' ' . $e->getLine());
  362. }
  363. // Return the Amf serialized output string
  364. return $response;
  365. }
  366. /**
  367. * Set request object
  368. *
  369. * @param string|Zend_Amf_Request $request
  370. * @return Zend_Amf_Server
  371. */
  372. public function setRequest($request)
  373. {
  374. if (is_string($request) && class_exists($request)) {
  375. $request = new $request();
  376. if (!$request instanceof Zend_Amf_Request) {
  377. require_once 'Zend/Amf/Server/Exception.php';
  378. throw new Zend_Amf_Server_Exception('Invalid request class');
  379. }
  380. } elseif (!$request instanceof Zend_Amf_Request) {
  381. require_once 'Zend/Amf/Server/Exception.php';
  382. throw new Zend_Amf_Server_Exception('Invalid request object');
  383. }
  384. $this->_request = $request;
  385. return $this;
  386. }
  387. /**
  388. * Return currently registered request object
  389. *
  390. * @return null|Zend_Amf_Request
  391. */
  392. public function getRequest()
  393. {
  394. if (null === $this->_request) {
  395. require_once 'Zend/Amf/Request/Http.php';
  396. $this->setRequest(new Zend_Amf_Request_Http());
  397. }
  398. return $this->_request;
  399. }
  400. /**
  401. * Public access method to private Zend_Amf_Server_Response refrence
  402. *
  403. * @param string|Zend_Amf_Server_Response $response
  404. * @return Zend_Amf_Server
  405. */
  406. public function setResponse($response)
  407. {
  408. if (is_string($response) && class_exists($response)) {
  409. $response = new $response();
  410. if (!$response instanceof Zend_Amf_Response) {
  411. require_once 'Zend/Amf/Server/Exception.php';
  412. throw new Zend_Amf_Server_Exception('Invalid response class');
  413. }
  414. } elseif (!$response instanceof Zend_Amf_Response) {
  415. require_once 'Zend/Amf/Server/Exception.php';
  416. throw new Zend_Amf_Server_Exception('Invalid response object');
  417. }
  418. $this->_response = $response;
  419. return $this;
  420. }
  421. /**
  422. * get a refrence to the Zend_Amf_response instance
  423. *
  424. * @return Zend_Amf_Server_Response
  425. */
  426. public function getResponse()
  427. {
  428. if (null === ($response = $this->_response)) {
  429. require_once 'Zend/Amf/Response/Http.php';
  430. $this->setResponse(new Zend_Amf_Response_Http());
  431. }
  432. return $this->_response;
  433. }
  434. /**
  435. * Attach a class or object to the server
  436. *
  437. * Class may be either a class name or an instantiated object. Reflection
  438. * is done on the class or object to determine the available public
  439. * methods, and each is attached to the server as and available method. If
  440. * a $namespace has been provided, that namespace is used to prefix
  441. * AMF service call.
  442. *
  443. * @param string|object $class
  444. * @param string $namespace Optional
  445. * @param mixed $arg Optional arguments to pass to a method
  446. * @return Zend_Amf_Server
  447. * @throws Zend_Amf_Server_Exception on invalid input
  448. */
  449. public function setClass($class, $namespace = '', $argv = null)
  450. {
  451. if (is_string($class) && !class_exists($class)){
  452. require_once 'Zend/Amf/Server/Exception.php';
  453. throw new Zend_Amf_Server_Exception('Invalid method or class');
  454. } elseif (!is_string($class) && !is_object($class)) {
  455. require_once 'Zend/Amf/Server/Exception.php';
  456. throw new Zend_Amf_Server_Exception('Invalid method or class; must be a classname or object');
  457. }
  458. $argv = null;
  459. if (2 < func_num_args()) {
  460. $argv = array_slice(func_get_args(), 2);
  461. }
  462. // Use the class name as the name space by default.
  463. if ($namespace == '') {
  464. $namespace = is_object($class) ? get_class($class) : $class;
  465. }
  466. $this->_methods[] = Zend_Server_Reflection::reflectClass($class, $argv, $namespace);
  467. $this->_buildDispatchTable();
  468. return $this;
  469. }
  470. /**
  471. * Attach a function to the server
  472. *
  473. * Additional arguments to pass to the function at dispatch may be passed;
  474. * any arguments following the namespace will be aggregated and passed at
  475. * dispatch time.
  476. *
  477. * @param string|array $function Valid callback
  478. * @param string $namespace Optional namespace prefix
  479. * @return Zend_Amf_Server
  480. * @throws Zend_Amf_Server_Exception
  481. */
  482. public function addFunction($function, $namespace = '')
  483. {
  484. if (!is_string($function) && !is_array($function)) {
  485. require_once 'Zend/Amf/Server/Exception.php';
  486. throw new Zend_Amf_Server_Exception('Unable to attach function');
  487. }
  488. $argv = null;
  489. if (2 < func_num_args()) {
  490. $argv = array_slice(func_get_args(), 2);
  491. }
  492. $function = (array) $function;
  493. foreach ($function as $func) {
  494. if (!is_string($func) || !function_exists($func)) {
  495. require_once 'Zend/Amf/Server/Exception.php';
  496. throw new Zend_Amf_Server_Exception('Unable to attach function');
  497. }
  498. $this->_methods[] = Zend_Server_Reflection::reflectFunction($func, $argv, $namespace);
  499. }
  500. $this->_buildDispatchTable();
  501. return $this;
  502. }
  503. /**
  504. * Creates an array of directories in which services can reside.
  505. *
  506. * @param string $dir
  507. */
  508. public function addDirectory($dir)
  509. {
  510. $this->_directories[] = $dir;
  511. }
  512. /**
  513. * Returns an array of directories that can hold services.
  514. *
  515. * @return array
  516. */
  517. public function getDirectory()
  518. {
  519. return $this->_directories;
  520. }
  521. /**
  522. * (Re)Build the dispatch table
  523. *
  524. * The dispatch table consists of a an array of method name =>
  525. * Zend_Server_Reflection_Function_Abstract pairs
  526. *
  527. * @return void
  528. */
  529. protected function _buildDispatchTable()
  530. {
  531. $table = array();
  532. foreach ($this->_methods as $key => $dispatchable) {
  533. if ($dispatchable instanceof Zend_Server_Reflection_Function_Abstract) {
  534. $ns = $dispatchable->getNamespace();
  535. $name = $dispatchable->getName();
  536. $name = empty($ns) ? $name : $ns . '.' . $name;
  537. if (isset($table[$name])) {
  538. require_once 'Zend/Amf/Server/Exception.php';
  539. throw new Zend_Amf_Server_Exception('Duplicate method registered: ' . $name);
  540. }
  541. $table[$name] = $dispatchable;
  542. continue;
  543. }
  544. if ($dispatchable instanceof Zend_Server_Reflection_Class) {
  545. foreach ($dispatchable->getMethods() as $method) {
  546. $ns = $method->getNamespace();
  547. $name = $method->getName();
  548. $name = empty($ns) ? $name : $ns . '.' . $name;
  549. if (isset($table[$name])) {
  550. require_once 'Zend/Amf/Server/Exception.php';
  551. throw new Zend_Amf_Server_Exception('Duplicate method registered: ' . $name);
  552. }
  553. $table[$name] = $method;
  554. continue;
  555. }
  556. }
  557. }
  558. $this->_table = $table;
  559. }
  560. /**
  561. * Raise a server fault
  562. *
  563. * Unimplemented
  564. *
  565. * @param string|Exception $fault
  566. * @return void
  567. */
  568. public function fault($fault = null, $code = 404)
  569. {
  570. }
  571. /**
  572. * Returns a list of registered methods
  573. *
  574. * Returns an array of dispatchables (Zend_Server_Reflection_Function,
  575. * _Method, and _Class items).
  576. *
  577. * @return array
  578. */
  579. public function getFunctions()
  580. {
  581. return $this->_table;
  582. }
  583. /**
  584. * Set server persistence
  585. *
  586. * Unimplemented
  587. *
  588. * @param mixed $mode
  589. * @return void
  590. */
  591. public function setPersistence($mode)
  592. {
  593. }
  594. /**
  595. * Load server definition
  596. *
  597. * Unimplemented
  598. *
  599. * @param array $definition
  600. * @return void
  601. */
  602. public function loadFunctions($definition)
  603. {
  604. }
  605. /**
  606. * Map ActionScript classes to PHP classes
  607. *
  608. * @param string $asClass
  609. * @param string $phpClass
  610. * @return Zend_Amf_Server
  611. */
  612. public function setClassMap($asClass, $phpClass)
  613. {
  614. require_once 'Zend/Amf/Parse/TypeLoader.php';
  615. Zend_Amf_Parse_TypeLoader::setMapping($asClass, $phpClass);
  616. return $this;
  617. }
  618. /**
  619. * List all available methods
  620. *
  621. * Returns an array of method names.
  622. *
  623. * @return array
  624. */
  625. public function listMethods()
  626. {
  627. return array_keys($this->_table);
  628. }
  629. }