-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from GravityKit/prepare-league-upgrade
- Loading branch information
Showing
10 changed files
with
168 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace GFExcel\Container; | ||
|
||
use League\Container\Container as LeagueContainer; | ||
use League\Container\ReflectionContainer; | ||
use Psr\Container\ContainerExceptionInterface; | ||
use Psr\Container\NotFoundExceptionInterface; | ||
|
||
/** | ||
* Container implementation backed by the League Container package. | ||
* @since $ver$ | ||
*/ | ||
final class Container implements ContainerInterface | ||
{ | ||
/** | ||
* The league container class. | ||
* @since $ver$ | ||
* @var LeagueContainer | ||
*/ | ||
private $container; | ||
|
||
public function __construct() | ||
{ | ||
$this->container = new LeagueContainer(); | ||
$this->container | ||
->defaultToShared() | ||
->delegate(new ReflectionContainer()); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @since $ver$ | ||
*/ | ||
public function addServiceProvider(ServiceProviderInterface $provider) : ContainerInterface | ||
{ | ||
$this->container->addServiceProvider($provider); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @since $ver$ | ||
*/ | ||
public function get(string $id) | ||
{ | ||
try { | ||
return $this->container->get($id); | ||
} catch (NotFoundExceptionInterface|ContainerExceptionInterface $e) { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @since $ver$ | ||
*/ | ||
public function has(string $id) : bool | ||
{ | ||
return $this->container->has($id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace GFExcel\Container; | ||
|
||
/** | ||
* The container contract. | ||
* @since $ver$ | ||
*/ | ||
interface ContainerInterface | ||
{ | ||
/** | ||
* Registers a service provider which registers services with the container. | ||
* @since $ver$ | ||
* @return static | ||
*/ | ||
public function addServiceProvider(ServiceProviderInterface $provider) : self; | ||
|
||
/** | ||
* Returns the service by the service ID. | ||
* @since $ver$ | ||
* @param string $id The service ID. | ||
* @return mixed|null The service or `null`. | ||
*/ | ||
public function get(string $id); | ||
|
||
/** | ||
* Whether the container holds the provided service ID. | ||
* @since $ver$ | ||
* @param string $id The service ID. | ||
* @return bool | ||
*/ | ||
public function has(string $id) : bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace GFExcel\Container; | ||
|
||
use League\Container\ServiceProvider\BootableServiceProviderInterface; | ||
use League\Container\ServiceProvider\ServiceProviderInterface as LeagueServiceProviderInterface; | ||
|
||
interface ServiceProviderInterface extends LeagueServiceProviderInterface, BootableServiceProviderInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters