CoreFiles by mySites.guru
NamespaceMap.php111 lines, 3,024 bytes, from Joomla_4.3.3-Stable-Full_Package.zip
Raw History Compare with 4.3.2
md5
fd11bc222c396f9b447bd78a3d6309d0
sha1
062adebb7e1d323f3cc4131c154e54a88e74cdad
sha256
b9776e338d6537148b365b43d8935b03a46f41a800b74620c5a2bb14fed6a8a3
<?php

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

namespace Joomla\Plugin\Extension\NamespaceMap\Extension;

use JNamespacePsr4Map;
use Joomla\CMS\Installer\Installer;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Event\DispatcherInterface;

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

/**
 * Joomla! namespace map creator / updater.
 *
 * @since  4.0.0
 */
final class NamespaceMap extends CMSPlugin
{
    /**
     * The namespace map file creator
     *
     * @var JNamespacePsr4Map
     */
    private $fileCreator = null;

    /**
     * Constructor
     *
     * @param   DispatcherInterface  $subject  The object to observe
     * @param   JNamespacePsr4Map    $map      The namespace map creator
     * @param   array                $config   An optional associative array of configuration settings.
     *                                         Recognized key values include 'name', 'group', 'params', 'language'
     *                                         (this list is not meant to be comprehensive).
     *
     * @since   4.0.0
     */
    public function __construct(DispatcherInterface $subject, JNamespacePsr4Map $map, $config = [])
    {
        $this->fileCreator = $map;

        parent::__construct($subject, $config);
    }

    /**
     * Update / Create map on extension install
     *
     * @param   Installer  $installer  Installer instance
     * @param   integer    $eid        Extension id
     *
     * @return  void
     *
     * @since   4.0.0
     */
    public function onExtensionAfterInstall($installer, $eid)
    {
        // Check that we have a valid extension
        if ($eid) {
            // Update / Create new map
            $this->fileCreator->create();
        }
    }

    /**
     * Update / Create map on extension uninstall
     *
     * @param   Installer  $installer  Installer instance
     * @param   integer    $eid        Extension id
     * @param   boolean    $removed    Installation result
     *
     * @return  void
     *
     * @since   4.0.0
     */
    public function onExtensionAfterUninstall($installer, $eid, $removed)
    {
        // Check that we have a valid extension and that it has been removed
        if ($eid && $removed) {
            // Update / Create new map
            $this->fileCreator->create();
        }
    }

    /**
     * Update map on extension update
     *
     * @param   Installer  $installer  Installer instance
     * @param   integer    $eid        Extension id
     *
     * @return  void
     *
     * @since   4.0.0
     */
    public function onExtensionAfterUpdate($installer, $eid)
    {
        // Check that we have a valid extension
        if ($eid) {
            // Update / Create new map
            $this->fileCreator->create();
        }
    }
}

The same content is in 20 releases, Joomla 4.3.0-alpha3 to 5.0.0-alpha1. See them all, or every version of this file.