CoreFiles by mySites.guru
EventReturnAware.php43 lines, 992 bytes, from Joomla_4.2.0-Stable-Full_Package.zip
Raw History Compare with 4.1.5
md5
eea49ae5fddffd91bfac5212d5927b25
sha1
05eb5f7d01425f6f14db94e0cf0be26de35ba7a9
sha256
08da854efb2b2478b83ccfc5872b3e5c620e3a203faec847d4c36489aa4e2199
<?php

/**
 * @package         Joomla.Plugin
 * @subpackage      System.Webauthn
 *
 * @copyright   (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
 * @license         GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Plugin\System\Webauthn\PluginTraits;

use Joomla\Event\Event;

/**
 * Utility trait to facilitate returning data from event handlers.
 *
 * @since 4.2.0
 */
trait EventReturnAware
{
    /**
     * Adds a result value to an event
     *
     * @param   Event   $event  The event we were processing
     * @param   mixed   $value  The value to append to the event's results
     *
     * @return  void
     * @since   4.2.0
     */
    private function returnFromEvent(Event $event, $value = null): void
    {
        $result = $event->getArgument('result') ?: [];

        if (!is_array($result)) {
            $result = [$result];
        }

        $result[] = $value;

        $event->setArgument('result', $result);
    }
}

The same content is in 5 releases, Joomla 4.2.0-beta3 to 4.2.1-rc2. See them all, or every version of this file.