Example #1
0
 /**
  * Attempt locating an abstract (passing any supplied parameters)
  * from the container and the embedded Application.
  *
  * *Order of events:*
  *      1. Does the abstract exist in the app container?
  *      2. Does the abstract exist in the container?
  *      3. Fail with ContainerAbstractNotFound exception.
  *
  * @param string     $abstract
  * @param array|NULL $parameters
  *
  * @return mixed|null
  *
  * @throws DependencyInstanceNotFound
  */
 public static function find($abstract, array $parameters = [])
 {
     static::$instance = static::$instance ?: new static();
     // find in the app first
     if (static::$app and static::$app->offsetExists($abstract)) {
         return static::$app[$abstract];
     }
     // find in Illuminate/Container
     if (static::$instance->bound($abstract)) {
         return static::$instance->make($abstract, $parameters);
     }
     throw new DependencyInstanceNotFound("Dependency or instance `{$abstract}` not found.");
 }