3.2 Access function in event-class from acp-module

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
cangor
Registered User
Posts: 86
Joined: Thu Oct 28, 2010 1:56 pm

3.2 Access function in event-class from acp-module

Post by cangor »

Hello,

I have an extension with a class in /event/ which contains all the important functions of my extension. Then I implemented an acp-module, which worked fine so far. Now I need to access a function inside my event-class from the acp-module.

Whats the recommended way to get the instance of the event-class inside the acp-modul-cass?
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: 3.2 Access function in event-class from acp-module

Post by mrgoldy »

Usually the "listener" is in the /event/ directory and not your functions used through out your extension.
However, have a look at the Board Rules ACP Module, Line 30. You can use the phpbb_container to get a service, which is declared within your services.yml.
Or if you're working with an admin controller yourself, which is declared in your services.yml, you can add the functions file through a dependency.
You can read more about that in the 3.2.x Extension Docs.
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
cangor
Registered User
Posts: 86
Joined: Thu Oct 28, 2010 1:56 pm

Re: 3.2 Access function in event-class from acp-module

Post by cangor »

Thank you! Using phpbb_container works.

But would you suggest putting all important functions into ext.php?
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 28619
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: 3.2 Access function in event-class from acp-module

Post by Paul »

cangor wrote: Tue Nov 21, 2017 1:37 pm But would you suggest putting all important functions into ext.php?
No.
Post Reply

Return to “Extension Writers Discussion”