コード例 #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
ファイル: 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;
 }
コード例 #4
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);
 }