aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2021-07-05 08:30:56 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-07-05 12:11:54 +0200
commita6a31bb419f5adda5f38b5ab5e93791e061ebbdc (patch)
tree5bb5268900e6fc58c77689fdbb9c41bb5e4cade8 /lib
parentbb22d38aa10e58de0103aa57ecbdf60b167c59bb (diff)
downloadnextcloud-server-a6a31bb419f5adda5f38b5ab5e93791e061ebbdc.tar.gz
nextcloud-server-a6a31bb419f5adda5f38b5ab5e93791e061ebbdc.zip
Clarify that lazy event listeners are built from the server container
Ref https://github.com/nextcloud/server/issues/27793 Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/EventDispatcher/ServiceEventListener.php24
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/private/EventDispatcher/ServiceEventListener.php b/lib/private/EventDispatcher/ServiceEventListener.php
index 045d7391ac1..a7e15f1df1b 100644
--- a/lib/private/EventDispatcher/ServiceEventListener.php
+++ b/lib/private/EventDispatcher/ServiceEventListener.php
@@ -24,13 +24,15 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
namespace OC\EventDispatcher;
use OCP\AppFramework\QueryException;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
-use OCP\IContainer;
+use OCP\IServerContainer;
use Psr\Log\LoggerInterface;
+use function sprintf;
/**
* Lazy service event listener
@@ -40,7 +42,7 @@ use Psr\Log\LoggerInterface;
*/
final class ServiceEventListener {
- /** @var IContainer */
+ /** @var IServerContainer */
private $container;
/** @var string */
@@ -52,7 +54,7 @@ final class ServiceEventListener {
/** @var null|IEventListener */
private $service;
- public function __construct(IContainer $container,
+ public function __construct(IServerContainer $container,
string $class,
LoggerInterface $logger) {
$this->container = $container;
@@ -63,11 +65,21 @@ final class ServiceEventListener {
public function __invoke(Event $event) {
if ($this->service === null) {
try {
+ // TODO: fetch from the app containers, otherwise any custom services,
+ // parameters and aliases won't be resolved.
+ // See https://github.com/nextcloud/server/issues/27793 for details.
$this->service = $this->container->query($this->class);
} catch (QueryException $e) {
- $this->logger->error("Could not load event listener service " . $this->class, [
- 'exception' => $e,
- ]);
+ $this->logger->error(
+ sprintf(
+ 'Could not load event listener service %s: %s. Make sure the class is auto-loadable by the Nextcloud server container',
+ $this->class,
+ $e->getMessage()
+ ),
+ [
+ 'exception' => $e,
+ ]
+ );
return;
}
}