-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Conversation
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_Di |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove @Package
@noopable I've marked this a "work in progress" as it's clear you've written tests, but are still working on solutions. |
Thanks. I'll be counting on you. |
@noopable Oh, I thought you were doing the work. :) |
@weierophinney |
Be aware of BC break for an enhancement of di capability
I wrote the first implementation. |
@noopable Looks great! If you're ready to sign off on it -- i.e., it solves the issues you were seeing with forms -- I can get this into 2.2.0RC3. |
@weierophinney |
@noopable Interestingly, I cannot revert either of those two commits, as doing so introduces new failures and/or errors. If I revert 9afbe6f, I get new failures in the If I revert 69dc3de, I get errors in the same test suite, in the Can you try reverting these on your branch and figuring out what changes need to be made to make them pass? |
I'm sorry. |
@noopable revert & new commit is good -- it's explicit. BTW, just pulled, and seeing 3 new failures on DiTest: |
@noopable I have a working solution: diff --git a/library/Zend/Di/Di.php b/library/Zend/Di/Di.php
index f70a457..a1fc612 100644
--- a/library/Zend/Di/Di.php
+++ b/library/Zend/Di/Di.php
@@ -12,6 +12,7 @@ namespace Zend\Di;
use Closure;
use ReflectionClass;
use Zend\Di\Exception;
+use Zend\ServiceManager\Exception\ExceptionInterface as ServiceManagerException;
/**
* Dependency injector that can generate instances using class definitions and configured instance parameters
@@ -757,9 +758,25 @@ class Di implements DependencyInjectionInterface
} else {
$resolvedParams[$index] = $this->get($computedParams['retrieval'][$fqParamPos][0], $callTimeUserParams);
}
- } catch (\Exception $e) {
+ } catch (Exception\RuntimeException $e) {
+ if ($methodRequirementType & self::RESOLVE_STRICT) {
+ //finally ( be aware to do at the end of flow)
+ array_pop($this->currentDependencies);
+ // if this item was marked strict,
+ // plus it cannot be resolve, and no value exist, bail out
+ throw new Exception\MissingPropertyException(sprintf(
+ 'Missing %s for parameter ' . $name . ' for ' . $class . '::' . $method,
+ (($value[0] === null) ? 'value' : 'instance/object' )
+ ),
+ $e->getCode(),
+ $e);
+ } else {
+ //finally ( be aware to do at the end of flow)
+ array_pop($this->currentDependencies);
+ return false;
+ }
+ } catch (ServiceManagerException $e) {
//Zend\ServiceManager\Exception\ServiceNotCreatedException
- //Zend\Di\Exception\RuntimeException
if ($methodRequirementType & self::RESOLVE_STRICT) {
//finally ( be aware to do at the end of flow)
array_pop($this->currentDependencies); |
@noopable The solution posted above works, and does not present a hard dependency on ServiceManager. |
@noopable Looks good! Preparing to merge now! |
@weierophinney |
[WIP] Di compatibility (#4434)
- order of use statements - ensure line between use statements and class docblock
@noopable No worries -- great work! |
Thank you! |
…ue/4434 [WIP] Di compatibility (zendframework/zendframework#4434)
- order of use statements - ensure line between use statements and class docblock
Relative to #4434
Now we cannot get some instances from the di even if the zf2's simple classes. This PR is a hotfix for it.
And this also enhances the capability to manage dependencies explicitly. But it has a minor BC break. If we should keep BC strictly, remove a5f1362 , b0d918e
Overview
METHOD_IS_REQUIRED:
METHOD_IS_EAGER:
METHOD_IS_OPTIONAL: