Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PostFileDownloadEvent.php

class PostFileDownloadEvent

The post file download event.

@author Nils Adermann <naderman@naderman.de>

Hierarchy

  • class \Composer\EventDispatcher\Event
    • class \Composer\Plugin\PostFileDownloadEvent extends \Composer\EventDispatcher\Event

Expanded class hierarchy of PostFileDownloadEvent

2 files declare their use of PostFileDownloadEvent
ComposerRepository.php in vendor/composer/composer/src/Composer/Repository/ComposerRepository.php
FileDownloader.php in vendor/composer/composer/src/Composer/Downloader/FileDownloader.php

File

vendor/composer/composer/src/Composer/Plugin/PostFileDownloadEvent.php, line 23

Namespace

Composer\Plugin
View source
class PostFileDownloadEvent extends Event {
    
    /**
     * @var string
     */
    private $fileName;
    
    /**
     * @var string|null
     */
    private $checksum;
    
    /**
     * @var string
     */
    private $url;
    
    /**
     * @var mixed
     */
    private $context;
    
    /**
     * @var string
     */
    private $type;
    
    /**
     * Constructor.
     *
     * @param string      $name     The event name
     * @param string|null $fileName The file name
     * @param string|null $checksum The checksum
     * @param string      $url      The processed url
     * @param string      $type     The type (package or metadata).
     * @param mixed       $context  Additional context for the download.
     */
    public function __construct(string $name, ?string $fileName, ?string $checksum, string $url, string $type, $context = null) {
        
        /** @phpstan-ignore instanceof.alwaysFalse, booleanAnd.alwaysFalse */
        if ($context === null && $type instanceof PackageInterface) {
            $context = $type;
            $type = 'package';
            trigger_error('PostFileDownloadEvent::__construct should receive a $type=package and the package object in $context since Composer 2.1.', E_USER_DEPRECATED);
        }
        parent::__construct($name);
        $this->fileName = $fileName;
        $this->checksum = $checksum;
        $this->url = $url;
        $this->context = $context;
        $this->type = $type;
    }
    
    /**
     * Retrieves the target file name location.
     *
     * If this download is of type metadata, null is returned.
     */
    public function getFileName() : ?string {
        return $this->fileName;
    }
    
    /**
     * Gets the checksum.
     */
    public function getChecksum() : ?string {
        return $this->checksum;
    }
    
    /**
     * Gets the processed URL.
     */
    public function getUrl() : string {
        return $this->url;
    }
    
    /**
     * Returns the context of this download, if any.
     *
     * If this download is of type package, the package object is returned. If
     * this download is of type metadata, an array{response: Response, repository: RepositoryInterface} is returned.
     *
     * @return mixed
     */
    public function getContext() {
        return $this->context;
    }
    
    /**
     * Get the package.
     *
     * If this download is of type metadata, null is returned.
     *
     * @return \Composer\Package\PackageInterface|null The package.
     * @deprecated Use getContext instead
     */
    public function getPackage() : ?PackageInterface {
        trigger_error('PostFileDownloadEvent::getPackage is deprecated since Composer 2.1, use getContext instead.', E_USER_DEPRECATED);
        $context = $this->getContext();
        return $context instanceof PackageInterface ? $context : null;
    }
    
    /**
     * Returns the type of this download (package, metadata).
     */
    public function getType() : string {
        return $this->type;
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title
Event::$args protected property
Event::$flags protected property
Event::$name protected property
Event::$propagationStopped private property
Event::getArguments public function Returns the event&#039;s arguments.
Event::getFlags public function Returns the event&#039;s flags.
Event::getName public function Returns the event&#039;s name.
Event::isPropagationStopped public function Checks if stopPropagation has been called
Event::stopPropagation public function Prevents the event from being passed to further listeners
PostFileDownloadEvent::$checksum private property
PostFileDownloadEvent::$context private property
PostFileDownloadEvent::$fileName private property
PostFileDownloadEvent::$type private property
PostFileDownloadEvent::$url private property
PostFileDownloadEvent::getChecksum public function Gets the checksum.
PostFileDownloadEvent::getContext public function Returns the context of this download, if any.
PostFileDownloadEvent::getFileName public function Retrieves the target file name location.
PostFileDownloadEvent::getPackage Deprecated public function Get the package.
PostFileDownloadEvent::getType public function Returns the type of this download (package, metadata).
PostFileDownloadEvent::getUrl public function Gets the processed URL.
PostFileDownloadEvent::__construct public function Constructor. Overrides Event::__construct

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal