Clean stuff up and deprecate old usages for PostFileDownloadEvent
parent
df0a2cdd0a
commit
7dd95a768b
|
@ -192,7 +192,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($eventDispatcher) {
|
if ($eventDispatcher) {
|
||||||
$postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, $fileName, $checksum, $url['processed'], $package);
|
$postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, $fileName, $checksum, $url['processed'], 'package', $package);
|
||||||
$eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
|
$eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ interface PluginInterface
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const PLUGIN_API_VERSION = '2.0.0';
|
const PLUGIN_API_VERSION = '2.1.0';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply plugin modifications to Composer
|
* Apply plugin modifications to Composer
|
||||||
|
|
|
@ -54,11 +54,17 @@ class PostFileDownloadEvent extends Event
|
||||||
* @param string|null $fileName The file name
|
* @param string|null $fileName The file name
|
||||||
* @param string|null $checksum The checksum
|
* @param string|null $checksum The checksum
|
||||||
* @param string $url The processed url
|
* @param string $url The processed url
|
||||||
* @param mixed $context Additional context for the download.
|
|
||||||
* @param string $type The type (package or metadata).
|
* @param string $type The type (package or metadata).
|
||||||
|
* @param mixed $context Additional context for the download.
|
||||||
*/
|
*/
|
||||||
public function __construct($name, $fileName, $checksum, $url, $context = null, $type = 'package')
|
public function __construct($name, $fileName, $checksum, $url, $type, $context = null)
|
||||||
{
|
{
|
||||||
|
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);
|
parent::__construct($name);
|
||||||
$this->fileName = $fileName;
|
$this->fileName = $fileName;
|
||||||
$this->checksum = $checksum;
|
$this->checksum = $checksum;
|
||||||
|
@ -118,10 +124,13 @@ class PostFileDownloadEvent extends Event
|
||||||
* If this download is of type metadata, null is returned.
|
* If this download is of type metadata, null is returned.
|
||||||
*
|
*
|
||||||
* @return \Composer\Package\PackageInterface|null The package.
|
* @return \Composer\Package\PackageInterface|null The package.
|
||||||
|
* @deprecated Use getContext instead
|
||||||
*/
|
*/
|
||||||
public function getPackage()
|
public function getPackage()
|
||||||
{
|
{
|
||||||
|
trigger_error('PostFileDownloadEvent::getPackage is deprecated since Composer 2.1, use getContext instead.', E_USER_DEPRECATED);
|
||||||
$context = $this->getContext();
|
$context = $this->getContext();
|
||||||
|
|
||||||
return $context instanceof PackageInterface ? $context : null;
|
return $context instanceof PackageInterface ? $context : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1112,7 +1112,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->eventDispatcher) {
|
if ($this->eventDispatcher) {
|
||||||
$postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, $sha256, $filename, $response, 'metadata');
|
$postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, $sha256, $filename, 'metadata', $response);
|
||||||
$this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
|
$this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1195,7 +1195,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->eventDispatcher) {
|
if ($this->eventDispatcher) {
|
||||||
$postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $filename, $response, 'metadata');
|
$postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $filename, 'metadata', $response);
|
||||||
$this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
|
$this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1288,7 +1288,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($eventDispatcher) {
|
if ($eventDispatcher) {
|
||||||
$postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $url, $response, 'metadata');
|
$postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $url, 'metadata', $response);
|
||||||
$eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
|
$eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,6 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"composer-plugin-api": "2.0.0"
|
"composer-plugin-api": "^2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue