__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Application;
use Joomla\CMS\Event\CoreEventAware;
use Joomla\Event\DispatcherInterface;
use Joomla\Event\Event;
use Psr\Log\LoggerInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Trait for application classes which dispatch events
*
* @since 4.0.0
*/
trait EventAware
{
use CoreEventAware;
/**
* Get the event dispatcher.
*
* @return DispatcherInterface
*
* @since 4.0.0
* @throws \UnexpectedValueException May be thrown if the dispatcher has not been set.
*/
abstract public function getDispatcher();
/**
* Get the logger.
*
* @return LoggerInterface
*
* @since 4.0.0
*/
abstract public function getLogger();
/**
* Registers a handler to a particular event group.
*
* @param string $event The event name.
* @param callable $handler The handler, a function or an instance of an event object.
*
* @return $this
*
* @since 4.0.0
*/
public function registerEvent($event, callable $handler)
{
try {
$this->getDispatcher()->addListener($event, $handler);
} catch (\UnexpectedValueException $e) {
// No dispatcher is registered, don't throw an error (mimics old behavior)
}
return $this;
}
/**
* Calls all handlers associated with an event group.
*
* This is a legacy method, implementing old-style (Joomla! 3.x) plugin calls. It's best to go directly through the
* Dispatcher and handle the returned EventInterface object instead of going through this method. This method is
* deprecated and will be removed in Joomla! 5.x.
*
* This method will only return the 'result' argument of the event
*
* @param string $eventName The event name.
* @param array|Event $args An array of arguments or an Event object (optional).
*
* @return array An array of results from each function call. Note this will be an empty array if no dispatcher is set.
*
* @since 4.0.0
* @throws \InvalidArgumentException
*
* @deprecated 4.0 will be removed in 6.0
* Use the Dispatcher method instead
* Example: Factory::getApplication()->getDispatcher()->dispatch($eventName, $event);
*
*/
public function triggerEvent($eventName, $args = [])
{
try {
$dispatcher = $this->getDispatcher();
} catch (\UnexpectedValueException $exception) {
$this->getLogger()->error(\sprintf('Dispatcher not set in %s, cannot trigger events.', \get_class($this)));
return [];
}
if ($args instanceof Event) {
$event = $args;
} elseif (\is_array($args)) {
$className = self::getEventClassByEventName($eventName);
$event = new $className($eventName, $args);
} else {
throw new \InvalidArgumentException('The arguments must either be an event or an array');
}
$result = $dispatcher->dispatch($eventName, $event);
// @todo - There are still test cases where the result isn't defined, temporarily leave the isset check in place
return !isset($result['result']) || \is_null($result['result']) ? [] : $result['result'];
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| CLI | Folder | 0775 |
|
|
| Exception | Folder | 0775 |
|
|
| AdministratorApplication.php | File | 17.52 KB | 0664 |
|
| ApiApplication.php | File | 14.25 KB | 0664 |
|
| ApplicationHelper.php | File | 5.56 KB | 0664 |
|
| BaseApplication.php | File | 1.88 KB | 0664 |
|
| CMSApplication.php | File | 43.66 KB | 0664 |
|
| CMSApplicationInterface.php | File | 4.44 KB | 0664 |
|
| CMSWebApplicationInterface.php | File | 3.12 KB | 0664 |
|
| CliApplication.php | File | 11.53 KB | 0664 |
|
| ConsoleApplication.php | File | 18.58 KB | 0664 |
|
| DaemonApplication.php | File | 28.88 KB | 0664 |
|
| EventAware.php | File | 3.57 KB | 0664 |
|
| EventAwareInterface.php | File | 2.12 KB | 0664 |
|
| ExtensionNamespaceMapper.php | File | 892 B | 0664 |
|
| IdentityAware.php | File | 1.29 KB | 0664 |
|
| MultiFactorAuthenticationHandler.php | File | 19.89 KB | 0664 |
|
| SiteApplication.php | File | 29.58 KB | 0664 |
|
| WebApplication.php | File | 15.66 KB | 0664 |
|