public function index()
 {
     // Require Zend_Amf_Server
     require_once 'Zend/Amf/Server.php';
     // *ZAMFBROWSER IMPLEMENTATION*
     // Require the ZendAmfServiceBrowser class, required to retrieve the list of methods on the ZendAMF server.
     require_once Kohana::find_file('vendor/ZamfBrowser', 'ZendAmfServiceBrowser');
     // Start Server
     $server = new Zend_Amf_Server();
     // $server->addDirectory( SHAREDPATH.Kohana::config('zendamf.services_path') );
     $services_path = APPPATH . Kohana::config('zendamf.services_path');
     $files = Kohana::list_files($services_path, FALSE);
     foreach ($files as $file) {
         $class = pathinfo($file, PATHINFO_FILENAME);
         $server->setClass($class);
     }
     // // do class mapping
     $vo_path = APPPATH . Kohana::config('zendamf.vo_path');
     $files = Kohana::list_files($vo_path, FALSE);
     foreach ($files as $file) {
         $class = pathinfo($file, PATHINFO_FILENAME);
         $server->setClassMap($class, $class);
     }
     // *ZAMFBROWSER IMPLEMENTATION*
     // Add the ZendAmfServiceBrowser class to the list of available classes.
     $server->setClass("ZendAmfServiceBrowser");
     // *ZAMFBROWSER IMPLEMENTATION*
     // Set this reference the class requires to the server object.
     // ZendAmfServiceBrowser::setAmfServer( $server );
     ZendAmfServiceBrowser::$ZEND_AMF_SERVER = $server;
     // Handle the AMF request
     echo $server->handle();
 }
예제 #2
0
 public function load()
 {
     $folder = 'AmfServices';
     defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__)));
     require_once dirname(__FILE__) . '/../lib/amf/browser/ZendAmfServiceBrowser.php';
     set_include_path(dirname(__FILE__) . '/../lib/amf/library' . PATH_SEPARATOR . get_include_path());
     require_once dirname(__FILE__) . '/../lib/amf/library/Zend/Amf/Server.php';
     $server = new \Zend_Amf_Server();
     set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/' . $folder . '/'), get_include_path())));
     $service_path = $this->container->getParameter('service_path');
     if (empty($service_path)) {
         $folder = APPLICATION_PATH . '/' . $folder . '/';
     } else {
         $folder = getcwd() . '/../src/' . $service_path . '/Services/AmfServices/';
         $folderPath = '/src/' . $service_path . '/Services/AmfServices/';
     }
     if (!is_dir($folder)) {
         echo 'path is undefined <br /> create: ' . $folderPath;
         die;
     }
     if (count(glob($folder . '*.php')) < 1) {
         echo 'no services defined';
         die;
     }
     foreach (glob($folder . '*.php') as $filename) {
         $service = basename($filename, ".php");
         $filerawname = basename($filename);
         if (file_exists($folder . $filerawname)) {
             include_once $folder . $filerawname;
             $server->setClass($service);
         }
     }
     $server->setClass("ZendAmfServiceBrowser");
     \ZendAmfServiceBrowser::$ZEND_AMF_SERVER = $server;
     return $server->handle();
 }