3Di wrote: ↑Mon Feb 05, 2018 11:40 pm
posey wrote: ↑Sun Feb 04, 2018 2:02 pm
you'll have to make sure you use the
use
statement I posted above, otherwise it will throw errors, saying you're injecting a wrong instance.
I believe the right injection in the construct would be
public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container)
shouldn't throw any error, no need to
use
.. not tested though.
Yes!! this is how i like. Thanks.
& for this , what should be my
services.yml
?
PS: This is what I was searching for , in Doc's....
&&&&&
Paul wrote: ↑Tue Feb 06, 2018 8:33 am
You really should not inject the container itself in a listener, but inject the specific dependencies instead.
Thanks
, But What if ,
I have 8 to 14
specific dependencies
in my Event listener to be Injected ,
Instead I use
phpbb_container
for all other's , Kind of
One dependence to Rule e'm All
[LOR reff]
which reduces the
construct
parameter's size , helps to keep it clean.
like ,
Code: Select all
public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $phpbb_container)
{
$this->auth = $phpbb_container->get('auth');
$this->config = $phpbb_container->get('config');
$this->config_text = $phpbb_container->get('config_text');
$this->language = $phpbb_container->get('language');
$this->phpbb_log = $phpbb_container->get('log');
$this->request = $phpbb_container->get('request');
$this->template = $phpbb_container->get('template');
$this->user = $phpbb_container->get('user');
}
Now ,
1. Does it harm the performance?
2. Does it Break anything?
3. Does it cause compatibility Issue?
4. Why should not it be used?
5. Is it against the phpBB code Style or ethics?
----------------------------------------------------------
Waiting for your reply , from Both.
Thanking you , Best regards.