setDescription('Build missing subviews'); return $this; } /** * {@inheritdoc} */ public function requireSetup() { return true; } /** * {@inheritdoc} */ protected function doExecute(InputInterface $input, OutputInterface $output) { $core = \bootstrap::getCore(); $this->appbox = \appbox::get_instance($core); if ($input->getOption('verbose')) { $logger = $this->getLogger(); $handler = new Handler\StreamHandler('php://stdout'); $logger->pushHandler($handler); $this->setLogger($logger); } $start = microtime(true); $n = 0; foreach ($this->appbox->get_databoxes() as $databox) { $subdefStructure = $databox->get_subdef_structure(); $sql = 'SELECT record_id FROM record WHERE parent_record_id = 0'; $stmt = $databox->get_connection()->prepare($sql); $stmt->execute(); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $stmt->closeCursor(); foreach ($rs as $row) { $record = $databox->get_record($row['record_id']); try { $record->get_hd_file(); } catch (FileNotFoundException $e) { continue; } $group = $subdefStructure->getSubdefGroup($record->get_type()); if ($group) { foreach ($group as $subdef) { $todo = false; if ( ! $record->has_subdef($subdef->get_name())) { $todo = true; } if (in_array($subdef->get_name(), array('preview', 'thumbnail', 'thumbnailgif'))) { try { $sub = $record->get_subdef($subdef->get_name()); if ( ! $sub->is_physically_present()) { $todo = true; } } catch (\Exception_Media_SubdefNotFound $e) { $todo = true; } } if ($todo) { $record->generate_subdefs($databox, $this->getLogger(), array($subdef->get_name())); $this->getLogger()->addInfo("generate " . $subdef->get_name() . " for record " . $record->get_record_id()); $n ++; } } } unset($record); } } $this->getLogger()->addInfo($n . " subdefs done"); $stop = microtime(true); $duration = $stop - $start; $this->getLogger()->addInfo(sprintf("process took %s, (%f sd/s.)", $this->getFormattedDuration($duration), round($n / $duration, 3))); return; } }