Skip to content

Commit

Permalink
Adding Passback To DIC, Updating Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fenikkusu committed Sep 8, 2019
1 parent a8dba95 commit 772a002
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-4.0.md
Expand Up @@ -8,6 +8,7 @@
- Changed `Phalcon\Flash\Direct` to allow `escaper` in the constructor [#14349](https://github.com/phalcon/cphalcon/issues/14349)
- Changed `Phalcon\Flash\Session` to allow `escaper` in the constructor [#14349](https://github.com/phalcon/cphalcon/issues/14349)
- Changed `Phalcon\Di\AbstractDIAware` to `Phalcon\Di\AbstractInjectionAware` [#14359](https://github.com/phalcon/cphalcon/issues/14359)
- Changed `Phalcon\Di\Service` to use DI to initialize `string` based services when possible [#14342](https://github.com/phalcon/cphalcon/pull/14342)

## Fixed
- Fixed `Phalcon\Helper\Str::includes` to return correct result [#14301](https://github.com/phalcon/cphalcon/issues/14301)
Expand Down
5 changes: 3 additions & 2 deletions phalcon/Di/Service.zep
Expand Up @@ -134,11 +134,12 @@ class Service implements ServiceInterface

let definition = this->definition;
if typeof definition == "string" {

/**
* String definitions can be class names without implicit parameters
*/
if class_exists(definition) {
if container !== null {
let instance = container->get(definition, parameters);
} elseif class_exists(definition) {
if typeof parameters == "array" && count(parameters) {
let instance = create_instance_params(
definition,
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/Di/ServiceCest.php
Expand Up @@ -61,4 +61,23 @@ function () {
$di->getService('notResolved')->isResolved()
);
}

public function testAlias(UnitTester $I)
{
$escaper = new Escaper();

$di = new Di();

$di->set(
'resolved',
Escaper::class
);

$di->set(Escaper::class, $escaper);

$I->assertSame(
$escaper,
$di->get('resolved')
);
}
}

0 comments on commit 772a002

Please sign in to comment.