[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Event/ -> CoreEventAware.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license        GNU General Public License version 2 or later; see LICENSE
   8   */
   9  
  10  namespace Joomla\CMS\Event;
  11  
  12  use Joomla\CMS\Event\Model\BeforeBatchEvent;
  13  use Joomla\CMS\Event\Plugin\System\Webauthn\Ajax as PlgSystemWebauthnAjax;
  14  use Joomla\CMS\Event\Plugin\System\Webauthn\AjaxChallenge as PlgSystemWebauthnAjaxChallenge;
  15  use Joomla\CMS\Event\Plugin\System\Webauthn\AjaxCreate as PlgSystemWebauthnAjaxCreate;
  16  use Joomla\CMS\Event\Plugin\System\Webauthn\AjaxDelete as PlgSystemWebauthnAjaxDelete;
  17  use Joomla\CMS\Event\Plugin\System\Webauthn\AjaxInitCreate as PlgSystemWebauthnAjaxInitCreate;
  18  use Joomla\CMS\Event\Plugin\System\Webauthn\AjaxLogin as PlgSystemWebauthnAjaxLogin;
  19  use Joomla\CMS\Event\Plugin\System\Webauthn\AjaxSaveLabel as PlgSystemWebauthnAjaxSaveLabel;
  20  use Joomla\CMS\Event\QuickIcon\GetIconEvent;
  21  use Joomla\CMS\Event\Table\AfterBindEvent;
  22  use Joomla\CMS\Event\Table\AfterCheckinEvent;
  23  use Joomla\CMS\Event\Table\AfterCheckoutEvent;
  24  use Joomla\CMS\Event\Table\AfterDeleteEvent;
  25  use Joomla\CMS\Event\Table\AfterHitEvent;
  26  use Joomla\CMS\Event\Table\AfterLoadEvent;
  27  use Joomla\CMS\Event\Table\AfterMoveEvent;
  28  use Joomla\CMS\Event\Table\AfterPublishEvent;
  29  use Joomla\CMS\Event\Table\AfterReorderEvent;
  30  use Joomla\CMS\Event\Table\AfterResetEvent;
  31  use Joomla\CMS\Event\Table\AfterStoreEvent;
  32  use Joomla\CMS\Event\Table\BeforeBindEvent;
  33  use Joomla\CMS\Event\Table\BeforeCheckinEvent;
  34  use Joomla\CMS\Event\Table\BeforeCheckoutEvent;
  35  use Joomla\CMS\Event\Table\BeforeDeleteEvent;
  36  use Joomla\CMS\Event\Table\BeforeHitEvent;
  37  use Joomla\CMS\Event\Table\BeforeLoadEvent;
  38  use Joomla\CMS\Event\Table\BeforeMoveEvent;
  39  use Joomla\CMS\Event\Table\BeforePublishEvent;
  40  use Joomla\CMS\Event\Table\BeforeReorderEvent;
  41  use Joomla\CMS\Event\Table\BeforeResetEvent;
  42  use Joomla\CMS\Event\Table\BeforeStoreEvent;
  43  use Joomla\CMS\Event\Table\CheckEvent;
  44  use Joomla\CMS\Event\Table\ObjectCreateEvent;
  45  use Joomla\CMS\Event\Table\SetNewTagsEvent;
  46  use Joomla\CMS\Event\View\DisplayEvent;
  47  use Joomla\CMS\Event\WebAsset\WebAssetRegistryAssetChanged;
  48  use Joomla\CMS\Event\Workflow\WorkflowFunctionalityUsedEvent;
  49  use Joomla\CMS\Event\Workflow\WorkflowTransitionEvent;
  50  use Joomla\Event\Event;
  51  
  52  // phpcs:disable PSR1.Files.SideEffects
  53  \defined('JPATH_PLATFORM') or die;
  54  // phpcs:enable PSR1.Files.SideEffects
  55  
  56  /**
  57   * Returns the most suitable event class for a Joomla core event name
  58   *
  59   * @since 4.2.0
  60   */
  61  trait CoreEventAware
  62  {
  63      /**
  64       * Maps event names to concrete Event classes.
  65       *
  66       * This is only for events with invariable names. Events with variable names are handled with
  67       * PHP logic in the getEventClassByEventName class.
  68       *
  69       * @var   array
  70       * @since 4.2.0
  71       */
  72      private static $eventNameToConcreteClass = [
  73          // Model
  74          'onBeforeBatch'               => BeforeBatchEvent::class,
  75          // Quickicon
  76          'onGetIcon'                   => GetIconEvent::class,
  77          // Table
  78          'onTableAfterBind'            => AfterBindEvent::class,
  79          'onTableAfterCheckin'         => AfterCheckinEvent::class,
  80          'onTableAfterCheckout'        => AfterCheckoutEvent::class,
  81          'onTableAfterDelete'          => AfterDeleteEvent::class,
  82          'onTableAfterHit'             => AfterHitEvent::class,
  83          'onTableAfterLoad'            => AfterLoadEvent::class,
  84          'onTableAfterMove'            => AfterMoveEvent::class,
  85          'onTableAfterPublish'         => AfterPublishEvent::class,
  86          'onTableAfterReorder'         => AfterReorderEvent::class,
  87          'onTableAfterReset'           => AfterResetEvent::class,
  88          'onTableAfterStore'           => AfterStoreEvent::class,
  89          'onTableBeforeBind'           => BeforeBindEvent::class,
  90          'onTableBeforeCheckin'        => BeforeCheckinEvent::class,
  91          'onTableBeforeCheckout'       => BeforeCheckoutEvent::class,
  92          'onTableBeforeDelete'         => BeforeDeleteEvent::class,
  93          'onTableBeforeHit'            => BeforeHitEvent::class,
  94          'onTableBeforeLoad'           => BeforeLoadEvent::class,
  95          'onTableBeforeMove'           => BeforeMoveEvent::class,
  96          'onTableBeforePublish'        => BeforePublishEvent::class,
  97          'onTableBeforeReorder'        => BeforeReorderEvent::class,
  98          'onTableBeforeReset'          => BeforeResetEvent::class,
  99          'onTableBeforeStore'          => BeforeStoreEvent::class,
 100          'onTableCheck'                => CheckEvent::class,
 101          'onTableObjectCreate'         => ObjectCreateEvent::class,
 102          'onTableSetNewTags'           => SetNewTagsEvent::class,
 103          // View
 104          'onBeforeDisplay'             => DisplayEvent::class,
 105          'onAfterDisplay'              => DisplayEvent::class,
 106          // Workflow
 107          'onWorkflowFunctionalityUsed' => WorkflowFunctionalityUsedEvent::class,
 108          'onWorkflowAfterTransition'   => WorkflowTransitionEvent::class,
 109          'onWorkflowBeforeTransition'  => WorkflowTransitionEvent::class,
 110          // Plugin: System, WebAuthn
 111          'onAjaxWebauthn'              => PlgSystemWebauthnAjax::class,
 112          'onAjaxWebauthnChallenge'     => PlgSystemWebauthnAjaxChallenge::class,
 113          'onAjaxWebauthnCreate'        => PlgSystemWebauthnAjaxCreate::class,
 114          'onAjaxWebauthnDelete'        => PlgSystemWebauthnAjaxDelete::class,
 115          'onAjaxWebauthnInitcreate'    => PlgSystemWebauthnAjaxInitCreate::class,
 116          'onAjaxWebauthnLogin'         => PlgSystemWebauthnAjaxLogin::class,
 117          'onAjaxWebauthnSavelabel'     => PlgSystemWebauthnAjaxSaveLabel::class,
 118      ];
 119  
 120      /**
 121       * Get the concrete event class name for the given event name.
 122       *
 123       * This method falls back to the generic Joomla\Event\Event class if the event name is unknown
 124       * to this trait.
 125       *
 126       * @param   string  $eventName  The event name
 127       *
 128       * @return  string The event class name
 129       * @since 4.2.0
 130       */
 131      protected static function getEventClassByEventName(string $eventName): string
 132      {
 133          if (strpos($eventName, 'onWebAssetRegistryChangedAsset') === 0) {
 134              return WebAssetRegistryAssetChanged::class;
 135          }
 136  
 137          return self::$eventNameToConcreteClass[$eventName] ?? Event::class;
 138      }
 139  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer