Пример #1
0
 /**
  * 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
0
 /**
  * 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
0
 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);
     }
 }
 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));
 }
 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);
 }
 /**
  * @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());
     }
 }
 /**
  * @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
0
 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
0
 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
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testGetArgException()
 {
     $this->event->getArgument('nameNotExist');
 }
 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
0
 public function addToFailed(GenericEvent $event)
 {
     $this->failed[$event->getArgument('uri')->toString()] = $event->getArgument('message');
 }
Пример #13
0
 protected function logEvent($name, GenericEvent $event)
 {
     if ($this->debug === true) {
         echo "\n[{$name}]\t:" . $event->getArgument('uri')->toString();
     }
 }
 protected function logEvent($name, GenericEvent $event)
 {
     if ($this->debug === TRUE) {
         \Pimcore\Logger::debug('LuceneSearch [' . $name . ']: ' . $event->getArgument('uri')->toString());
     }
 }
 /**
  *
  * @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];
 }