Turn EventDispatcher into generic solution handling plugins as well
parent
2f43e9aefb
commit
3960edd64e
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\EventDispatcher;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\IO\IOInterface;
|
||||
|
||||
/**
|
||||
* The base event class
|
||||
*
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
class Event
|
||||
{
|
||||
/**
|
||||
* @var string This event's name
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @var boolean Whether the event should not be passed to more listeners
|
||||
*/
|
||||
private $propagationStopped = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name The event name
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event's name.
|
||||
*
|
||||
* @return string The event name
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if stopPropagation has been called
|
||||
*
|
||||
* @return boolean Whether propagation has been stopped
|
||||
*/
|
||||
public function isPropagationStopped()
|
||||
{
|
||||
return $this->propagationStopped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents the event from being passed to further listeners
|
||||
*/
|
||||
public function stopPropagation()
|
||||
{
|
||||
$this->propagationStopped = true;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Plugin;
|
||||
|
||||
/**
|
||||
* The Plugin Events.
|
||||
*
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
class PluginEvents
|
||||
{
|
||||
/**
|
||||
* The PREPARE_REMOTE_FILESYSTEM event occurs before downloading a file
|
||||
*
|
||||
* The event listener method receives a
|
||||
* Composer\Plugin\PrepareRemoteFilesystemEvent instance.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const PREPARE_REMOTE_FILESYSTEM = 'prepare-remote-filesystem';
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Plugin;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\EventDispatcher\Event;
|
||||
use Composer\Util\RemoteFilesystem;
|
||||
|
||||
/**
|
||||
* The Prepare Remote Filesystem Event.
|
||||
*
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
class PrepareRemoteFilesystemEvent extends Event
|
||||
{
|
||||
/**
|
||||
* @var RemoteFilesystem
|
||||
*/
|
||||
private $rfs;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $processedUrl;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name The event name
|
||||
* @param Composer $composer The composer object
|
||||
* @param IOInterface $io The IOInterface object
|
||||
* @param boolean $devMode Whether or not we are in dev mode
|
||||
* @param OperationInterface $operation The operation object
|
||||
*/
|
||||
public function __construct($name, RemoteFilesystem $rfs, $processedUrl)
|
||||
{
|
||||
parent::__construct($name);
|
||||
$this->rfs = $rfs;
|
||||
$this->processedUrl = $processedUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the remote filesystem
|
||||
*
|
||||
* @return OperationInterface
|
||||
*/
|
||||
public function getRemoteFilesystem()
|
||||
{
|
||||
return $this->rfs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the remote filesystem
|
||||
*/
|
||||
public function setRemoteFilesystem(RemoteFilesystem $rfs)
|
||||
{
|
||||
$this->rfs = $rfs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the processed URL this remote filesystem will be used for
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getProcessedUrl()
|
||||
{
|
||||
return $this->processedUrl;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue