[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/system/webauthn/src/PluginTraits/ -> EventReturnAware.php (source)

   1  <?php
   2  
   3  /**
   4   * @package         Joomla.Plugin
   5   * @subpackage      System.Webauthn
   6   *
   7   * @copyright   (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license         GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Plugin\System\Webauthn\PluginTraits;
  12  
  13  use Joomla\Event\Event;
  14  
  15  // phpcs:disable PSR1.Files.SideEffects
  16  \defined('_JEXEC') or die;
  17  // phpcs:enable PSR1.Files.SideEffects
  18  
  19  /**
  20   * Utility trait to facilitate returning data from event handlers.
  21   *
  22   * @since 4.2.0
  23   */
  24  trait EventReturnAware
  25  {
  26      /**
  27       * Adds a result value to an event
  28       *
  29       * @param   Event   $event  The event we were processing
  30       * @param   mixed   $value  The value to append to the event's results
  31       *
  32       * @return  void
  33       * @since   4.2.0
  34       */
  35      private function returnFromEvent(Event $event, $value = null): void
  36      {
  37          $result = $event->getArgument('result') ?: [];
  38  
  39          if (!is_array($result)) {
  40              $result = [$result];
  41          }
  42  
  43          $result[] = $value;
  44  
  45          $event->setArgument('result', $result);
  46      }
  47  }


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