Missing dependency

Discussion forum for Extension Writers regarding Extension Development.
User avatar
cYbercOsmOnauT
Registered User
Posts: 362
Joined: Wed Jun 16, 2004 8:22 am
Location: Goettingen, Germany
Name: Tekin Birdüzen

Missing dependency

Post by cYbercOsmOnauT »

$php_container should be provided as dependency for extensions. For example if you want to write something into the log you have to use globals inside the __construct.

Code: Select all

$this->phpbb_log = $GLOBALS['phpbb_container']->get('log'); 
phpBB-installation and reparation. Prof. PHP coding with function guarantee. Just contact me at: t.birduezen@web-coding.eu.
Ex-German Support Team Member | phpBB Development Environment
rxu
Extensions Development Team
Posts: 3458
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Missing dependency

Post by rxu »

You should just add the log dependency in that case.
User avatar
cYbercOsmOnauT
Registered User
Posts: 362
Joined: Wed Jun 16, 2004 8:22 am
Location: Goettingen, Germany
Name: Tekin Birdüzen

Re: Missing dependency

Post by cYbercOsmOnauT »

Well said

https://wiki.phpbb.com/Dependency_list

there is nothing like a log dependency in the list... please now don't come and tell me that this exists and I had to look inside the phpBB sourcecode. ;)
phpBB-installation and reparation. Prof. PHP coding with function guarantee. Just contact me at: t.birduezen@web-coding.eu.
Ex-German Support Team Member | phpBB Development Environment
User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 5487
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: Missing dependency

Post by Marc »

That dependency list is far from being complete. The main set of service can be found in services.yml:
https://github.com/phpbb/phpbb/blob/3.1 ... rvices.yml
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 27130
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Missing dependency

Post by Paul »

cYbercOsmOnauT wrote:Well said

https://wiki.phpbb.com/Dependency_list

there is nothing like a log dependency in the list... please now don't come and tell me that this exists and I had to look inside the phpBB sourcecode. ;)
If it didn't exists you wouldn't be able to ask it from the container :).
User avatar
cYbercOsmOnauT
Registered User
Posts: 362
Joined: Wed Jun 16, 2004 8:22 am
Location: Goettingen, Germany
Name: Tekin Birdüzen

Re: Missing dependency

Post by cYbercOsmOnauT »

I am injecting the container into my event listener by using $GLOBALS. But this is not the secure way of getting a core method of phpBB into my script. This dependencies are there to make sure to get the objects one need in his event listener with the plus of type check like \phpbb\config\config $config.

When I use $GLOBALS (or global) I don't have this extra security. I have to believe that the object is what I really wanted. Even if you say The passing of dependencies in this way replaces the need of using global $var; in most cases. in your Wiki I believe that such core stuff should be available as dependency.

btw, the "Full Editor & Preview" button in your QuickReply here does not really work. I clicked it unintentionally twice and lost my whole posting because all I got was an empty full editor. ;)
phpBB-installation and reparation. Prof. PHP coding with function guarantee. Just contact me at: t.birduezen@web-coding.eu.
Ex-German Support Team Member | phpBB Development Environment
User avatar
RMcGirr83
Former Team Member
Posts: 21848
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: Missing dependency

Post by RMcGirr83 »

Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
User avatar
cYbercOsmOnauT
Registered User
Posts: 362
Joined: Wed Jun 16, 2004 8:22 am
Location: Goettingen, Germany
Name: Tekin Birdüzen

Re: Missing dependency

Post by cYbercOsmOnauT »

Thanks RMcGirr83... but tell me one thing.. how can someone who does not sleep with the phpBB source know that there is such a dependency existing when it's not found in the wiki? :)

Anyways.. I will change my code and use the container the way you showed.
phpBB-installation and reparation. Prof. PHP coding with function guarantee. Just contact me at: t.birduezen@web-coding.eu.
Ex-German Support Team Member | phpBB Development Environment
User avatar
RMcGirr83
Former Team Member
Posts: 21848
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: Missing dependency

Post by RMcGirr83 »

cYbercOsmOnauT wrote:Thanks RMcGirr83... but tell me one thing.. how can someone who does not sleep with the phpBB source know that there is such a dependency existing when it's not found in the wiki? :)
By staying up until the wee hours of the night looking at code...like I did. I guess.
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
User avatar
cYbercOsmOnauT
Registered User
Posts: 362
Joined: Wed Jun 16, 2004 8:22 am
Location: Goettingen, Germany
Name: Tekin Birdüzen

Re: Missing dependency

Post by cYbercOsmOnauT »

I guess you have no family to feed. ;) I have work to be done and code to be finished with less time to look inside a sourcecode of big project for hours. Documentation is eminent for bigger project.

Is there a place somewhere in the phpBB code where all these dependencies are set and we can see what is provided? Sorry but I am also no Symphony pro.
phpBB-installation and reparation. Prof. PHP coding with function guarantee. Just contact me at: t.birduezen@web-coding.eu.
Ex-German Support Team Member | phpBB Development Environment
nicofuma
3.2 Release Manager
3.2 Release Manager
Posts: 546
Joined: Sun Apr 13, 2014 1:47 am
Location: Grenoble - France

Re: Missing dependency

Post by nicofuma »

You can look at the files in the config directory or use my Debug Tools extension viewtopic.php?f=456&t=2253386
Member of phpBB Development-Team
No Support via PM
User avatar
cYbercOsmOnauT
Registered User
Posts: 362
Joined: Wed Jun 16, 2004 8:22 am
Location: Goettingen, Germany
Name: Tekin Birdüzen

Re: Missing dependency

Post by cYbercOsmOnauT »

Thanks for the hint nicofuma.

RMcGirr83: I did it the way you linked me. But now when I go to the configpage of my captcha extension I get to see
Catchable fatal error: Argument 7 passed to cosmo\peoplesign\captcha\peoplesign::__construct() must be an instance of \ContainerInterface, instance of phpbb_cache_container given, called in /var/www/dev/board/cache/container_dotslashdotdotslash.php on line 990

So back to globals I guess ;)

Edit... now I see.. you forgot to mention that you injected the dependency on your own
use Symfony\Component\DependencyInjection\ContainerInterface;

Edit 2: After playing around I found the following solution.
https://github.com/cYbercOsmOnauT/phpbb ... es.yml#L13
https://github.com/cYbercOsmOnauT/phpbb ... gn.php#L80
https://github.com/cYbercOsmOnauT/phpbb ... gn.php#L99
https://github.com/cYbercOsmOnauT/phpbb ... n.php#L308
phpBB-installation and reparation. Prof. PHP coding with function guarantee. Just contact me at: t.birduezen@web-coding.eu.
Ex-German Support Team Member | phpBB Development Environment
rxu
Extensions Development Team
Posts: 3458
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Missing dependency

Post by rxu »

"Edit 2" is the correct approach ;)
User avatar
cYbercOsmOnauT
Registered User
Posts: 362
Joined: Wed Jun 16, 2004 8:22 am
Location: Goettingen, Germany
Name: Tekin Birdüzen

Re: Missing dependency

Post by cYbercOsmOnauT »

but nowhere documented ;)
phpBB-installation and reparation. Prof. PHP coding with function guarantee. Just contact me at: t.birduezen@web-coding.eu.
Ex-German Support Team Member | phpBB Development Environment
Post Reply

Return to “Extension Writers Discussion”