WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
класс не описан

CustomAutoloaderPlugin() WC 1.0

Class CustomAutoloaderPlugin.

Хуков нет.

Возвращает

Null. Ничего.

Использование

$CustomAutoloaderPlugin = new CustomAutoloaderPlugin();
// use class methods

Методы

  1. activate( Composer $composer, IOInterface $io )
  2. activate( Composer $composer, IOInterface $io )
  3. activate( Composer $composer, IOInterface $io )
  4. getSubscribedEvents()
  5. getSubscribedEvents()
  6. getSubscribedEvents()
  7. postAutoloadDump( Event $event )
  8. postAutoloadDump( Event $event )
  9. postAutoloadDump( Event $event )

Заметки

  • Пакет: automattic/jetpack-autoloader

Код CustomAutoloaderPlugin: woocommerce/vendor/automattic/jetpack-autoloader/src/CustomAutoloaderPlugin.php WC 4.3.1

<?php
class CustomAutoloaderPlugin implements PluginInterface, EventSubscriberInterface {

	/**
	 * IO object.
	 *
	 * @var IOInterface IO object.
	 */
	private $io;

	/**
	 * Composer object.
	 *
	 * @var Composer Composer object.
	 */
	private $composer;

	/**
	 * Do nothing.
	 *
	 * @param Composer    $composer Composer object.
	 * @param IOInterface $io IO object.
	 */
	public function activate( Composer $composer, IOInterface $io ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
		$this->composer = $composer;
		$this->io       = $io;
	}

	/**
	 * Tell composer to listen for events and do something with them.
	 *
	 * @return array List of succribed events.
	 */
	public static function getSubscribedEvents() {
		return array(
			ScriptEvents::POST_AUTOLOAD_DUMP => 'postAutoloadDump',
		);
	}

	/**
	 * Generate the custom autolaoder.
	 *
	 * @param Event $event Script event object.
	 */
	public function postAutoloadDump( Event $event ) {

		$installationManager = $this->composer->getInstallationManager();
		$repoManager         = $this->composer->getRepositoryManager();
		$localRepo           = $repoManager->getLocalRepository();
		$package             = $this->composer->getPackage();
		$config              = $this->composer->getConfig();
		$optimize            = true;
		$suffix              = $config->get( 'autoloader-suffix' )
			? $config->get( 'autoloader-suffix' )
			: md5( uniqid( '', true ) );

		$generator = new AutoloadGenerator( $this->io );

		$generator->dump( $config, $localRepo, $package, $installationManager, 'composer', $optimize, $suffix );
		$this->generated = true;
	}

}