1212use OCP \AppFramework \QueryException ;
1313use OCP \EventDispatcher \Event ;
1414use OCP \EventDispatcher \IEventListener ;
15- use OCP \ IServerContainer ;
15+ use Psr \ Container \ ContainerInterface ;
1616use Psr \Log \LoggerInterface ;
1717use function sprintf ;
1818
2323 * created by the service container
2424 */
2525final class ServiceEventListener {
26- /** @var IServerContainer */
27- private $ container ;
26+ private ?IEventListener $ service = null ;
2827
29- /** @var string */
30- private $ class ;
31-
32- /** @var LoggerInterface */
33- private $ logger ;
34-
35- /** @var null|IEventListener */
36- private $ service ;
37-
38- public function __construct (IServerContainer $ container ,
39- string $ class ,
40- LoggerInterface $ logger ) {
41- $ this ->container = $ container ;
42- $ this ->class = $ class ;
43- $ this ->logger = $ logger ;
28+ public function __construct (
29+ private ContainerInterface $ container ,
30+ private string $ class ,
31+ private LoggerInterface $ logger ,
32+ ) {
4433 }
4534
4635 public function __invoke (Event $ event ) {
@@ -49,7 +38,7 @@ public function __invoke(Event $event) {
4938 // TODO: fetch from the app containers, otherwise any custom services,
5039 // parameters and aliases won't be resolved.
5140 // See https://github.com/nextcloud/server/issues/27793 for details.
52- $ this ->service = $ this ->container ->query ($ this ->class );
41+ $ this ->service = $ this ->container ->get ($ this ->class );
5342 } catch (QueryException $ e ) {
5443 $ this ->logger ->error (
5544 sprintf (
0 commit comments