CoreFiles by mySites.guru
namespacemap.php107 lines, 2,512 bytes, from Joomla_4.0.0-beta1-Beta-Full_Package.zip
Raw History Compare with 3.9.0-beta4
md5
b977e2356dd21d3c5156f1f9eb79d103
sha1
8a9e955a00d749df6483940ef11ecdcea6442e5b
sha256
4180a9921cae97a93a8c4c79eb1455e6ef44c52c307aee20034dc37f45275986
<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  Extension.Joomla
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Installer\Installer as JInstaller;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Event\DispatcherInterface;

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

	/**
	 * Constructor
	 *
	 * @param   DispatcherInterface  &$subject  The object to observe
	 * @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
	 */
	public function __construct(&$subject, $config = array())
	{
		$this->fileCreator = new JNamespacePsr4Map;

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

	/**
	 * Update / Create map on extension install
	 *
	 * @param   JInstaller  $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   JInstaller  $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   JInstaller  $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 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.