コード例 #1
0
 /**
  * {@inheritdoc}
  */
 protected function initialize()
 {
     if (true === $this->initialized) {
         return;
     }
     $this->documents = $this->result->getRows();
     $this->initialized = true;
 }
コード例 #2
0
 /**
  * Render a table with the results of the given QueryResultInterface
  */
 public function formatQueryResult(QueryResultInterface $result, OutputInterface $output, $elapsed)
 {
     $table = $this->tableHelper->create();
     $table->setHeaders(array_merge(array('Path', 'Index'), $result->getColumnNames()));
     foreach ($result->getRows() as $row) {
         $values = array_merge(array($row->getPath()), $row->getValues());
         foreach ($values as &$value) {
             $value = $this->textHelper->truncate($value, 255);
         }
         $table->addRow($values);
     }
     $table->render($output);
     if (true === $this->config['show_execution_time_query']) {
         $output->writeln(sprintf('%s rows in set (%s sec)', count($result->getRows()), number_format($elapsed, $this->config['execution_time_expansion'])));
     }
 }
コード例 #3
0
 /**
  * It should handle query execution and set the result.
  */
 public function testHandleQueryExecute()
 {
     $locale = 'fr';
     $primarySelector = 'p';
     $this->query->getLocale()->willReturn($locale);
     $this->query->getPhpcrQuery()->willReturn($this->phpcrQuery->reveal());
     $this->phpcrQuery->execute()->willReturn($this->phpcrResult->reveal());
     $this->query->getPrimarySelector()->willReturn($primarySelector);
     $this->queryExecuteEvent->getQuery()->willReturn($this->query->reveal());
     $this->queryExecuteEvent->getOptions()->willReturn([]);
     $this->queryExecuteEvent->setResult(new QueryResultCollection($this->phpcrResult->reveal(), $this->dispatcher->reveal(), $locale))->shouldBeCalled();
     $this->subscriber->handleQueryExecute($this->queryExecuteEvent->reveal());
 }
コード例 #4
0
 public function testReadPropertyContentFromResults()
 {
     $seekName = '/tests_general_base/multiValueProperty';
     $this->assertTrue(count($this->qr->getNodes()) > 0);
     foreach ($this->qr->getNodes() as $path => $node) {
         if ($seekName == $path) {
             break;
         }
     }
     $this->assertInstanceOf('PHPCR\\NodeInterface', $node);
     $prop = $node->getProperty('jcr:uuid');
     $this->assertInstanceOf('PHPCR\\PropertyInterface', $prop);
     $this->assertEquals('jcr:uuid', $prop->getName());
     $this->assertEquals('14e18ef3-be20-4985-bee9-7bb4763b31de', $prop->getString());
 }
コード例 #5
0
ファイル: ContentMapper.php プロジェクト: kriswillis/sulu
 /**
  * {@inheritdoc}
  */
 public function convertQueryResultToArray(QueryResultInterface $queryResult, $webspaceKey, $locales, $fields, $maxDepth)
 {
     $rootDepth = substr_count($this->sessionManager->getContentPath($webspaceKey), '/');
     $result = array();
     foreach ($locales as $locale) {
         foreach ($queryResult->getRows() as $row) {
             $pageDepth = substr_count($row->getPath('page'), '/') - $rootDepth;
             if ($maxDepth === null || $maxDepth < 0 || $maxDepth > 0 && $pageDepth <= $maxDepth) {
                 $item = $this->rowToArray($row, $locale, $webspaceKey, $fields);
                 if (false === $item || in_array($item, $result)) {
                     continue;
                 }
                 $result[] = $item;
             }
         }
     }
     return $result;
 }
コード例 #6
0
 /**
  * @return bool Whether to execute the action or not.
  */
 private function shouldExecute(InputInterface $input, OutputInterface $output, QueryResultInterface $result)
 {
     $response = strtoupper($this->ask($input, $output, sprintf('<question>About to update %d nodes. Enter "Y" to continue, "N" to cancel or "L" to list.</question>', count($result->getRows()))));
     if ($response == 'L') {
         /** @var $row RowInterface */
         foreach ($result as $i => $row) {
             $output->writeln(sprintf(' - [%d] %s', $i, $row->getPath()));
         }
         return $this->shouldExecute($input, $output, $result);
     }
     if ($response == 'N') {
         return false;
     }
     if ($response == 'Y') {
         return true;
     }
     return $this->shouldExecute($input, $output, $result);
 }