コード例 #1
0
ファイル: search.php プロジェクト: bix0r/Stjornvisi
//
$counter = 0;
$articleService = new Stjornvisi\Service\Article($pdo);
$articles = $articleService->fetchAll();
$adapter = new Zend\Progressbar\Adapter\Console();
echo "\nIndexing News entries\n";
$progressBar = new Zend\ProgressBar\ProgressBar($adapter, $counter, count($articles));
$i = new Stjornvisi\Search\Index\Article();
foreach ($articles as $item) {
    $i->index($item, $index);
    $progressBar->update(++$counter);
}
$index->commit();
$progressBar->finish();
//Group
//	index group entries.
//
$counter = 0;
$groupService = new Stjornvisi\Service\Group($pdo);
$groups = $groupService->fetchAll();
$adapter = new Zend\Progressbar\Adapter\Console();
echo "\nIndexing Group entries\n";
$progressBar = new Zend\ProgressBar\ProgressBar($adapter, $counter, count($groups));
$i = new Stjornvisi\Search\Index\Group();
foreach ($groups as $item) {
    $i->index($item, $index);
    $progressBar->update(++$counter);
}
$index->commit();
$progressBar->finish();
コード例 #2
0
     //Copy ZendSkeletonApplication files into the deploy directory
     $aFiles = scandir($sTempZendSkeletonApplication);
     if ($bVerbose) {
         $oConsole->writeLine('    - Copy "ZendSkeletonApplication" into deploy directory "' . $sDeployDirPath . '"', \Zend\Console\ColorInterface::GRAY);
         $oProgressBar = new Zend\ProgressBar\ProgressBar(new \Zend\ProgressBar\Adapter\Console(array('width' => $oConsole->getWidth())), 0, count($aFiles));
     }
     foreach ($aFiles as $iKey => $sFileName) {
         if ($bVerbose) {
             $oProgressBar->update($iKey + 1);
         }
         if ($sFileName != '.' && $sFileName != '..') {
             rcopy($sTempZendSkeletonApplication . DIRECTORY_SEPARATOR . $sFileName, $sDeployDirPath . DIRECTORY_SEPARATOR . $sFileName);
         }
     }
     if ($bVerbose) {
         $oProgressBar->finish();
     }
     emptyDir($sTempDirPath);
     if (!rmdir($sTempDirPath)) {
         throw new \RuntimeException('Unable to remove directory "' . $sTempDirPath . '"');
     }
 } elseif ($bVerbose) {
     $oConsole->writeLine(PHP_EOL . '  * "ZendSkeletonApplication" is already loaded', \Zend\Console\ColorInterface::LIGHT_MAGENTA);
 }
 //Adapt ZendSkeletonApplication autoloader
 if ($bVerbose) {
     $oConsole->writeLine(PHP_EOL . '  * Adapt "ZendSkeletonApplication" init_autoloader', \Zend\Console\ColorInterface::LIGHT_MAGENTA);
 }
 //Add autoloading module
 if (!($sInitAutoloaderContents = file_get_contents($sInitAutoloaderPath = $sDeployDirPath . DIRECTORY_SEPARATOR . 'init_autoloader.php'))) {
     throw new \RuntimeException('An error occurred while getting contents from file "' . $sInitAutoloaderPath . '"');