1
0
Fork 0

Complete missing docblocks and fix incorrect ones

pull/2179/head
Nils Adermann 2013-08-15 18:04:13 +02:00
parent 3b519e44c4
commit 3e1519cde0
3 changed files with 78 additions and 7 deletions

View File

@ -165,11 +165,25 @@ class EventDispatcher
$className::$methodName($event); $className::$methodName($event);
} }
/**
* Add a listener for a particular event
*
* @param string $eventName The event name - typically a constant
* @param Callable $listener A callable expecting an event argument
* @param integer $priority A higher value represents a higher priority
*/
protected function addListener($eventName, $listener, $priority = 0) protected function addListener($eventName, $listener, $priority = 0)
{ {
$this->listeners[$eventName][$priority][] = $listener; $this->listeners[$eventName][$priority][] = $listener;
} }
/**
* Adds object methods as listeners for the events in getSubscribedEvents
*
* @see EventSubscriberInterface
*
* @param EventSubscriberInterface $subscriber
*/
public function addSubscriber(EventSubscriberInterface $subscriber) public function addSubscriber(EventSubscriberInterface $subscriber)
{ {
foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
@ -185,6 +199,12 @@ class EventDispatcher
} }
} }
/**
* Retrieves all listeners for a given event
*
* @param Event $event
* @return array All listeners: callables and scripts
*/
protected function getListeners(Event $event) protected function getListeners(Event $event)
{ {
$scriptListeners = $this->getScriptListeners($event); $scriptListeners = $this->getScriptListeners($event);
@ -201,6 +221,8 @@ class EventDispatcher
} }
/** /**
* Finds all listeners defined as scripts in the package
*
* @param Event $event Event object * @param Event $event Event object
* @return array Listeners * @return array Listeners
*/ */

View File

@ -45,6 +45,9 @@ class PluginManager
$this->io = $io; $this->io = $io;
} }
/**
* Loads all plugins from currently installed plugin packages
*/
public function loadInstalledPlugins() public function loadInstalledPlugins()
{ {
$repo = $this->composer->getRepositoryManager()->getLocalRepository(); $repo = $this->composer->getRepositoryManager()->getLocalRepository();
@ -59,7 +62,7 @@ class PluginManager
} }
/** /**
* Adds plugin * Adds a plugin, activates it and registers it with the event dispatcher
* *
* @param PluginInterface $plugin plugin instance * @param PluginInterface $plugin plugin instance
*/ */
@ -73,11 +76,25 @@ class PluginManager
} }
} }
/**
* Gets all currently active plugin instances
*
* @return array plugins
*/
public function getPlugins() public function getPlugins()
{ {
return $this->plugins; return $this->plugins;
} }
/**
* Recursively generates a map of package names to packages for all deps
*
* @param Pool $pool Package pool of installed packages
* @param array $collected Current state of the map for recursion
* @param PackageInterface $package The package to analyze
*
* @return array Map of package names to packages
*/
protected function collectDependencies(Pool $pool, array $collected, PackageInterface $package) protected function collectDependencies(Pool $pool, array $collected, PackageInterface $package)
{ {
$requires = array_merge( $requires = array_merge(
@ -96,6 +113,16 @@ class PluginManager
return $collected; return $collected;
} }
/**
* Resolves a package link to a package in the installed pool
*
* Since dependencies are already installed this should always find one.
*
* @param Pool $pool Pool of installed packages only
* @param Link $link Package link to look up
*
* @return PackageInterface|null The found package
*/
protected function lookupInstalledPackage(Pool $pool, Link $link) protected function lookupInstalledPackage(Pool $pool, Link $link)
{ {
$packages = $pool->whatProvides($link->getTarget(), $link->getConstraint()); $packages = $pool->whatProvides($link->getTarget(), $link->getConstraint());
@ -103,6 +130,14 @@ class PluginManager
return (!empty($packages)) ? $packages[0] : null; return (!empty($packages)) ? $packages[0] : null;
} }
/**
* Register a plugin package, activate it etc.
*
* If it's of type composer-installer it is registered as an installer
* instead for BC
*
* @param PackageInterface $package
*/
public function registerPackage(PackageInterface $package) public function registerPackage(PackageInterface $package)
{ {
$oldInstallerPlugin = ($package->getType() === 'composer-installer'); $oldInstallerPlugin = ($package->getType() === 'composer-installer');
@ -149,6 +184,12 @@ class PluginManager
} }
} }
/**
* Retrieves the path a package is installed to.
*
* @param PackageInterface $package
* @return string Install path
*/
public function getInstallPath(PackageInterface $package) public function getInstallPath(PackageInterface $package)
{ {
$targetDir = $package->getTargetDir(); $targetDir = $package->getTargetDir();
@ -156,6 +197,14 @@ class PluginManager
return $this->getPackageBasePath($package) . ($targetDir ? '/'.$targetDir : ''); return $this->getPackageBasePath($package) . ($targetDir ? '/'.$targetDir : '');
} }
/**
* Retrieves the base path a package gets installed into.
*
* Does not take targetDir into account.
*
* @param PackageInterface $package
* @return string Base path
*/
protected function getPackageBasePath(PackageInterface $package) protected function getPackageBasePath(PackageInterface $package)
{ {
$vendorDir = rtrim($this->composer->getConfig()->get('vendor-dir'), '/'); $vendorDir = rtrim($this->composer->getConfig()->get('vendor-dir'), '/');

View File

@ -38,10 +38,8 @@ class PreFileDownloadEvent extends Event
* Constructor. * Constructor.
* *
* @param string $name The event name * @param string $name The event name
* @param Composer $composer The composer object * @param RemoteFilesystem $rfs
* @param IOInterface $io The IOInterface object * @param string $processedUrl
* @param boolean $devMode Whether or not we are in dev mode
* @param OperationInterface $operation The operation object
*/ */
public function __construct($name, RemoteFilesystem $rfs, $processedUrl) public function __construct($name, RemoteFilesystem $rfs, $processedUrl)
{ {
@ -53,7 +51,7 @@ class PreFileDownloadEvent extends Event
/** /**
* Returns the remote filesystem * Returns the remote filesystem
* *
* @return OperationInterface * @return RemoteFilesystem
*/ */
public function getRemoteFilesystem() public function getRemoteFilesystem()
{ {
@ -62,6 +60,8 @@ class PreFileDownloadEvent extends Event
/** /**
* Sets the remote filesystem * Sets the remote filesystem
*
* @param RemoteFilesystem $rfs
*/ */
public function setRemoteFilesystem(RemoteFilesystem $rfs) public function setRemoteFilesystem(RemoteFilesystem $rfs)
{ {