protected function execute(InputInterface $input, OutputInterface $output)
{
$this->detectMagento($output, true);
if (!$this->initMagento()) {
return;
}
if ($input->hasOption('fpc') && $input->getOption('fpc')) {
if (!class_exists('\\Enterprise_PageCache_Model_Cache')) {
throw new RuntimeException('Enterprise page cache not found');
}
$cacheInstance = \Enterprise_PageCache_Model_Cache::getCacheInstance()->getFrontend();
} else {
$cacheInstance = \Mage::app()->getCache();
}
/* @var $cacheInstance \Varien_Cache_Core */
$cacheIds = $cacheInstance->getIds();
$table = array();
foreach ($cacheIds as $cacheId) {
if ($input->getOption('filter-id') !== null && !stristr($cacheId, $input->getOption('filter-id'))) {
continue;
}
$metaData = $cacheInstance->getMetadatas($cacheId);
if ($input->getOption('filter-tag') !== null && !$this->isTagFiltered($metaData, $input)) {
continue;
}
$row = array($cacheId, date('Y-m-d H:i:s', $metaData['expire']));
if ($input->getOption('mtime')) {
$row[] = date('Y-m-d H:i:s', $metaData['mtime']);
}
if ($input->getOption('tags')) {
$row[] = implode(',', $metaData['tags']);
}
$table[] = $row;
}
$headers = array('ID', 'EXPIRE');
if ($input->getOption('mtime')) {
$headers[] = 'MTIME';
}
if ($input->getOption('tags')) {
$headers[] = 'TAGS';
}
$this->getHelper('table')->setHeaders($headers)->renderByFormat($output, $table, $input->getOption('format'));
}