/** * Export all clients */ public function exportAction() { $request = $this->getRequest(); $directory = $request->getParam('directory'); $validate = $request->getParam('validate') || $request->getParam('v'); if (!is_dir($directory) or !is_writable($directory)) { $model = new \Zend\View\Model\ConsoleModel(); $model->setErrorLevel(10); $model->setResult("Directory '{$directory}' does not exist or is not writable.\n"); return $model; } $clients = $this->getServiceLocator()->get('Model\\Client\\ClientManager')->getClients(null, 'ClientId'); foreach ($clients as $client) { $id = $client['ClientId']; $this->console->writeLine("Exporting {$id}"); $document = $client->toDomDocument(); $document->save($directory . '/' . $document->getFilename()); if ($validate and !$document->isValid()) { $model = new \Zend\View\Model\ConsoleModel(); $model->setErrorLevel(11); $model->setResult("Validation failed for {$id}.\n"); return $model; } } }
/** * Process render all assets action */ public function renderAssetsAction() { //Retrieve configuration $aConfiguration = $this->getServiceLocator()->get('Config'); if (!isset($aConfiguration['assets_bundle'])) { $oView = new \Zend\View\Model\ConsoleModel(); $oView->setErrorLevel(1); return $oView->setResult('AssetsBundle configuration is undefined' . PHP_EOL); } $this->getServiceLocator()->get('AssetsBundleToolsService')->renderAllAssets(); }
public function loadBrowscapIniAction() { //Retrieve configuration $aConfiguration = $this->getServiceLocator()->get('Config'); if (!isset($aConfiguration['zf2_browscap'])) { $oView = new \Zend\View\Model\ConsoleModel(); $oView->setErrorLevel(1); return $oView->setResult('ZF2 Browscap configuration is undefined' . PHP_EOL); } $aConfiguration = $aConfiguration['zf2_browscap']; $oServiceLocator = $this->getServiceLocator(); $oConsole = $this->getServiceLocator()->get('console'); //Initialize Browscap service $oBrowscapService = $oServiceLocator->get('BrowscapService'); if ($oBrowscapService->getAllowsNativeGetBrowser() && $oBrowscapService->canUseNativeGetBrowser()) { $oPrompt = new \Zend\Console\Prompt\Confirm('Native function "get_browser" is available, it is useless to load "browscap.ini" file. Continue anyway ?', 'y', 'n'); $oPrompt->setConsole($oConsole); if (!$oPrompt->show()) { $oConsole->writeLine(); $oConsole->writeLine('"browscap.ini" load canceled', \Zend\Console\ColorInterface::LIGHT_RED); $oConsole->writeLine(); return; } } //Start process $oConsole->writeLine(''); $oConsole->writeLine('======================================================================', \Zend\Console\ColorInterface::GRAY); $oConsole->writeLine('Load "browscap.ini" file from "' . $oBrowscapService->getBrowscapIniPath() . '"', \Zend\Console\ColorInterface::GREEN); $oConsole->writeLine('======================================================================', \Zend\Console\ColorInterface::GRAY); $oConsole->writeLine(''); $oBrowscapService->loadBrowscapIni(); $oConsole->writeLine(''); $oConsole->writeLine('---------------', \Zend\Console\ColorInterface::GRAY); $oConsole->writeLine('"Browscap.ini" file loaded', \Zend\Console\ColorInterface::GREEN); $oConsole->writeLine(''); }
/** * @param string $sMessage * @return \Zend\View\Model\ConsoleModel */ private function sendError($sMessage) { $oView = new \Zend\View\Model\ConsoleModel(); $oView->setErrorLevel(2); return $oView->setResult($sMessage . PHP_EOL); }