-
Notifications
You must be signed in to change notification settings - Fork 28
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 #133 from moufmouf/missing_dependency_exception
This PR fixes exception handling according to container-interop and incoming PSR-11 (Adds the Interop\Container\NotFoundException to the MoufInstanceNotFoundException) and does not throw it in case of nested missing dependencies.
- Loading branch information
Showing
4 changed files
with
88 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/* | ||
* This file is part of the Mouf core package. | ||
* | ||
* (c) 2012 David Negrier <david@mouf-php.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Mouf; | ||
use Interop\Container\Exception\ContainerException; | ||
|
||
/** | ||
* MissingDependencyException are thrown by the Mouf framework when the user | ||
* request an instance that has a dependency on an instance that does not exist. | ||
* | ||
*/ | ||
class MissingDependencyException extends MoufException implements ContainerException { | ||
|
||
/** | ||
* The name of the instance that was not found. | ||
* | ||
* @var string | ||
*/ | ||
private $instanceName; | ||
|
||
public function __construct($msg, $code = null, $instanceName = null, \Exception $causeException = null) { | ||
parent::__construct($msg, $code, $causeException); | ||
$this->instanceName = $instanceName; | ||
} | ||
|
||
/** | ||
* Returns the name of the instance that was not found. | ||
* | ||
* @return string | ||
*/ | ||
public function getMissingInstanceName() { | ||
return $this->instanceName; | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
/* | ||
* This file is part of the Mouf core package. | ||
* | ||
* (c) 2012 David Negrier <david@mouf-php.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Mouf; | ||
|
||
/** | ||
* Mouf Container Exceptions are thrown by the Mouf framework if something goes wrong in the container. | ||
* | ||
*/ | ||
class MoufContainerException extends MoufException { | ||
|
||
} |
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