本文整理汇总了PHP中Symfony\Component\EventDispatcher\GenericEvent::getArgument方法的典型用法代码示例。如果您正苦于以下问题:PHP GenericEvent::getArgument方法的具体用法?PHP GenericEvent::getArgument怎么用?PHP GenericEvent::getArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\EventDispatcher\GenericEvent
的用法示例。
在下文中一共展示了GenericEvent::getArgument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: up
/**
* Starts a new phantomjs process in background
*
* @throws \Symfony\Component\Process\Exception\RuntimeException
*/
public function up()
{
$this->killAllRunning();
$this->process = new Process('phantomjs --webdriver=' . $this->port . ' ' . $this->options);
$process = $this->process;
$output = new GenericEvent();
$process->setTimeout(null);
$process->start(function () use($process, $output) {
$output->setArgument('output', $process->getIncrementalOutput());
});
$phantomjsOnline = false;
$portScan = false;
while (!$phantomjsOnline) {
if ($output->hasArgument('output')) {
$portScan = strpos($output->getArgument('output'), 'running on port ' . $this->port);
}
if ($portScan) {
echo $output->getArgument('output');
}
$phantomjsOnline = $process->isStarted() && $process->isRunning() && $portScan;
if ($process->isTerminated()) {
throw new RuntimeException('Phantomjs could not been started with webdriver on port ' . $this->port);
}
}
}
示例2: generateEditorLink
/**
* Generates editor's link
*
* @param GenericEvent $event Symfony Event
*/
public function generateEditorLink(GenericEvent $event)
{
$articleNumber = $event->getArgument('articleNumber');
$articleLanguage = $event->getArgument('articleLanguage');
if ($this->pluginsService->isEnabled($this->getPluginName()) && $this->hasAccessToEditor()) {
$articleLink = $this->router->generate('newscoop_admin_aes', array('articleNumber' => $articleNumber, 'language' => $articleLanguage));
}
$event->setArgument('link', $articleLink);
}
示例3: onBuilderPostTask
public function onBuilderPostTask(GenericEvent $event)
{
if (true === $this->showProgress) {
$index = $event->getArgument('index');
$total = $event->getArgument('total');
$percentage = ++$index * 100 / $total;
$this->io->overwrite(sprintf('Progress: <comment>%d%%</comment>', $percentage), false);
$this->needsNewline = true;
} else {
$this->io->decreaseIndention(2);
}
}
示例4: initializeRequest
public function initializeRequest(GenericEvent $event)
{
if (null === $this->request) {
return;
}
$this->request->attributes->set('easyadmin', array('entity' => $entity = $event->getArgument('entity'), 'view' => $this->request->query->get('action', 'list'), 'item' => ($id = $this->request->query->get('id')) ? $this->findCurrentItem($entity, $id) : null));
}
示例5:
function it_does_not_set_locale_on_post_update_when_event_subject_is_different_from_current_user($translator, GenericEvent $event, UserInterface $user, RequestStack $requestStack, Request $request, LocaleInterface $locale)
{
$event->getSubject()->willReturn($user);
$event->getArgument('current_user')->willReturn(null);
$translator->setLocale('fr_FR')->shouldNotBeCalled();
$this->onPostUpdate($event);
}
示例6: onPostUpdate
/**
* @param GenericEvent $event
*/
public function onPostUpdate(GenericEvent $event)
{
$user = $event->getSubject();
if ($user === $event->getArgument('current_user')) {
$request = $this->requestStack->getMasterRequest();
$request->getSession()->set('_locale', $user->getUiLocale()->getCode());
$this->translator->setLocale($user->getUiLocale()->getCode());
}
}
示例7: onCrawlPreRequest
/**
* @param GenericEvent $event
*/
public function onCrawlPreRequest(GenericEvent $event)
{
$currentHostname = $event->getArgument('uri')->getHost();
if ($currentHostname === $this->previousHostname) {
$this->totalDelay = $this->totalDelay + $this->requestDelay;
usleep($this->requestDelay);
}
$this->previousHostname = $currentHostname;
}
示例8: let
function let(OutputPrinter $printer, GenericEvent $event, InvokableMethod $method, \ReflectionMethod $refl, ExampleTestResult $result)
{
$this->beConstructedWith($printer, new ExceptionPresenter(), '/current/path');
$event->getSubject()->willReturn($method);
$event->getArgument('result')->willReturn($result);
$method->getReflection()->willReturn($refl);
$method->getPath()->willReturn('/current/path/to/spec');
$refl->getName()->willReturn('it_does_stuff');
$refl->getStartLine()->willReturn(42);
$printer->write(' <comment>to/spec</comment> <lineno>+42</lineno>')->willReturn();
$printer->writeln(Argument::type('string'))->shouldBeCalled();
$printer->writeln(Argument::type('null'))->shouldBeCalled();
$result->getStdOut()->willReturn();
}
示例9: onTaskPreExecute
public function onTaskPreExecute(GenericEvent $event)
{
$task = $event->getSubject();
$io = $this->io;
$self = $this;
$task->setOutput(function ($output) use($io, $self) {
if ($io->isVerbose()) {
$io->write(sprintf('%s', $output));
$self->needsNewline = false;
} else {
$io->overwrite(sprintf('%s', $output), false);
$self->needsNewline = true;
}
});
if ($event->getArgument('index') > 0) {
if (true === $this->needsNewline) {
$this->io->write('');
$this->needsNewline = false;
}
$this->io->write('');
}
$this->io->write(sprintf('- Executing task <info>%s</info>', get_class($task)));
$this->io->increaseIndention(2);
}
示例10: testGetArgException
/**
* @expectedException \InvalidArgumentException
*/
public function testGetArgException()
{
$this->event->getArgument('nameNotExist');
}
示例11: onBlacklisted
public function onBlacklisted(GenericEvent $event)
{
$url = $event->getArgument('uri')->toString();
$this->logger->info(sprintf('blacklisted %s', $url), ['tags' => [parse_url($url, PHP_URL_HOST)]]);
}
示例12: addToFailed
public function addToFailed(GenericEvent $event)
{
$this->failed[$event->getArgument('uri')->toString()] = $event->getArgument('message');
}
示例13: logEvent
protected function logEvent($name, GenericEvent $event)
{
if ($this->debug === true) {
echo "\n[{$name}]\t:" . $event->getArgument('uri')->toString();
}
}
示例14: logEvent
protected function logEvent($name, GenericEvent $event)
{
if ($this->debug === TRUE) {
\Pimcore\Logger::debug('LuceneSearch [' . $name . ']: ' . $event->getArgument('uri')->toString());
}
}
示例15: getEntityClass
/**
*
* @return string
*/
protected function getEntityClass(GenericEvent $event)
{
$entity = $event->getArgument('entity');
$entityNamespace = get_class($entity);
$entityClasses = explode('\\', $entityNamespace);
//get last string of the classname
return $entityClasses[count($entityClasses) - 1];
}