You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2015/05/09 15:11:58 UTC

[6/8] airavata-php-gateway git commit: Adding missing files

Adding missing files


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/e1a1024f
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/e1a1024f
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/e1a1024f

Branch: refs/heads/master
Commit: e1a1024f372bf485ccaa7e68efd00cb3bd33f44b
Parents: 3ca0215
Author: Supun Nakandala <su...@gmail.com>
Authored: Sat May 9 14:15:37 2015 +0530
Committer: Supun Nakandala <su...@gmail.com>
Committed: Sat May 9 14:15:37 2015 +0530

----------------------------------------------------------------------
 .../Airavata/AiravataServiceProvider.php        | 80 ++++++++++++++++++++
 app/libraries/Airavata/Facades/Airavata.php     | 16 ++++
 2 files changed, 96 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e1a1024f/app/libraries/Airavata/AiravataServiceProvider.php
----------------------------------------------------------------------
diff --git a/app/libraries/Airavata/AiravataServiceProvider.php b/app/libraries/Airavata/AiravataServiceProvider.php
new file mode 100755
index 0000000..2ff4db1
--- /dev/null
+++ b/app/libraries/Airavata/AiravataServiceProvider.php
@@ -0,0 +1,80 @@
+<?php namespace Airavata;
+
+use Illuminate\Support\ServiceProvider;
+use Illuminate\Support\Facades\Config;
+use Airavata\API\AiravataClient;
+use Thrift\Transport\TSocket;
+use Thrift\Protocol\TBinaryProtocol;
+
+class AiravataServiceProvider extends ServiceProvider {
+
+	/**
+	 * Indicates if loading of the provider is deferred.
+	 *
+	 * @var bool
+	 */
+	protected $defer = false;
+
+    /**
+     * Bootstrap the application events.
+     *
+     * @return void
+     */
+    public function boot()
+    {
+        $this->package('airavata/airavata');
+    }
+
+	/**
+	 * Register the service provider.
+	 *
+	 * @return void
+	 */
+	public function register()
+	{
+        //registering service provider
+        $this->app['airavata'] = $this->app->share(function($app)
+        {
+            try{
+                $transport = new TSocket(
+                    Config::get('pga_config.airavata')['airavata-server'],
+                    Config::get('pga_config.airavata')['airavata-port']
+                );
+                $transport->setRecvTimeout( Config::get('pga_config.airavata')['airavata-timeout']);
+                $transport->setSendTimeout( Config::get('pga_config.airavata')['airavata-timeout']);
+
+                $protocol = new TBinaryProtocol($transport);
+                $transport->open();
+
+                $client = new AiravataClient($protocol);
+
+            }catch (\Exception $ex){
+                var_dump($ex);
+                exit;
+            }
+
+            if( is_object( $client))
+                return $client;
+            else
+                return Redirect::to("airavata/down");
+        });
+
+        //registering alis
+        $this->app->booting(function()
+        {
+            $loader = \Illuminate\Foundation\AliasLoader::getInstance();
+            $loader->alias('Airavata', 'Airavata\Facades\Airavata');
+        });
+	}
+
+	/**
+	 * Get the services provided by the provider.
+	 *
+	 * @return array
+	 */
+	public function provides()
+	{
+		return array('airavata');
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/e1a1024f/app/libraries/Airavata/Facades/Airavata.php
----------------------------------------------------------------------
diff --git a/app/libraries/Airavata/Facades/Airavata.php b/app/libraries/Airavata/Facades/Airavata.php
new file mode 100755
index 0000000..1446c2c
--- /dev/null
+++ b/app/libraries/Airavata/Facades/Airavata.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace Airavata\Facades;
+
+use Illuminate\Support\Facades\Facade;
+
+class Airavata extends Facade {
+
+    /**
+     * Get the registered name of the component.
+     *
+     * @return string
+     */
+    protected static function getFacadeAccessor() { return 'airavata'; }
+
+}
\ No newline at end of file