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(''); }
} if (empty($sCurrentModuleName)) { throw new \InvalidArgumentException('"' . $sModuleClassPath . '" does not provide a "Module" class'); } //Check "dir" option if (!($sDeployDirPath = $oGetopt->getOption('dir'))) { throw new \InvalidArgumentException('Deploy directory path is empty'); } if (!is_string($sDeployDirPath)) { throw new \InvalidArgumentException('Deploy directory path expects string, "' . gettype($sDeployDirPath) . '" given'); } //Create deploy dir if needed if (!is_dir($sDeployDirPath)) { $oPrompt = new \Zend\Console\Prompt\Confirm('Deploy dir "' . $sDeployDirPath . '" does not exist, create it (y/n) ?', 'y', 'n'); $oPrompt->setConsole($oConsole); if ($oPrompt->show()) { if (!@mkdir($sDeployDirPath)) { $aLastError = error_get_last(); throw new \InvalidArgumentException('Deploy directory "' . $sDeployDirPath . '" can\'t be created - ' . $aLastError['message']); } } else { $oConsole->writeLine(PHP_EOL . 'Deploying module "' . $sCurrentModuleName . '" aborted' . PHP_EOL, \Zend\Console\ColorInterface::LIGHT_RED); exit(0); } } $sDeployDirPath = realpath($sDeployDirPath); if ($bVerbose) { $oConsole->writeLine(PHP_EOL . '### Deploy module "' . $sCurrentModuleName . '" into "' . $sDeployDirPath . '" ###', \Zend\Console\ColorInterface::GREEN); } /** * Assert that ZendSkeletonApplication mandatory files / dir exist