1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101:
<?php
/*
* This file is part of the webmozart/console package.
*
* (c) Bernhard Schussek <bschussek@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Webmozart\Console\Api\Event;
use Symfony\Component\EventDispatcher\Event;
use Webmozart\Console\Api\Application\Application;
use Webmozart\Console\Api\Args\RawArgs;
use Webmozart\Console\Api\Resolver\ResolvedCommand;
/**
* Dispatched before the console arguments are resolved to a command.
*
* Add a listener for this event to customize the command used for the given
* console arguments.
*
* @since 1.0
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class PreResolveEvent extends Event
{
/**
* @var RawArgs
*/
private $rawArgs;
/**
* @var Application
*/
private $application;
/**
* @var ResolvedCommand
*/
private $resolvedCommand;
/**
* Creates the event.
*
* @param RawArgs $rawArgs The raw console arguments.
* @param Application $application The application.
*/
public function __construct(RawArgs $rawArgs, Application $application)
{
$this->rawArgs = $rawArgs;
$this->application = $application;
}
/**
* Returns the raw console arguments.
*
* @return RawArgs The raw console arguments.
*/
public function getRawArgs()
{
return $this->rawArgs;
}
/**
* Returns the application.
*
* @return Application The application.
*/
public function getApplication()
{
return $this->application;
}
/**
* Returns the resolved command.
*
* @return ResolvedCommand Returns the resolved command or `null` if none
* was set.
*/
public function getResolvedCommand()
{
return $this->resolvedCommand;
}
/**
* Sets the resolved command.
*
* @param ResolvedCommand $resolvedCommand The resolved command. Set to
* `null` to let the configured
* resolver decide.
*/
public function setResolvedCommand(ResolvedCommand $resolvedCommand = null)
{
$this->resolvedCommand = $resolvedCommand;
}
}