Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Passback To DIC #14342

Merged
merged 2 commits into from
Sep 12, 2019
Merged

Adding Passback To DIC #14342

merged 2 commits into from
Sep 12, 2019

Conversation

Fenikkusu
Copy link
Contributor

@Fenikkusu Fenikkusu commented Aug 29, 2019

Hello!

  • Type: new feature

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR
  • I have updated the relevant CHANGELOG
  • I have created a PR for the documentation about this change

Small description of change:

I often find myself having to do the following:

use Phalcon\Di;
use Other;
use Another;

$di = new Di();

$di->set('name', function () {
   return $this->get(Other::class);
});

if (true) {
     $di->set(Other::class, Another::class);
}

This PR eliminates the extra steps by letting the service class instantiate through the DIC. I can now right the code as:

use Phalcon\Di;
use Other;
use Another;

$di = new Di();

$di->set('name', Other::class);
if (true) {
     $di->set(Other::class, Another::class);
}

Thanks

@codecov
Copy link

codecov bot commented Aug 29, 2019

Codecov Report

Merging #14342 into 4.0.x will decrease coverage by <.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##            4.0.x   #14342      +/-   ##
==========================================
- Coverage   67.78%   67.77%   -0.01%     
==========================================
  Files         478      478              
  Lines      112924   112927       +3     
==========================================
- Hits        76549    76541       -8     
- Misses      36375    36386      +11

@sergeyklay
Copy link
Contributor

Related to #13042

@sergeyklay sergeyklay added 4.1 new feature request Planned Feature or New Feature Request discussion Request for comments and discussion labels Aug 29, 2019
@sergeyklay
Copy link
Contributor

/cc @phalcon/framework-team

niden
niden previously approved these changes Sep 7, 2019
@niden
Copy link
Member

niden commented Sep 7, 2019

@Fenikkusu could you please add an entry in the CHANGELOG-4.0 please?

@niden
Copy link
Member

niden commented Sep 7, 2019

and rebase

@niden niden added 4.0 and removed 4.1 labels Sep 7, 2019
@Fenikkusu
Copy link
Contributor Author

Done

sergeyklay
sergeyklay previously approved these changes Sep 9, 2019
ruudboon
ruudboon previously approved these changes Sep 9, 2019
Jeckerson
Jeckerson previously approved these changes Sep 9, 2019
@Fenikkusu Fenikkusu dismissed stale reviews from Jeckerson, ruudboon, and sergeyklay via 0e1b3e8 September 11, 2019 00:42
@niden niden merged commit 0e1b3e8 into phalcon:4.0.x Sep 12, 2019
@niden
Copy link
Member

niden commented Sep 12, 2019

@Fenikkusu Thank you!

@niden niden added documentation Documentation required and removed discussion Request for comments and discussion labels Sep 12, 2019
@Fenikkusu Fenikkusu deleted the 4.0.x-di-alias branch September 12, 2019 23:27
@niden niden removed the documentation Documentation required label Dec 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature request Planned Feature or New Feature Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants