eZ\Bundle\EzPublishCoreBundle\EventListener\ConsoleCommandListener::onConsoleCommand PHP Метод

onConsoleCommand() публичный Метод

public onConsoleCommand ( Symfony\Component\Console\Event\ConsoleCommandEvent $event )
$event Symfony\Component\Console\Event\ConsoleCommandEvent
    public function onConsoleCommand(ConsoleCommandEvent $event)
    {
        $this->siteAccess->name = $event->getInput()->getParameterOption('--siteaccess', $this->defaultSiteAccessName);
        $this->siteAccess->matchingType = 'cli';
        if (!in_array($this->siteAccess->name, $this->siteAccessList)) {
            throw new InvalidSiteAccessException($this->siteAccess->name, $this->siteAccessList, $this->siteAccess->matchingType);
        }
        $this->eventDispatcher->dispatch(MVCEvents::CONFIG_SCOPE_CHANGE, new ScopeChangeEvent($this->siteAccess));
    }

Usage Example

 public function testDefaultSiteAccess()
 {
     $this->dispatcher->expects($this->once())->method('dispatch');
     $input = new ArrayInput(array(), $this->inputDefinition);
     $event = new ConsoleCommandEvent($this->command, $input, $this->testOutput);
     $this->listener->onConsoleCommand($event);
     $this->assertEquals(new SiteAccess('default', 'cli'), $this->siteAccess);
 }