Return-Path: X-Original-To: apmail-airavata-commits-archive@www.apache.org Delivered-To: apmail-airavata-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7E734177F9 for ; Fri, 1 May 2015 21:32:50 +0000 (UTC) Received: (qmail 96831 invoked by uid 500); 1 May 2015 21:32:50 -0000 Delivered-To: apmail-airavata-commits-archive@airavata.apache.org Received: (qmail 96721 invoked by uid 500); 1 May 2015 21:32:50 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 95130 invoked by uid 99); 1 May 2015 21:32:48 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 May 2015 21:32:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AAB6FE41E3; Fri, 1 May 2015 21:32:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ndoshi@apache.org To: commits@airavata.apache.org Date: Fri, 01 May 2015 21:33:08 -0000 Message-Id: In-Reply-To: <75facea618c04426a66df940fb7893c3@git.apache.org> References: <75facea618c04426a66df940fb7893c3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [21/57] [partial] airavata-php-gateway git commit: AIRAVATA 1632 + Job Description for Admin Dashboard http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Container/Container.php ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Container/Container.php b/vendor/laravel/framework/src/Illuminate/Container/Container.php new file mode 100755 index 0000000..84b606e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Container/Container.php @@ -0,0 +1,866 @@ +bound($abstract) || $this->isAlias($abstract); + } + + /** + * Determine if the given abstract type has been bound. + * + * @param string $abstract + * @return bool + */ + public function bound($abstract) + { + return isset($this->bindings[$abstract]) || isset($this->instances[$abstract]); + } + + /** + * Determine if the given abstract type has been resolved. + * + * @param string $abstract + * @return bool + */ + public function resolved($abstract) + { + return isset($this->resolved[$abstract]) || isset($this->instances[$abstract]); + } + + /** + * Determine if a given string is an alias. + * + * @param string $name + * @return bool + */ + public function isAlias($name) + { + return isset($this->aliases[$name]); + } + + /** + * Register a binding with the container. + * + * @param string|array $abstract + * @param \Closure|string|null $concrete + * @param bool $shared + * @return void + */ + public function bind($abstract, $concrete = null, $shared = false) + { + // If the given types are actually an array, we will assume an alias is being + // defined and will grab this "real" abstract class name and register this + // alias with the container so that it can be used as a shortcut for it. + if (is_array($abstract)) + { + list($abstract, $alias) = $this->extractAlias($abstract); + + $this->alias($abstract, $alias); + } + + // If no concrete type was given, we will simply set the concrete type to the + // abstract type. This will allow concrete type to be registered as shared + // without being forced to state their classes in both of the parameter. + $this->dropStaleInstances($abstract); + + if (is_null($concrete)) + { + $concrete = $abstract; + } + + // If the factory is not a Closure, it means it is just a class name which is + // is bound into this container to the abstract type and we will just wrap + // it up inside a Closure to make things more convenient when extending. + if ( ! $concrete instanceof Closure) + { + $concrete = $this->getClosure($abstract, $concrete); + } + + $this->bindings[$abstract] = compact('concrete', 'shared'); + + // If the abstract type was already resolved in this container we'll fire the + // rebound listener so that any objects which have already gotten resolved + // can have their copy of the object updated via the listener callbacks. + if ($this->resolved($abstract)) + { + $this->rebound($abstract); + } + } + + /** + * Get the Closure to be used when building a type. + * + * @param string $abstract + * @param string $concrete + * @return \Closure + */ + protected function getClosure($abstract, $concrete) + { + return function($c, $parameters = array()) use ($abstract, $concrete) + { + $method = ($abstract == $concrete) ? 'build' : 'make'; + + return $c->$method($concrete, $parameters); + }; + } + + /** + * Register a binding if it hasn't already been registered. + * + * @param string $abstract + * @param \Closure|string|null $concrete + * @param bool $shared + * @return void + */ + public function bindIf($abstract, $concrete = null, $shared = false) + { + if ( ! $this->bound($abstract)) + { + $this->bind($abstract, $concrete, $shared); + } + } + + /** + * Register a shared binding in the container. + * + * @param string $abstract + * @param \Closure|string|null $concrete + * @return void + */ + public function singleton($abstract, $concrete = null) + { + $this->bind($abstract, $concrete, true); + } + + /** + * Wrap a Closure such that it is shared. + * + * @param \Closure $closure + * @return \Closure + */ + public function share(Closure $closure) + { + return function($container) use ($closure) + { + // We'll simply declare a static variable within the Closures and if it has + // not been set we will execute the given Closures to resolve this value + // and return it back to these consumers of the method as an instance. + static $object; + + if (is_null($object)) + { + $object = $closure($container); + } + + return $object; + }; + } + + /** + * Bind a shared Closure into the container. + * + * @param string $abstract + * @param \Closure $closure + * @return void + */ + public function bindShared($abstract, Closure $closure) + { + $this->bind($abstract, $this->share($closure), true); + } + + /** + * "Extend" an abstract type in the container. + * + * @param string $abstract + * @param \Closure $closure + * @return void + * + * @throws \InvalidArgumentException + */ + public function extend($abstract, Closure $closure) + { + if ( ! isset($this->bindings[$abstract])) + { + throw new \InvalidArgumentException("Type {$abstract} is not bound."); + } + + if (isset($this->instances[$abstract])) + { + $this->instances[$abstract] = $closure($this->instances[$abstract], $this); + + $this->rebound($abstract); + } + else + { + $extender = $this->getExtender($abstract, $closure); + + $this->bind($abstract, $extender, $this->isShared($abstract)); + } + } + + /** + * Get an extender Closure for resolving a type. + * + * @param string $abstract + * @param \Closure $closure + * @return \Closure + */ + protected function getExtender($abstract, Closure $closure) + { + // To "extend" a binding, we will grab the old "resolver" Closure and pass it + // into a new one. The old resolver will be called first and the result is + // handed off to the "new" resolver, along with this container instance. + $resolver = $this->bindings[$abstract]['concrete']; + + return function($container) use ($resolver, $closure) + { + return $closure($resolver($container), $container); + }; + } + + /** + * Register an existing instance as shared in the container. + * + * @param string $abstract + * @param mixed $instance + * @return void + */ + public function instance($abstract, $instance) + { + // First, we will extract the alias from the abstract if it is an array so we + // are using the correct name when binding the type. If we get an alias it + // will be registered with the container so we can resolve it out later. + if (is_array($abstract)) + { + list($abstract, $alias) = $this->extractAlias($abstract); + + $this->alias($abstract, $alias); + } + + unset($this->aliases[$abstract]); + + // We'll check to determine if this type has been bound before, and if it has + // we will fire the rebound callbacks registered with the container and it + // can be updated with consuming classes that have gotten resolved here. + $bound = $this->bound($abstract); + + $this->instances[$abstract] = $instance; + + if ($bound) + { + $this->rebound($abstract); + } + } + + /** + * Alias a type to a shorter name. + * + * @param string $abstract + * @param string $alias + * @return void + */ + public function alias($abstract, $alias) + { + $this->aliases[$alias] = $abstract; + } + + /** + * Extract the type and alias from a given definition. + * + * @param array $definition + * @return array + */ + protected function extractAlias(array $definition) + { + return array(key($definition), current($definition)); + } + + /** + * Bind a new callback to an abstract's rebind event. + * + * @param string $abstract + * @param \Closure $callback + * @return mixed + */ + public function rebinding($abstract, Closure $callback) + { + $this->reboundCallbacks[$abstract][] = $callback; + + if ($this->bound($abstract)) return $this->make($abstract); + } + + /** + * Refresh an instance on the given target and method. + * + * @param string $abstract + * @param mixed $target + * @param string $method + * @return mixed + */ + public function refresh($abstract, $target, $method) + { + return $this->rebinding($abstract, function($app, $instance) use ($target, $method) + { + $target->{$method}($instance); + }); + } + + /** + * Fire the "rebound" callbacks for the given abstract type. + * + * @param string $abstract + * @return void + */ + protected function rebound($abstract) + { + $instance = $this->make($abstract); + + foreach ($this->getReboundCallbacks($abstract) as $callback) + { + call_user_func($callback, $this, $instance); + } + } + + /** + * Get the rebound callbacks for a given type. + * + * @param string $abstract + * @return array + */ + protected function getReboundCallbacks($abstract) + { + if (isset($this->reboundCallbacks[$abstract])) + { + return $this->reboundCallbacks[$abstract]; + } + + return array(); + } + + /** + * Resolve the given type from the container. + * + * @param string $abstract + * @param array $parameters + * @return mixed + */ + public function make($abstract, $parameters = array()) + { + $abstract = $this->getAlias($abstract); + + // If an instance of the type is currently being managed as a singleton we'll + // just return an existing instance instead of instantiating new instances + // so the developer can keep using the same objects instance every time. + if (isset($this->instances[$abstract])) + { + return $this->instances[$abstract]; + } + + $concrete = $this->getConcrete($abstract); + + // We're ready to instantiate an instance of the concrete type registered for + // the binding. This will instantiate the types, as well as resolve any of + // its "nested" dependencies recursively until all have gotten resolved. + if ($this->isBuildable($concrete, $abstract)) + { + $object = $this->build($concrete, $parameters); + } + else + { + $object = $this->make($concrete, $parameters); + } + + // If the requested type is registered as a singleton we'll want to cache off + // the instances in "memory" so we can return it later without creating an + // entirely new instance of an object on each subsequent request for it. + if ($this->isShared($abstract)) + { + $this->instances[$abstract] = $object; + } + + $this->fireResolvingCallbacks($abstract, $object); + + $this->resolved[$abstract] = true; + + return $object; + } + + /** + * Get the concrete type for a given abstract. + * + * @param string $abstract + * @return mixed $concrete + */ + protected function getConcrete($abstract) + { + // If we don't have a registered resolver or concrete for the type, we'll just + // assume each type is a concrete name and will attempt to resolve it as is + // since the container should be able to resolve concretes automatically. + if ( ! isset($this->bindings[$abstract])) + { + if ($this->missingLeadingSlash($abstract) && isset($this->bindings['\\'.$abstract])) + { + $abstract = '\\'.$abstract; + } + + return $abstract; + } + + return $this->bindings[$abstract]['concrete']; + } + + /** + * Determine if the given abstract has a leading slash. + * + * @param string $abstract + * @return bool + */ + protected function missingLeadingSlash($abstract) + { + return is_string($abstract) && strpos($abstract, '\\') !== 0; + } + + /** + * Instantiate a concrete instance of the given type. + * + * @param string $concrete + * @param array $parameters + * @return mixed + * + * @throws BindingResolutionException + */ + public function build($concrete, $parameters = array()) + { + // If the concrete type is actually a Closure, we will just execute it and + // hand back the results of the functions, which allows functions to be + // used as resolvers for more fine-tuned resolution of these objects. + if ($concrete instanceof Closure) + { + return $concrete($this, $parameters); + } + + $reflector = new ReflectionClass($concrete); + + // If the type is not instantiable, the developer is attempting to resolve + // an abstract type such as an Interface of Abstract Class and there is + // no binding registered for the abstractions so we need to bail out. + if ( ! $reflector->isInstantiable()) + { + $message = "Target [$concrete] is not instantiable."; + + throw new BindingResolutionException($message); + } + + $constructor = $reflector->getConstructor(); + + // If there are no constructors, that means there are no dependencies then + // we can just resolve the instances of the objects right away, without + // resolving any other types or dependencies out of these containers. + if (is_null($constructor)) + { + return new $concrete; + } + + $dependencies = $constructor->getParameters(); + + // Once we have all the constructor's parameters we can create each of the + // dependency instances and then use the reflection instances to make a + // new instance of this class, injecting the created dependencies in. + $parameters = $this->keyParametersByArgument( + $dependencies, $parameters + ); + + $instances = $this->getDependencies( + $dependencies, $parameters + ); + + return $reflector->newInstanceArgs($instances); + } + + /** + * Resolve all of the dependencies from the ReflectionParameters. + * + * @param array $parameters + * @param array $primitives + * @return array + */ + protected function getDependencies($parameters, array $primitives = array()) + { + $dependencies = array(); + + foreach ($parameters as $parameter) + { + $dependency = $parameter->getClass(); + + // If the class is null, it means the dependency is a string or some other + // primitive type which we can not resolve since it is not a class and + // we will just bomb out with an error since we have no-where to go. + if (array_key_exists($parameter->name, $primitives)) + { + $dependencies[] = $primitives[$parameter->name]; + } + elseif (is_null($dependency)) + { + $dependencies[] = $this->resolveNonClass($parameter); + } + else + { + $dependencies[] = $this->resolveClass($parameter); + } + } + + return (array) $dependencies; + } + + /** + * Resolve a non-class hinted dependency. + * + * @param \ReflectionParameter $parameter + * @return mixed + * + * @throws BindingResolutionException + */ + protected function resolveNonClass(ReflectionParameter $parameter) + { + if ($parameter->isDefaultValueAvailable()) + { + return $parameter->getDefaultValue(); + } + + $message = "Unresolvable dependency resolving [$parameter] in class {$parameter->getDeclaringClass()->getName()}"; + + throw new BindingResolutionException($message); + } + + /** + * Resolve a class based dependency from the container. + * + * @param \ReflectionParameter $parameter + * @return mixed + * + * @throws BindingResolutionException + */ + protected function resolveClass(ReflectionParameter $parameter) + { + try + { + return $this->make($parameter->getClass()->name); + } + + // If we can not resolve the class instance, we will check to see if the value + // is optional, and if it is we will return the optional parameter value as + // the value of the dependency, similarly to how we do this with scalars. + catch (BindingResolutionException $e) + { + if ($parameter->isOptional()) + { + return $parameter->getDefaultValue(); + } + + throw $e; + } + } + + /** + * If extra parameters are passed by numeric ID, rekey them by argument name. + * + * @param array $dependencies + * @param array $parameters + * @return array + */ + protected function keyParametersByArgument(array $dependencies, array $parameters) + { + foreach ($parameters as $key => $value) + { + if (is_numeric($key)) + { + unset($parameters[$key]); + + $parameters[$dependencies[$key]->name] = $value; + } + } + + return $parameters; + } + + /** + * Register a new resolving callback. + * + * @param string $abstract + * @param \Closure $callback + * @return void + */ + public function resolving($abstract, Closure $callback) + { + $this->resolvingCallbacks[$abstract][] = $callback; + } + + /** + * Register a new resolving callback for all types. + * + * @param \Closure $callback + * @return void + */ + public function resolvingAny(Closure $callback) + { + $this->globalResolvingCallbacks[] = $callback; + } + + /** + * Fire all of the resolving callbacks. + * + * @param string $abstract + * @param mixed $object + * @return void + */ + protected function fireResolvingCallbacks($abstract, $object) + { + if (isset($this->resolvingCallbacks[$abstract])) + { + $this->fireCallbackArray($object, $this->resolvingCallbacks[$abstract]); + } + + $this->fireCallbackArray($object, $this->globalResolvingCallbacks); + } + + /** + * Fire an array of callbacks with an object. + * + * @param mixed $object + * @param array $callbacks + */ + protected function fireCallbackArray($object, array $callbacks) + { + foreach ($callbacks as $callback) + { + call_user_func($callback, $object, $this); + } + } + + /** + * Determine if a given type is shared. + * + * @param string $abstract + * @return bool + */ + public function isShared($abstract) + { + if (isset($this->bindings[$abstract]['shared'])) + { + $shared = $this->bindings[$abstract]['shared']; + } + else + { + $shared = false; + } + + return isset($this->instances[$abstract]) || $shared === true; + } + + /** + * Determine if the given concrete is buildable. + * + * @param mixed $concrete + * @param string $abstract + * @return bool + */ + protected function isBuildable($concrete, $abstract) + { + return $concrete === $abstract || $concrete instanceof Closure; + } + + /** + * Get the alias for an abstract if available. + * + * @param string $abstract + * @return string + */ + protected function getAlias($abstract) + { + return isset($this->aliases[$abstract]) ? $this->aliases[$abstract] : $abstract; + } + + /** + * Get the container's bindings. + * + * @return array + */ + public function getBindings() + { + return $this->bindings; + } + + /** + * Drop all of the stale instances and aliases. + * + * @param string $abstract + * @return void + */ + protected function dropStaleInstances($abstract) + { + unset($this->instances[$abstract], $this->aliases[$abstract]); + } + + /** + * Remove a resolved instance from the instance cache. + * + * @param string $abstract + * @return void + */ + public function forgetInstance($abstract) + { + unset($this->instances[$abstract]); + } + + /** + * Clear all of the instances from the container. + * + * @return void + */ + public function forgetInstances() + { + $this->instances = array(); + } + + /** + * Determine if a given offset exists. + * + * @param string $key + * @return bool + */ + public function offsetExists($key) + { + return isset($this->bindings[$key]); + } + + /** + * Get the value at a given offset. + * + * @param string $key + * @return mixed + */ + public function offsetGet($key) + { + return $this->make($key); + } + + /** + * Set the value at a given offset. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function offsetSet($key, $value) + { + // If the value is not a Closure, we will make it one. This simply gives + // more "drop-in" replacement functionality for the Pimple which this + // container's simplest functions are base modeled and built after. + if ( ! $value instanceof Closure) + { + $value = function() use ($value) + { + return $value; + }; + } + + $this->bind($key, $value); + } + + /** + * Unset the value at a given offset. + * + * @param string $key + * @return void + */ + public function offsetUnset($key) + { + unset($this->bindings[$key], $this->instances[$key], $this->resolved[$key]); + } + + /** + * Dynamically access container services. + * + * @param string $key + * @return mixed + */ + public function __get($key) + { + return $this[$key]; + } + + /** + * Dynamically set container services. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function __set($key, $value) + { + $this[$key] = $value; + } + +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Container/composer.json ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Container/composer.json b/vendor/laravel/framework/src/Illuminate/Container/composer.json new file mode 100755 index 0000000..a2445f1 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Container/composer.json @@ -0,0 +1,25 @@ +{ + "name": "illuminate/container", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.4.0" + }, + "autoload": { + "psr-0": { + "Illuminate\\Container": "" + } + }, + "target-dir": "Illuminate/Container", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "minimum-stability": "dev" +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php b/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php new file mode 100755 index 0000000..56e531a --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php @@ -0,0 +1,167 @@ +getPathAndDomain($path, $domain); + + $time = ($minutes == 0) ? 0 : time() + ($minutes * 60); + + return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly); + } + + /** + * Create a cookie that lasts "forever" (five years). + * + * @param string $name + * @param string $value + * @param string $path + * @param string $domain + * @param bool $secure + * @param bool $httpOnly + * @return \Symfony\Component\HttpFoundation\Cookie + */ + public function forever($name, $value, $path = null, $domain = null, $secure = false, $httpOnly = true) + { + return $this->make($name, $value, 2628000, $path, $domain, $secure, $httpOnly); + } + + /** + * Expire the given cookie. + * + * @param string $name + * @param string $path + * @param string $domain + * @return \Symfony\Component\HttpFoundation\Cookie + */ + public function forget($name, $path = null, $domain = null) + { + return $this->make($name, null, -2628000, $path, $domain); + } + + /** + * Determine if a cookie has been queued. + * + * @param string $key + * @return bool + */ + public function hasQueued($key) + { + return ! is_null($this->queued($key)); + } + + /** + * Get a queued cookie instance. + * + * @param string $key + * @param mixed $default + * @return \Symfony\Component\HttpFoundation\Cookie + */ + public function queued($key, $default = null) + { + return array_get($this->queued, $key, $default); + } + + /** + * Queue a cookie to send with the next response. + * + * @param mixed + * @return void + */ + public function queue() + { + if (head(func_get_args()) instanceof Cookie) + { + $cookie = head(func_get_args()); + } + else + { + $cookie = call_user_func_array(array($this, 'make'), func_get_args()); + } + + $this->queued[$cookie->getName()] = $cookie; + } + + /** + * Remove a cookie from the queue. + * + * @param string $name + */ + public function unqueue($name) + { + unset($this->queued[$name]); + } + + /** + * Get the path and domain, or the default values. + * + * @param string $path + * @param string $domain + * @return array + */ + protected function getPathAndDomain($path, $domain) + { + return array($path ?: $this->path, $domain ?: $this->domain); + } + + /** + * Set the default path and domain for the jar. + * + * @param string $path + * @param string $domain + * @return $this + */ + public function setDefaultPathAndDomain($path, $domain) + { + list($this->path, $this->domain) = array($path, $domain); + + return $this; + } + + /** + * Get the cookies which have been queued for the next request + * + * @return array + */ + public function getQueuedCookies() + { + return $this->queued; + } + +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php new file mode 100755 index 0000000..1c7b9d0 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php @@ -0,0 +1,22 @@ +app->bindShared('cookie', function($app) + { + $config = $app['config']['session']; + + return (new CookieJar)->setDefaultPathAndDomain($config['path'], $config['domain']); + }); + } + +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php b/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php new file mode 100644 index 0000000..1aafbef --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php @@ -0,0 +1,141 @@ +app = $app; + $this->encrypter = $encrypter; + } + + /** + * Handle the given request and get the response. + * + * @implements HttpKernelInterface::handle + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @param int $type + * @param bool $catch + * @return \Symfony\Component\HttpFoundation\Response + */ + public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) + { + return $this->encrypt($this->app->handle($this->decrypt($request), $type, $catch)); + } + + /** + * Decrypt the cookies on the request. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return \Symfony\Component\HttpFoundation\Request + */ + protected function decrypt(Request $request) + { + foreach ($request->cookies as $key => $c) + { + try + { + $request->cookies->set($key, $this->decryptCookie($c)); + } + catch (DecryptException $e) + { + $request->cookies->set($key, null); + } + } + + return $request; + } + + /** + * Decrypt the given cookie and return the value. + * + * @param string|array $cookie + * @return string|array + */ + protected function decryptCookie($cookie) + { + return is_array($cookie) + ? $this->decryptArray($cookie) + : $this->encrypter->decrypt($cookie); + } + + /** + * Decrypt an array based cookie. + * + * @param array $cookie + * @return array + */ + protected function decryptArray(array $cookie) + { + $decrypted = array(); + + foreach ($cookie as $key => $value) + { + $decrypted[$key] = $this->encrypter->decrypt($value); + } + + return $decrypted; + } + + /** + * Encrypt the cookies on an outgoing response. + * + * @param \Symfony\Component\HttpFoundation\Response $response + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function encrypt(Response $response) + { + foreach ($response->headers->getCookies() as $key => $c) + { + $encrypted = $this->encrypter->encrypt($c->getValue()); + + $response->headers->setCookie($this->duplicate($c, $encrypted)); + } + + return $response; + } + + /** + * Duplicate a cookie with a new value. + * + * @param \Symfony\Component\HttpFoundation\Cookie $c + * @param mixed $value + * @return \Symfony\Component\HttpFoundation\Cookie + */ + protected function duplicate(Cookie $c, $value) + { + return new Cookie( + $c->getName(), $value, $c->getExpiresTime(), $c->getPath(), + $c->getDomain(), $c->isSecure(), $c->isHttpOnly() + ); + } + +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php b/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php new file mode 100644 index 0000000..65354cb --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php @@ -0,0 +1,57 @@ +app = $app; + $this->cookies = $cookies; + } + + /** + * Handle the given request and get the response. + * + * @implements HttpKernelInterface::handle + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @param int $type + * @param bool $catch + * @return \Symfony\Component\HttpFoundation\Response + */ + public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) + { + $response = $this->app->handle($request, $type, $catch); + + foreach ($this->cookies->getQueuedCookies() as $cookie) + { + $response->headers->setCookie($cookie); + } + + return $response; + } + +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Cookie/composer.json ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Cookie/composer.json b/vendor/laravel/framework/src/Illuminate/Cookie/composer.json new file mode 100755 index 0000000..aa9559d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cookie/composer.json @@ -0,0 +1,29 @@ +{ + "name": "illuminate/cookie", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.4.0", + "illuminate/encryption": "4.2.*", + "illuminate/support": "4.2.*", + "symfony/http-kernel": "2.5.*", + "symfony/http-foundation": "2.5.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Cookie": "" + } + }, + "target-dir": "Illuminate/Cookie", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "minimum-stability": "dev" +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Database/Capsule/Manager.php ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Database/Capsule/Manager.php b/vendor/laravel/framework/src/Illuminate/Database/Capsule/Manager.php new file mode 100755 index 0000000..408e563 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Capsule/Manager.php @@ -0,0 +1,227 @@ +setupContainer($container); + + // Once we have the container setup, we will setup the default configuration + // options in the container "config" binding. This will make the database + // manager behave correctly since all the correct binding are in place. + $this->setupDefaultConfiguration(); + + $this->setupManager(); + } + + /** + * Setup the default database configuration options. + * + * @return void + */ + protected function setupDefaultConfiguration() + { + $this->container['config']['database.fetch'] = PDO::FETCH_ASSOC; + + $this->container['config']['database.default'] = 'default'; + } + + /** + * Build the database manager instance. + * + * @return void + */ + protected function setupManager() + { + $factory = new ConnectionFactory($this->container); + + $this->manager = new DatabaseManager($this->container, $factory); + } + + /** + * Get a connection instance from the global manager. + * + * @param string $connection + * @return \Illuminate\Database\Connection + */ + public static function connection($connection = null) + { + return static::$instance->getConnection($connection); + } + + /** + * Get a fluent query builder instance. + * + * @param string $table + * @param string $connection + * @return \Illuminate\Database\Query\Builder + */ + public static function table($table, $connection = null) + { + return static::$instance->connection($connection)->table($table); + } + + /** + * Get a schema builder instance. + * + * @param string $connection + * @return \Illuminate\Database\Schema\Builder + */ + public static function schema($connection = null) + { + return static::$instance->connection($connection)->getSchemaBuilder(); + } + + /** + * Get a registered connection instance. + * + * @param string $name + * @return \Illuminate\Database\Connection + */ + public function getConnection($name = null) + { + return $this->manager->connection($name); + } + + /** + * Register a connection with the manager. + * + * @param array $config + * @param string $name + * @return void + */ + public function addConnection(array $config, $name = 'default') + { + $connections = $this->container['config']['database.connections']; + + $connections[$name] = $config; + + $this->container['config']['database.connections'] = $connections; + } + + /** + * Bootstrap Eloquent so it is ready for usage. + * + * @return void + */ + public function bootEloquent() + { + Eloquent::setConnectionResolver($this->manager); + + // If we have an event dispatcher instance, we will go ahead and register it + // with the Eloquent ORM, allowing for model callbacks while creating and + // updating "model" instances; however, if it not necessary to operate. + if ($dispatcher = $this->getEventDispatcher()) + { + Eloquent::setEventDispatcher($dispatcher); + } + } + + /** + * Set the fetch mode for the database connections. + * + * @param int $fetchMode + * @return $this + */ + public function setFetchMode($fetchMode) + { + $this->container['config']['database.fetch'] = $fetchMode; + + return $this; + } + + /** + * Get the database manager instance. + * + * @return \Illuminate\Database\DatabaseManager + */ + public function getDatabaseManager() + { + return $this->manager; + } + + /** + * Get the current event dispatcher instance. + * + * @return \Illuminate\Events\Dispatcher + */ + public function getEventDispatcher() + { + if ($this->container->bound('events')) + { + return $this->container['events']; + } + } + + /** + * Set the event dispatcher instance to be used by connections. + * + * @param \Illuminate\Events\Dispatcher $dispatcher + * @return void + */ + public function setEventDispatcher(Dispatcher $dispatcher) + { + $this->container->instance('events', $dispatcher); + } + + /** + * Get the current cache manager instance. + * + * @return \Illuminate\Cache\CacheManager + */ + public function getCacheManager() + { + if ($this->container->bound('cache')) + { + return $this->container['cache']; + } + } + + /** + * Set the cache manager to be used by connections. + * + * @param \Illuminate\Cache\CacheManager $cache + * @return void + */ + public function setCacheManager(CacheManager $cache) + { + $this->container->instance('cache', $cache); + } + + /** + * Dynamically pass methods to the default connection. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public static function __callStatic($method, $parameters) + { + return call_user_func_array(array(static::connection(), $method), $parameters); + } + +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Database/Connection.php ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Database/Connection.php b/vendor/laravel/framework/src/Illuminate/Database/Connection.php new file mode 100755 index 0000000..fd09205 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Connection.php @@ -0,0 +1,1173 @@ +pdo = $pdo; + + // First we will setup the default properties. We keep track of the DB + // name we are connected to since it is needed when some reflective + // type commands are run such as checking whether a table exists. + $this->database = $database; + + $this->tablePrefix = $tablePrefix; + + $this->config = $config; + + // We need to initialize a query grammar and the query post processors + // which are both very important parts of the database abstractions + // so we initialize these to their default values while starting. + $this->useDefaultQueryGrammar(); + + $this->useDefaultPostProcessor(); + } + + /** + * Set the query grammar to the default implementation. + * + * @return void + */ + public function useDefaultQueryGrammar() + { + $this->queryGrammar = $this->getDefaultQueryGrammar(); + } + + /** + * Get the default query grammar instance. + * + * @return \Illuminate\Database\Query\Grammars\Grammar + */ + protected function getDefaultQueryGrammar() + { + return new Query\Grammars\Grammar; + } + + /** + * Set the schema grammar to the default implementation. + * + * @return void + */ + public function useDefaultSchemaGrammar() + { + $this->schemaGrammar = $this->getDefaultSchemaGrammar(); + } + + /** + * Get the default schema grammar instance. + * + * @return \Illuminate\Database\Schema\Grammars\Grammar + */ + protected function getDefaultSchemaGrammar() {} + + /** + * Set the query post processor to the default implementation. + * + * @return void + */ + public function useDefaultPostProcessor() + { + $this->postProcessor = $this->getDefaultPostProcessor(); + } + + /** + * Get the default post processor instance. + * + * @return \Illuminate\Database\Query\Processors\Processor + */ + protected function getDefaultPostProcessor() + { + return new Query\Processors\Processor; + } + + /** + * Get a schema builder instance for the connection. + * + * @return \Illuminate\Database\Schema\Builder + */ + public function getSchemaBuilder() + { + if (is_null($this->schemaGrammar)) { $this->useDefaultSchemaGrammar(); } + + return new Schema\Builder($this); + } + + /** + * Begin a fluent query against a database table. + * + * @param string $table + * @return \Illuminate\Database\Query\Builder + */ + public function table($table) + { + $processor = $this->getPostProcessor(); + + $query = new Query\Builder($this, $this->getQueryGrammar(), $processor); + + return $query->from($table); + } + + /** + * Get a new raw query expression. + * + * @param mixed $value + * @return \Illuminate\Database\Query\Expression + */ + public function raw($value) + { + return new Query\Expression($value); + } + + /** + * Run a select statement and return a single result. + * + * @param string $query + * @param array $bindings + * @return mixed + */ + public function selectOne($query, $bindings = array()) + { + $records = $this->select($query, $bindings); + + return count($records) > 0 ? reset($records) : null; + } + + /** + * Run a select statement against the database. + * + * @param string $query + * @param array $bindings + * @return array + */ + public function selectFromWriteConnection($query, $bindings = array()) + { + return $this->select($query, $bindings, false); + } + + /** + * Run a select statement against the database. + * + * @param string $query + * @param array $bindings + * @param bool $useReadPdo + * @return array + */ + public function select($query, $bindings = array(), $useReadPdo = true) + { + return $this->run($query, $bindings, function($me, $query, $bindings) use ($useReadPdo) + { + if ($me->pretending()) return array(); + + // For select statements, we'll simply execute the query and return an array + // of the database result set. Each element in the array will be a single + // row from the database table, and will either be an array or objects. + $statement = $this->getPdoForSelect($useReadPdo)->prepare($query); + + $statement->execute($me->prepareBindings($bindings)); + + return $statement->fetchAll($me->getFetchMode()); + }); + } + + /** + * Get the PDO connection to use for a select query. + * + * @param bool $useReadPdo + * @return \PDO + */ + protected function getPdoForSelect($useReadPdo = true) + { + return $useReadPdo ? $this->getReadPdo() : $this->getPdo(); + } + + /** + * Run an insert statement against the database. + * + * @param string $query + * @param array $bindings + * @return bool + */ + public function insert($query, $bindings = array()) + { + return $this->statement($query, $bindings); + } + + /** + * Run an update statement against the database. + * + * @param string $query + * @param array $bindings + * @return int + */ + public function update($query, $bindings = array()) + { + return $this->affectingStatement($query, $bindings); + } + + /** + * Run a delete statement against the database. + * + * @param string $query + * @param array $bindings + * @return int + */ + public function delete($query, $bindings = array()) + { + return $this->affectingStatement($query, $bindings); + } + + /** + * Execute an SQL statement and return the boolean result. + * + * @param string $query + * @param array $bindings + * @return bool + */ + public function statement($query, $bindings = array()) + { + return $this->run($query, $bindings, function($me, $query, $bindings) + { + if ($me->pretending()) return true; + + $bindings = $me->prepareBindings($bindings); + + return $me->getPdo()->prepare($query)->execute($bindings); + }); + } + + /** + * Run an SQL statement and get the number of rows affected. + * + * @param string $query + * @param array $bindings + * @return int + */ + public function affectingStatement($query, $bindings = array()) + { + return $this->run($query, $bindings, function($me, $query, $bindings) + { + if ($me->pretending()) return 0; + + // For update or delete statements, we want to get the number of rows affected + // by the statement and return that back to the developer. We'll first need + // to execute the statement and then we'll use PDO to fetch the affected. + $statement = $me->getPdo()->prepare($query); + + $statement->execute($me->prepareBindings($bindings)); + + return $statement->rowCount(); + }); + } + + /** + * Run a raw, unprepared query against the PDO connection. + * + * @param string $query + * @return bool + */ + public function unprepared($query) + { + return $this->run($query, array(), function($me, $query) + { + if ($me->pretending()) return true; + + return (bool) $me->getPdo()->exec($query); + }); + } + + /** + * Prepare the query bindings for execution. + * + * @param array $bindings + * @return array + */ + public function prepareBindings(array $bindings) + { + $grammar = $this->getQueryGrammar(); + + foreach ($bindings as $key => $value) + { + // We need to transform all instances of the DateTime class into an actual + // date string. Each query grammar maintains its own date string format + // so we'll just ask the grammar for the format to get from the date. + if ($value instanceof DateTime) + { + $bindings[$key] = $value->format($grammar->getDateFormat()); + } + elseif ($value === false) + { + $bindings[$key] = 0; + } + } + + return $bindings; + } + + /** + * Execute a Closure within a transaction. + * + * @param \Closure $callback + * @return mixed + * + * @throws \Exception + */ + public function transaction(Closure $callback) + { + $this->beginTransaction(); + + // We'll simply execute the given callback within a try / catch block + // and if we catch any exception we can rollback the transaction + // so that none of the changes are persisted to the database. + try + { + $result = $callback($this); + + $this->commit(); + } + + // If we catch an exception, we will roll back so nothing gets messed + // up in the database. Then we'll re-throw the exception so it can + // be handled how the developer sees fit for their applications. + catch (\Exception $e) + { + $this->rollBack(); + + throw $e; + } + + return $result; + } + + /** + * Start a new database transaction. + * + * @return void + */ + public function beginTransaction() + { + ++$this->transactions; + + if ($this->transactions == 1) + { + $this->pdo->beginTransaction(); + } + + $this->fireConnectionEvent('beganTransaction'); + } + + /** + * Commit the active database transaction. + * + * @return void + */ + public function commit() + { + if ($this->transactions == 1) $this->pdo->commit(); + + --$this->transactions; + + $this->fireConnectionEvent('committed'); + } + + /** + * Rollback the active database transaction. + * + * @return void + */ + public function rollBack() + { + if ($this->transactions == 1) + { + $this->transactions = 0; + + $this->pdo->rollBack(); + } + else + { + --$this->transactions; + } + + $this->fireConnectionEvent('rollingBack'); + } + + /** + * Get the number of active transactions. + * + * @return int + */ + public function transactionLevel() + { + return $this->transactions; + } + + /** + * Execute the given callback in "dry run" mode. + * + * @param \Closure $callback + * @return array + */ + public function pretend(Closure $callback) + { + $this->pretending = true; + + $this->queryLog = array(); + + // Basically to make the database connection "pretend", we will just return + // the default values for all the query methods, then we will return an + // array of queries that were "executed" within the Closure callback. + $callback($this); + + $this->pretending = false; + + return $this->queryLog; + } + + /** + * Run a SQL statement and log its execution context. + * + * @param string $query + * @param array $bindings + * @param \Closure $callback + * @return mixed + * + * @throws \Illuminate\Database\QueryException + */ + protected function run($query, $bindings, Closure $callback) + { + $this->reconnectIfMissingConnection(); + + $start = microtime(true); + + // Here we will run this query. If an exception occurs we'll determine if it was + // caused by a connection that has been lost. If that is the cause, we'll try + // to re-establish connection and re-run the query with a fresh connection. + try + { + $result = $this->runQueryCallback($query, $bindings, $callback); + } + catch (QueryException $e) + { + $result = $this->tryAgainIfCausedByLostConnection( + $e, $query, $bindings, $callback + ); + } + + // Once we have run the query we will calculate the time that it took to run and + // then log the query, bindings, and execution time so we will report them on + // the event that the developer needs them. We'll log time in milliseconds. + $time = $this->getElapsedTime($start); + + $this->logQuery($query, $bindings, $time); + + return $result; + } + + /** + * Run a SQL statement. + * + * @param string $query + * @param array $bindings + * @param \Closure $callback + * @return mixed + * + * @throws \Illuminate\Database\QueryException + */ + protected function runQueryCallback($query, $bindings, Closure $callback) + { + // To execute the statement, we'll simply call the callback, which will actually + // run the SQL against the PDO connection. Then we can calculate the time it + // took to execute and log the query SQL, bindings and time in our memory. + try + { + $result = $callback($this, $query, $bindings); + } + + // If an exception occurs when attempting to run a query, we'll format the error + // message to include the bindings with SQL, which will make this exception a + // lot more helpful to the developer instead of just the database's errors. + catch (\Exception $e) + { + throw new QueryException( + $query, $this->prepareBindings($bindings), $e + ); + } + + return $result; + } + + /** + * Handle a query exception that occurred during query execution. + * + * @param \Illuminate\Database\QueryException $e + * @param string $query + * @param array $bindings + * @param \Closure $callback + * @return mixed + * + * @throws \Illuminate\Database\QueryException + */ + protected function tryAgainIfCausedByLostConnection(QueryException $e, $query, $bindings, Closure $callback) + { + if ($this->causedByLostConnection($e)) + { + $this->reconnect(); + + return $this->runQueryCallback($query, $bindings, $callback); + } + + throw $e; + } + + /** + * Determine if the given exception was caused by a lost connection. + * + * @param \Illuminate\Database\QueryException + * @return bool + */ + protected function causedByLostConnection(QueryException $e) + { + return str_contains($e->getPrevious()->getMessage(), 'server has gone away'); + } + + /** + * Disconnect from the underlying PDO connection. + * + * @return void + */ + public function disconnect() + { + $this->setPdo(null)->setReadPdo(null); + } + + /** + * Reconnect to the database. + * + * @return void + * + * @throws \LogicException + */ + public function reconnect() + { + if (is_callable($this->reconnector)) + { + return call_user_func($this->reconnector, $this); + } + + throw new \LogicException("Lost connection and no reconnector available."); + } + + /** + * Reconnect to the database if a PDO connection is missing. + * + * @return void + */ + protected function reconnectIfMissingConnection() + { + if (is_null($this->getPdo()) || is_null($this->getReadPdo())) + { + $this->reconnect(); + } + } + + /** + * Log a query in the connection's query log. + * + * @param string $query + * @param array $bindings + * @param float|null $time + * @return void + */ + public function logQuery($query, $bindings, $time = null) + { + if (isset($this->events)) + { + $this->events->fire('illuminate.query', array($query, $bindings, $time, $this->getName())); + } + + if ( ! $this->loggingQueries) return; + + $this->queryLog[] = compact('query', 'bindings', 'time'); + } + + /** + * Register a database query listener with the connection. + * + * @param \Closure $callback + * @return void + */ + public function listen(Closure $callback) + { + if (isset($this->events)) + { + $this->events->listen('illuminate.query', $callback); + } + } + + /** + * Fire an event for this connection. + * + * @param string $event + * @return void + */ + protected function fireConnectionEvent($event) + { + if (isset($this->events)) + { + $this->events->fire('connection.'.$this->getName().'.'.$event, $this); + } + } + + /** + * Get the elapsed time since a given starting point. + * + * @param int $start + * @return float + */ + protected function getElapsedTime($start) + { + return round((microtime(true) - $start) * 1000, 2); + } + + /** + * Get a Doctrine Schema Column instance. + * + * @param string $table + * @param string $column + * @return \Doctrine\DBAL\Schema\Column + */ + public function getDoctrineColumn($table, $column) + { + $schema = $this->getDoctrineSchemaManager(); + + return $schema->listTableDetails($table)->getColumn($column); + } + + /** + * Get the Doctrine DBAL schema manager for the connection. + * + * @return \Doctrine\DBAL\Schema\AbstractSchemaManager + */ + public function getDoctrineSchemaManager() + { + return $this->getDoctrineDriver()->getSchemaManager($this->getDoctrineConnection()); + } + + /** + * Get the Doctrine DBAL database connection instance. + * + * @return \Doctrine\DBAL\Connection + */ + public function getDoctrineConnection() + { + $driver = $this->getDoctrineDriver(); + + $data = array('pdo' => $this->pdo, 'dbname' => $this->getConfig('database')); + + return new DoctrineConnection($data, $driver); + } + + /** + * Get the current PDO connection. + * + * @return \PDO + */ + public function getPdo() + { + return $this->pdo; + } + + /** + * Get the current PDO connection used for reading. + * + * @return \PDO + */ + public function getReadPdo() + { + if ($this->transactions >= 1) return $this->getPdo(); + + return $this->readPdo ?: $this->pdo; + } + + /** + * Set the PDO connection. + * + * @param \PDO|null $pdo + * @return $this + */ + public function setPdo($pdo) + { + if ($this->transactions >= 1) + throw new \RuntimeException("Can't swap PDO instance while within transaction."); + + $this->pdo = $pdo; + + return $this; + } + + /** + * Set the PDO connection used for reading. + * + * @param \PDO|null $pdo + * @return $this + */ + public function setReadPdo($pdo) + { + $this->readPdo = $pdo; + + return $this; + } + + /** + * Set the reconnect instance on the connection. + * + * @param callable $reconnector + * @return $this + */ + public function setReconnector(callable $reconnector) + { + $this->reconnector = $reconnector; + + return $this; + } + + /** + * Get the database connection name. + * + * @return string|null + */ + public function getName() + { + return $this->getConfig('name'); + } + + /** + * Get an option from the configuration options. + * + * @param string $option + * @return mixed + */ + public function getConfig($option) + { + return array_get($this->config, $option); + } + + /** + * Get the PDO driver name. + * + * @return string + */ + public function getDriverName() + { + return $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); + } + + /** + * Get the query grammar used by the connection. + * + * @return \Illuminate\Database\Query\Grammars\Grammar + */ + public function getQueryGrammar() + { + return $this->queryGrammar; + } + + /** + * Set the query grammar used by the connection. + * + * @param \Illuminate\Database\Query\Grammars\Grammar + * @return void + */ + public function setQueryGrammar(Query\Grammars\Grammar $grammar) + { + $this->queryGrammar = $grammar; + } + + /** + * Get the schema grammar used by the connection. + * + * @return \Illuminate\Database\Query\Grammars\Grammar + */ + public function getSchemaGrammar() + { + return $this->schemaGrammar; + } + + /** + * Set the schema grammar used by the connection. + * + * @param \Illuminate\Database\Schema\Grammars\Grammar + * @return void + */ + public function setSchemaGrammar(Schema\Grammars\Grammar $grammar) + { + $this->schemaGrammar = $grammar; + } + + /** + * Get the query post processor used by the connection. + * + * @return \Illuminate\Database\Query\Processors\Processor + */ + public function getPostProcessor() + { + return $this->postProcessor; + } + + /** + * Set the query post processor used by the connection. + * + * @param \Illuminate\Database\Query\Processors\Processor + * @return void + */ + public function setPostProcessor(Processor $processor) + { + $this->postProcessor = $processor; + } + + /** + * Get the event dispatcher used by the connection. + * + * @return \Illuminate\Events\Dispatcher + */ + public function getEventDispatcher() + { + return $this->events; + } + + /** + * Set the event dispatcher instance on the connection. + * + * @param \Illuminate\Events\Dispatcher + * @return void + */ + public function setEventDispatcher(Dispatcher $events) + { + $this->events = $events; + } + + /** + * Get the paginator environment instance. + * + * @return \Illuminate\Pagination\Factory + */ + public function getPaginator() + { + if ($this->paginator instanceof Closure) + { + $this->paginator = call_user_func($this->paginator); + } + + return $this->paginator; + } + + /** + * Set the pagination environment instance. + * + * @param \Illuminate\Pagination\Factory|\Closure $paginator + * @return void + */ + public function setPaginator($paginator) + { + $this->paginator = $paginator; + } + + /** + * Get the cache manager instance. + * + * @return \Illuminate\Cache\CacheManager + */ + public function getCacheManager() + { + if ($this->cache instanceof Closure) + { + $this->cache = call_user_func($this->cache); + } + + return $this->cache; + } + + /** + * Set the cache manager instance on the connection. + * + * @param \Illuminate\Cache\CacheManager|\Closure $cache + * @return void + */ + public function setCacheManager($cache) + { + $this->cache = $cache; + } + + /** + * Determine if the connection in a "dry run". + * + * @return bool + */ + public function pretending() + { + return $this->pretending === true; + } + + /** + * Get the default fetch mode for the connection. + * + * @return int + */ + public function getFetchMode() + { + return $this->fetchMode; + } + + /** + * Set the default fetch mode for the connection. + * + * @param int $fetchMode + * @return int + */ + public function setFetchMode($fetchMode) + { + $this->fetchMode = $fetchMode; + } + + /** + * Get the connection query log. + * + * @return array + */ + public function getQueryLog() + { + return $this->queryLog; + } + + /** + * Clear the query log. + * + * @return void + */ + public function flushQueryLog() + { + $this->queryLog = array(); + } + + /** + * Enable the query log on the connection. + * + * @return void + */ + public function enableQueryLog() + { + $this->loggingQueries = true; + } + + /** + * Disable the query log on the connection. + * + * @return void + */ + public function disableQueryLog() + { + $this->loggingQueries = false; + } + + /** + * Determine whether we're logging queries. + * + * @return bool + */ + public function logging() + { + return $this->loggingQueries; + } + + /** + * Get the name of the connected database. + * + * @return string + */ + public function getDatabaseName() + { + return $this->database; + } + + /** + * Set the name of the connected database. + * + * @param string $database + * @return string + */ + public function setDatabaseName($database) + { + $this->database = $database; + } + + /** + * Get the table prefix for the connection. + * + * @return string + */ + public function getTablePrefix() + { + return $this->tablePrefix; + } + + /** + * Set the table prefix in use by the connection. + * + * @param string $prefix + * @return void + */ + public function setTablePrefix($prefix) + { + $this->tablePrefix = $prefix; + + $this->getQueryGrammar()->setTablePrefix($prefix); + } + + /** + * Set the table prefix and return the grammar. + * + * @param \Illuminate\Database\Grammar $grammar + * @return \Illuminate\Database\Grammar + */ + public function withTablePrefix(Grammar $grammar) + { + $grammar->setTablePrefix($this->tablePrefix); + + return $grammar; + } + +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Database/ConnectionInterface.php ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Database/ConnectionInterface.php b/vendor/laravel/framework/src/Illuminate/Database/ConnectionInterface.php new file mode 100755 index 0000000..48d69b3 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/ConnectionInterface.php @@ -0,0 +1,148 @@ + $connection) + { + $this->addConnection($name, $connection); + } + } + + /** + * Get a database connection instance. + * + * @param string $name + * @return \Illuminate\Database\Connection + */ + public function connection($name = null) + { + if (is_null($name)) $name = $this->getDefaultConnection(); + + return $this->connections[$name]; + } + + /** + * Add a connection to the resolver. + * + * @param string $name + * @param \Illuminate\Database\Connection $connection + * @return void + */ + public function addConnection($name, Connection $connection) + { + $this->connections[$name] = $connection; + } + + /** + * Check if a connection has been registered. + * + * @param string $name + * @return bool + */ + public function hasConnection($name) + { + return isset($this->connections[$name]); + } + + /** + * Get the default connection name. + * + * @return string + */ + public function getDefaultConnection() + { + return $this->default; + } + + /** + * Set the default connection name. + * + * @param string $name + * @return void + */ + public function setDefaultConnection($name) + { + $this->default = $name; + } + +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php b/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php new file mode 100755 index 0000000..46abdc0 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php @@ -0,0 +1,28 @@ +container = $container; + } + + /** + * Establish a PDO connection based on the configuration. + * + * @param array $config + * @param string $name + * @return \Illuminate\Database\Connection + */ + public function make(array $config, $name = null) + { + $config = $this->parseConfig($config, $name); + + if (isset($config['read'])) + { + return $this->createReadWriteConnection($config); + } + + return $this->createSingleConnection($config); + } + + /** + * Create a single database connection instance. + * + * @param array $config + * @return \Illuminate\Database\Connection + */ + protected function createSingleConnection(array $config) + { + $pdo = $this->createConnector($config)->connect($config); + + return $this->createConnection($config['driver'], $pdo, $config['database'], $config['prefix'], $config); + } + + /** + * Create a single database connection instance. + * + * @param array $config + * @return \Illuminate\Database\Connection + */ + protected function createReadWriteConnection(array $config) + { + $connection = $this->createSingleConnection($this->getWriteConfig($config)); + + return $connection->setReadPdo($this->createReadPdo($config)); + } + + /** + * Create a new PDO instance for reading. + * + * @param array $config + * @return \PDO + */ + protected function createReadPdo(array $config) + { + $readConfig = $this->getReadConfig($config); + + return $this->createConnector($readConfig)->connect($readConfig); + } + + /** + * Get the read configuration for a read / write connection. + * + * @param array $config + * @return array + */ + protected function getReadConfig(array $config) + { + $readConfig = $this->getReadWriteConfig($config, 'read'); + + return $this->mergeReadWriteConfig($config, $readConfig); + } + + /** + * Get the read configuration for a read / write connection. + * + * @param array $config + * @return array + */ + protected function getWriteConfig(array $config) + { + $writeConfig = $this->getReadWriteConfig($config, 'write'); + + return $this->mergeReadWriteConfig($config, $writeConfig); + } + + /** + * Get a read / write level configuration. + * + * @param array $config + * @param string $type + * @return array + */ + protected function getReadWriteConfig(array $config, $type) + { + if (isset($config[$type][0])) + { + return $config[$type][array_rand($config[$type])]; + } + + return $config[$type]; + } + + /** + * Merge a configuration for a read / write connection. + * + * @param array $config + * @param array $merge + * @return array + */ + protected function mergeReadWriteConfig(array $config, array $merge) + { + return array_except(array_merge($config, $merge), array('read', 'write')); + } + + /** + * Parse and prepare the database configuration. + * + * @param array $config + * @param string $name + * @return array + */ + protected function parseConfig(array $config, $name) + { + return array_add(array_add($config, 'prefix', ''), 'name', $name); + } + + /** + * Create a connector instance based on the configuration. + * + * @param array $config + * @return \Illuminate\Database\Connectors\ConnectorInterface + * + * @throws \InvalidArgumentException + */ + public function createConnector(array $config) + { + if ( ! isset($config['driver'])) + { + throw new \InvalidArgumentException("A driver must be specified."); + } + + if ($this->container->bound($key = "db.connector.{$config['driver']}")) + { + return $this->container->make($key); + } + + switch ($config['driver']) + { + case 'mysql': + return new MySqlConnector; + + case 'pgsql': + return new PostgresConnector; + + case 'sqlite': + return new SQLiteConnector; + + case 'sqlsrv': + return new SqlServerConnector; + } + + throw new \InvalidArgumentException("Unsupported driver [{$config['driver']}]"); + } + + /** + * Create a new connection instance. + * + * @param string $driver + * @param \PDO $connection + * @param string $database + * @param string $prefix + * @param array $config + * @return \Illuminate\Database\Connection + * + * @throws \InvalidArgumentException + */ + protected function createConnection($driver, PDO $connection, $database, $prefix = '', array $config = array()) + { + if ($this->container->bound($key = "db.connection.{$driver}")) + { + return $this->container->make($key, array($connection, $database, $prefix, $config)); + } + + switch ($driver) + { + case 'mysql': + return new MySqlConnection($connection, $database, $prefix, $config); + + case 'pgsql': + return new PostgresConnection($connection, $database, $prefix, $config); + + case 'sqlite': + return new SQLiteConnection($connection, $database, $prefix, $config); + + case 'sqlsrv': + return new SqlServerConnection($connection, $database, $prefix, $config); + } + + throw new \InvalidArgumentException("Unsupported driver [$driver]"); + } + +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php b/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php new file mode 100755 index 0000000..0c16093 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php @@ -0,0 +1,71 @@ + PDO::CASE_NATURAL, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, + PDO::ATTR_STRINGIFY_FETCHES => false, + PDO::ATTR_EMULATE_PREPARES => false, + ); + + /** + * Get the PDO options based on the configuration. + * + * @param array $config + * @return array + */ + public function getOptions(array $config) + { + $options = array_get($config, 'options', array()); + + return array_diff_key($this->options, $options) + $options; + } + + /** + * Create a new PDO connection. + * + * @param string $dsn + * @param array $config + * @param array $options + * @return \PDO + */ + public function createConnection($dsn, array $config, array $options) + { + $username = array_get($config, 'username'); + + $password = array_get($config, 'password'); + + return new PDO($dsn, $username, $password, $options); + } + + /** + * Get the default PDO connection options. + * + * @return array + */ + public function getDefaultOptions() + { + return $this->options; + } + + /** + * Set the default PDO connection options. + * + * @param array $options + * @return void + */ + public function setDefaultOptions(array $options) + { + $this->options = $options; + } + +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectorInterface.php ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectorInterface.php b/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectorInterface.php new file mode 100755 index 0000000..c2c76a5 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectorInterface.php @@ -0,0 +1,13 @@ +getDsn($config); + + $options = $this->getOptions($config); + + // We need to grab the PDO options that should be used while making the brand + // new connection instance. The PDO options control various aspects of the + // connection's behavior, and some might be specified by the developers. + $connection = $this->createConnection($dsn, $config, $options); + + if (isset($config['unix_socket'])) + { + $connection->exec("use `{$config['database']}`;"); + } + + $collation = $config['collation']; + + // Next we will set the "names" and "collation" on the clients connections so + // a correct character set will be used by this client. The collation also + // is set on the server but needs to be set here on this client objects. + $charset = $config['charset']; + + $names = "set names '$charset'". + ( ! is_null($collation) ? " collate '$collation'" : ''); + + $connection->prepare($names)->execute(); + + // If the "strict" option has been configured for the connection we'll enable + // strict mode on all of these tables. This enforces some extra rules when + // using the MySQL database system and is a quicker way to enforce them. + if (isset($config['strict']) && $config['strict']) + { + $connection->prepare("set session sql_mode='STRICT_ALL_TABLES'")->execute(); + } + + return $connection; + } + + /** + * Create a DSN string from a configuration. Chooses socket or host/port based on + * the 'unix_socket' config value + * + * @param array $config + * @return string + */ + protected function getDsn(array $config) + { + return $this->configHasSocket($config) ? $this->getSocketDsn($config) : $this->getHostDsn($config); + } + + /** + * Determine if the given configuration array has a UNIX socket value. + * + * @param array $config + * @return bool + */ + protected function configHasSocket(array $config) + { + return isset($config['unix_socket']) && ! empty($config['unix_socket']); + } + + /** + * Get the DSN string for a socket configuration. + * + * @param array $config + * @return string + */ + protected function getSocketDsn(array $config) + { + extract($config); + + return "mysql:unix_socket={$config['unix_socket']};dbname={$database}"; + } + + /** + * Get the DSN string for a host / port configuration. + * + * @param array $config + * @return string + */ + protected function getHostDsn(array $config) + { + extract($config); + + return isset($config['port']) + ? "mysql:host={$host};port={$port};dbname={$database}" + : "mysql:host={$host};dbname={$database}"; + } + +} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/01413d65/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php ---------------------------------------------------------------------- diff --git a/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php b/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php new file mode 100755 index 0000000..39b50e3 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php @@ -0,0 +1,86 @@ + PDO::CASE_NATURAL, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, + PDO::ATTR_STRINGIFY_FETCHES => false, + ); + + /** + * Establish a database connection. + * + * @param array $config + * @return \PDO + */ + public function connect(array $config) + { + // First we'll create the basic DSN and connection instance connecting to the + // using the configuration option specified by the developer. We will also + // set the default character set on the connections to UTF-8 by default. + $dsn = $this->getDsn($config); + + $options = $this->getOptions($config); + + $connection = $this->createConnection($dsn, $config, $options); + + $charset = $config['charset']; + + $connection->prepare("set names '$charset'")->execute(); + + // Unlike MySQL, Postgres allows the concept of "schema" and a default schema + // may have been specified on the connections. If that is the case we will + // set the default schema search paths to the specified database schema. + if (isset($config['schema'])) + { + $schema = $config['schema']; + + $connection->prepare("set search_path to {$schema}")->execute(); + } + + return $connection; + } + + /** + * Create a DSN string from a configuration. + * + * @param array $config + * @return string + */ + protected function getDsn(array $config) + { + // First we will create the basic DSN setup as well as the port if it is in + // in the configuration options. This will give us the basic DSN we will + // need to establish the PDO connections and return them back for use. + extract($config); + + $host = isset($host) ? "host={$host};" : ''; + + $dsn = "pgsql:{$host}dbname={$database}"; + + // If a port was specified, we will add it to this Postgres DSN connections + // format. Once we have done that we are ready to return this connection + // string back out for usage, as this has been fully constructed here. + if (isset($config['port'])) + { + $dsn .= ";port={$port}"; + } + + if (isset($config['sslmode'])) + { + $dsn .= ";sslmode={$sslmode}"; + } + + return $dsn; + } + +}