CoreFiles by mySites.guru
JsonapiView.php59 lines, 1,538 bytes, from Joomla_6.2.0-rc2-Release_Candidate-Full_Package.zip
Raw History Compare with 6.2.0-rc1
md5
068f3960caf57de1b4253de1de8023e7
sha1
5a12672c074c5df2f9f1bc68597f5ffdf3633e54
sha256
9eb52e297a4da3046a994137d4dce65405ecfd8f1d0e916bab4f6b5ef26670d6
<?php

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

namespace Joomla\Component\Joomlaupdate\Api\View\Notification;

use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Joomlaupdate\Administrator\Model\UpdateModel;
use Tobscure\JsonApi\Resource;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * The notification view
 *
 * @since  5.4.0
 */
class JsonapiView extends BaseApiView
{
    /**
     * Sends the update result notification
     *
     * @return string  The rendered data
     *
     * @since   5.4.0
     */
    public function notification($type, $oldVersion, $newVersion)
    {
        /**
         * @var UpdateModel $model
         */
        $model   = $this->getModel();
        $success = true;

        try {
            // Perform the finalization action
            $model->sendNotification($type, $oldVersion, $newVersion);
        } catch (\Throwable $e) {
            $success = false;
        }

        $element = (new Resource((object) ['success' => $success, 'id' => $type], $this->serializer))
            ->fields(['notification' => ['success']]);

        $this->getDocument()->setData($element);
        $this->getDocument()->addLink('self', Uri::current());

        return $this->getDocument()->render();
    }
}

The same content is in 71 releases, Joomla 5.4.0-beta2 to 6.2.1-rc1. See them all, or every version of this file.