public function execute($session) { $trace = $session->getCallStack()->getTrace(); $t = new \Console_Table(CONSOLE_TABLE_ALIGN_LEFT, ''); $t->setAlign(2, CONSOLE_TABLE_ALIGN_RIGHT); foreach ($trace as $i => $a) { $t->addRow([$this->getCallable($a), isset($a['file']) ? $a['file'] : '', isset($a['line']) ? $a['line'] : '']); } echo $t->getTable(); return true; }
/** * List bundles * * @return void */ private function execList() { $pathArg = $this->getPathArgument('path', false, $this->getCommand()); $path = new ProjectPath($pathArg); $que = $this->getBundleParam(); // user searches for a certain bundle $bundles = $this->service->setProjectPath($path)->getBundles($this->getTypeParam(), $this->getBundleParam()); $this->out("Located project folder: {$path->get()}\n"); if (is_dir($path->get()) === false) { throw new \Exception("No project found at {$pathArg}"); } $tbl = new ConsoleTable(); $tbl->setHeaders(array('S', 'Id', 'Version', 'Author', 'Description')); foreach ($bundles as $bundle) { if (isset($bundle['hide']) && $bundle['hide'] == true) { continue; } $tbl->addRow(array($this->service->getRegistryContainer()->isInstalled($bundle['id']) ? 'i' : 'p', $bundle['id'], $bundle['version'], $bundle['author'], $bundle['description'])); } if (strlen($que)) { // hi-light search results $callback = array($this, 'highlightSearchTerm'); $tbl->addFilter(1, $callback); $this->out(sprintf("Search bundles having \"%s\"..", $que)); } $tbl->setAlign(3, CONSOLE_TABLE_ALIGN_CENTER); $this->out($tbl->getTable()); }
/** * テキストテーブル文字列の取得 * * 文字列でテーブルを描画します。 * * @param array $data * * @return string */ private function _getTextTable($data) { if (!$data) { return ''; } $table = new Console_Table(); $table->setAlign(0, CONSOLE_TABLE_ALIGN_LEFT); $data = $this->isList($data) !== true ? array($data) : $data; $table->setHeaders(array_keys($data[0])); foreach ($data as $row) { $table->addRow($row); } $result = $table->getTable(); return $result; }