From 1769c365499c0abc1f9c7c723bb497393dcc7fc9 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Tue, 28 Aug 2012 13:24:55 -0400
Subject: [PATCH] Renamed VuFind\CLI module to VuFindConsole for cleaner
 layout.  Changed return value for expire_searches.php so that "no searches
 were found to delete" is a success rather than a failure.

---
 config/application.config.php                     |  2 +-
 module/VuFind/CLI/config/module.config.php        | 14 --------------
 module/{VuFind/CLI => VuFindConsole}/Module.php   | 15 +++++++++------
 module/VuFindConsole/config/module.config.php     | 14 ++++++++++++++
 .../VuFindConsole}/Controller/AbstractBase.php    |  2 +-
 .../Controller/HarvestController.php              |  2 +-
 .../Controller/ImportController.php               |  2 +-
 .../VuFindConsole}/Controller/UtilController.php  |  4 ++--
 .../VuFindConsole}/Mvc/Router/ConsoleRouter.php   |  2 +-
 9 files changed, 30 insertions(+), 27 deletions(-)
 delete mode 100644 module/VuFind/CLI/config/module.config.php
 rename module/{VuFind/CLI => VuFindConsole}/Module.php (65%)
 create mode 100644 module/VuFindConsole/config/module.config.php
 rename module/{VuFind/src/VuFind/CLI => VuFindConsole/src/VuFindConsole}/Controller/AbstractBase.php (98%)
 rename module/{VuFind/src/VuFind/CLI => VuFindConsole/src/VuFindConsole}/Controller/HarvestController.php (99%)
 rename module/{VuFind/src/VuFind/CLI => VuFindConsole/src/VuFindConsole}/Controller/ImportController.php (99%)
 rename module/{VuFind/src/VuFind/CLI => VuFindConsole/src/VuFindConsole}/Controller/UtilController.php (99%)
 rename module/{VuFind/src/VuFind => VuFindConsole/src/VuFindConsole}/Mvc/Router/ConsoleRouter.php (99%)

diff --git a/config/application.config.php b/config/application.config.php
index 183a9ebc333..03ad5f13e44 100644
--- a/config/application.config.php
+++ b/config/application.config.php
@@ -21,6 +21,6 @@ $config = array(
     ),
 );
 if (PHP_SAPI == 'cli' && !defined('VUFIND_PHPUNIT_RUNNING')) {
-    $config['modules'][] = 'VuFind\\CLI';
+    $config['modules'][] = 'VuFindConsole';
 }
 return $config;
\ No newline at end of file
diff --git a/module/VuFind/CLI/config/module.config.php b/module/VuFind/CLI/config/module.config.php
deleted file mode 100644
index acbcbe2c41c..00000000000
--- a/module/VuFind/CLI/config/module.config.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-namespace VuFind\CLI\Module\Configuration;
-
-$config = array(
-    'controllers' => array(
-        'invokables' => array(
-            'harvest' => 'VuFind\CLI\Controller\HarvestController',
-            'import' => 'VuFind\CLI\Controller\ImportController',
-            'util' => 'VuFind\CLI\Controller\UtilController',
-        ),
-    ),
-);
-
-return $config;
\ No newline at end of file
diff --git a/module/VuFind/CLI/Module.php b/module/VuFindConsole/Module.php
similarity index 65%
rename from module/VuFind/CLI/Module.php
rename to module/VuFindConsole/Module.php
index a853bec7e7f..4e51ee00d47 100644
--- a/module/VuFind/CLI/Module.php
+++ b/module/VuFindConsole/Module.php
@@ -1,7 +1,7 @@
 <?php
 
-namespace VuFind\CLI;
-use VuFind\Mvc\Router\ConsoleRouter,
+namespace VuFindConsole;
+use VuFindConsole\Mvc\Router\ConsoleRouter,
     Zend\ModuleManager\ModuleManager, Zend\Mvc\MvcEvent;
 
 class Module
@@ -13,10 +13,13 @@ class Module
 
     public function getAutoloaderConfig()
     {
-        // No extra configuration necessary; since this module uses a subset of the
-        // VuFind namespace, its library code is in the main src area of the VuFind
-        // module.
-        return array();
+        return array(
+            'Zend\Loader\StandardAutoloader' => array(
+                'namespaces' => array(
+                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
+                ),
+            ),
+        );
     }
 
     public function init(ModuleManager $m)
diff --git a/module/VuFindConsole/config/module.config.php b/module/VuFindConsole/config/module.config.php
new file mode 100644
index 00000000000..546a9a74eb6
--- /dev/null
+++ b/module/VuFindConsole/config/module.config.php
@@ -0,0 +1,14 @@
+<?php
+namespace VuFindConsole\Module\Configuration;
+
+$config = array(
+    'controllers' => array(
+        'invokables' => array(
+            'harvest' => 'VuFindConsole\Controller\HarvestController',
+            'import' => 'VuFindConsole\Controller\ImportController',
+            'util' => 'VuFindConsole\Controller\UtilController',
+        ),
+    ),
+);
+
+return $config;
\ No newline at end of file
diff --git a/module/VuFind/src/VuFind/CLI/Controller/AbstractBase.php b/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php
similarity index 98%
rename from module/VuFind/src/VuFind/CLI/Controller/AbstractBase.php
rename to module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php
index 7bcea077c88..e6fcac5a2a3 100644
--- a/module/VuFind/src/VuFind/CLI/Controller/AbstractBase.php
+++ b/module/VuFindConsole/src/VuFindConsole/Controller/AbstractBase.php
@@ -26,7 +26,7 @@
  * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
  * @link     http://vufind.org/wiki/building_a_recommendations_module Wiki
  */
-namespace VuFind\CLI\Controller;
+namespace VuFindConsole\Controller;
 use Zend\Console\Console, Zend\Console\Getopt,
     Zend\Mvc\Controller\AbstractActionController;
 
diff --git a/module/VuFind/src/VuFind/CLI/Controller/HarvestController.php b/module/VuFindConsole/src/VuFindConsole/Controller/HarvestController.php
similarity index 99%
rename from module/VuFind/src/VuFind/CLI/Controller/HarvestController.php
rename to module/VuFindConsole/src/VuFindConsole/Controller/HarvestController.php
index ceacd216196..67c11bb21c7 100644
--- a/module/VuFind/src/VuFind/CLI/Controller/HarvestController.php
+++ b/module/VuFindConsole/src/VuFindConsole/Controller/HarvestController.php
@@ -25,7 +25,7 @@
  * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
  * @link     http://vufind.org/wiki/building_a_recommendations_module Wiki
  */
-namespace VuFind\CLI\Controller;
+namespace VuFindConsole\Controller;
 use VuFind\Config\Reader as ConfigReader, VuFind\Harvester\NAF, VuFind\Harvester\OAI,
     Zend\Console\Console;
 
diff --git a/module/VuFind/src/VuFind/CLI/Controller/ImportController.php b/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php
similarity index 99%
rename from module/VuFind/src/VuFind/CLI/Controller/ImportController.php
rename to module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php
index caa4042ae31..32d9edb0c1b 100644
--- a/module/VuFind/src/VuFind/CLI/Controller/ImportController.php
+++ b/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php
@@ -25,7 +25,7 @@
  * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
  * @link     http://vufind.org/wiki/building_a_recommendations_module Wiki
  */
-namespace VuFind\CLI\Controller;
+namespace VuFindConsole\Controller;
 use VuFind\XSLT\Importer, Zend\Console\Console;
 
 /**
diff --git a/module/VuFind/src/VuFind/CLI/Controller/UtilController.php b/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php
similarity index 99%
rename from module/VuFind/src/VuFind/CLI/Controller/UtilController.php
rename to module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php
index d6d6b9fbf3c..ec346a08469 100644
--- a/module/VuFind/src/VuFind/CLI/Controller/UtilController.php
+++ b/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php
@@ -25,7 +25,7 @@
  * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
  * @link     http://vufind.org/wiki/building_a_recommendations_module Wiki
  */
-namespace VuFind\CLI\Controller;
+namespace VuFindConsole\Controller;
 use File_MARC, File_MARCXML, VuFind\Connection\Manager as ConnectionManager,
     VuFind\Db\Table\Search as SearchTable, VuFind\Sitemap, Zend\Console\Console;
 
@@ -240,7 +240,7 @@ class UtilController extends AbstractBase
         $query = $search->getExpiredQuery($daysOld);
         if (($count = count($search->select($query))) == 0) {
             Console::writeLine("No expired searches to delete.");
-            return $this->getFailureResponse();
+            return $this->getSuccessResponse();
         }
         $search->delete($query);
         Console::writeLine("{$count} expired searches deleted.");
diff --git a/module/VuFind/src/VuFind/Mvc/Router/ConsoleRouter.php b/module/VuFindConsole/src/VuFindConsole/Mvc/Router/ConsoleRouter.php
similarity index 99%
rename from module/VuFind/src/VuFind/Mvc/Router/ConsoleRouter.php
rename to module/VuFindConsole/src/VuFindConsole/Mvc/Router/ConsoleRouter.php
index e8a84609e79..a45764bd1e4 100644
--- a/module/VuFind/src/VuFind/Mvc/Router/ConsoleRouter.php
+++ b/module/VuFindConsole/src/VuFindConsole/Mvc/Router/ConsoleRouter.php
@@ -25,7 +25,7 @@
  * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
  * @link     http://vufind.org   Main Site
  */
-namespace VuFind\Mvc\Router;
+namespace VuFindConsole\Mvc\Router;
 use Zend\Mvc\Router\Http\RouteMatch, Zend\Mvc\Router\RouteStackInterface,
     Zend\Stdlib\RequestInterface as Request;
 
-- 
GitLab