setDatabase($database); } /** * Returns an array of CMS events this plugin will listen to and the respective handlers. * * @return array * * @since __DEPLOY_VERSION__ */ public static function getSubscribedEvents(): array { return [ 'onGetStats' => 'onGetStats', ]; } /** * Method to add statistics information to Administrator control panel. * * @param string $extension The extension requesting information. * * @return void * * @since __DEPLOY_VERSION__ */ public function onGetStats(Event $event) { if (!ComponentHelper::isEnabled('com_weblinks')) { return; } [$extension] = $event->getArguments(); if (!in_array($extension, $this->supportedExtensions)) { return; } $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('COUNT(id) AS count_links') ->from('#__weblinks') ->where('state = 1'); $webLinks = $db->setQuery($query)->loadResult(); if (!$webLinks) { return; } $result = $event->getArgument('result', []); $result[] = [ [ 'title' => Text::_('PLG_SYSTEM_WEBLINKS_STATISTICS'), 'icon' => 'out-2', 'data' => $webLinks, ], ]; $event->setArgument('result', $result); } }