示例#1
0
 public function initializeCli()
 {
     $paths = new Paths();
     $folder = basename($paths->getPluginRoot());
     $pluginFile = $paths->getPluginRoot() . '/' . $folder . '.php';
     if (file_exists($pluginFile)) {
         require_once $pluginFile;
     }
 }
示例#2
0
 public function getConfigData($file = null)
 {
     if (!$this->configData) {
         if (null === $file) {
             $paths = new Paths();
             $file = $paths->getPluginRoot() . '/dewdrop-config.php';
         }
         if (file_exists($file) || is_readable($file)) {
             $this->configData = (require $file);
         }
     }
     return $this->configData;
 }
示例#3
0
 /**
  * Optionally point this class at a non-standard configuration file path.
  *
  * @param string $file
  */
 public function __construct($file = null)
 {
     $paths = new Paths();
     if (!$paths->isWp()) {
         if (null === $file) {
             $file = $paths->getPluginRoot() . '/dewdrop-config.php';
         }
         if (file_exists($file) || is_readable($file)) {
             $this->data = (require $file);
         }
     } else {
         $className = '\\Dewdrop\\Bootstrap\\Wp';
         if (defined('DEWDROP_BOOTSTRAP_CLASS')) {
             $className = DEWDROP_BOOTSTRAP_CLASS;
         }
         $this->data = array('bootstrap' => $className, 'db' => array('username' => DB_USER, 'password' => DB_PASSWORD, 'host' => DB_HOST, 'name' => DB_NAME, 'type' => 'mysql'));
     }
 }
示例#4
0
 private function searchPathsForHandlers()
 {
     if ($this->pathSearchPerformed) {
         return;
     }
     $this->pathSearchPerformed = true;
     $this->searchPathForHandlers($this->systemPaths->getActivityLog(), 'ActivityLog');
     $this->searchPathForHandlers($this->systemPaths->getModels(), 'Model');
     foreach ($this->paths as $path => $namespacePrefix) {
         $this->searchPathForHandlers($path, $namespacePrefix);
     }
 }
示例#5
0
 /**
  * @param array $methodsToMock
  * @return \PHPUnit_Framework_MockObject_MockObject|\Dewdrop\Cli\Command\Dbdeploy
  */
 private function getMockCommand(array $methodsToMock = array())
 {
     /* @var $command \PHPUnit_Framework_MockObject_MockObject|\Dewdrop\Cli\Command\Dbdeploy */
     $command = $this->getMock('\\Dewdrop\\Cli\\Command\\Dbdeploy', count($methodsToMock) ? $methodsToMock : array('abort'), array($this->runner, $this->renderer));
     $env = Env::getInstance();
     $dbTypeSuffix = 'pgsql';
     if ($env instanceof WpEnv) {
         $dbTypeSuffix = 'mysql';
     }
     $command->overrideChangesetPath($env->getProjectNoun(), $this->paths->getDewdropLib() . '/tests/Dewdrop/Cli/Command/dbdeploy-test/plugin/' . $dbTypeSuffix);
     $command->overrideChangesetPath('dewdrop-test', $this->paths->getDewdropLib() . '/tests/Dewdrop/Cli/Command/dbdeploy-test/dewdrop-test/' . $dbTypeSuffix);
     $command->overrideChangesetPath('dewdrop-core', $this->paths->getDewdropLib() . '/tests/Dewdrop/Cli/Command/dbdeploy-test/dewdrop-core/');
     $command->overrideChangelogTableName('dewdrop_test_dbdeploy_changelog');
     return $command;
 }
示例#6
0
 /**
  * Instantiate all command objects.  We need them all instantiated so that
  * we can see if any has been selected for execution (i.e. the command
  * property of this object matches the command name or one of its aliases).
  *
  * @return void
  */
 protected function instantiateCommands()
 {
     foreach ($this->commandClasses as $commandClass) {
         $fullClassName = '\\Dewdrop\\Cli\\Command\\' . $commandClass;
         $this->commands[$commandClass] = new $fullClassName($this, $this->renderer);
     }
     // Add any commands found in the project's commands folder
     $commandPath = $this->paths->getCommands();
     if (is_dir($commandPath)) {
         $commands = glob($commandPath . '/*.php');
         foreach ($commands as $command) {
             $className = '\\Command\\' . basename($command, '.php');
             $this->commands[$className] = new $className($this, $this->renderer);
         }
     }
     // Add any custom commands defined in Pimple's "cli-commands" resource
     if (isset($this->pimple['cli-commands'])) {
         foreach ($this->pimple['cli-commands'] as $className) {
             $this->commands[$className] = new $className($this, $this->renderer);
         }
     }
 }
示例#7
0
 /**
  * Assuming that we can detect ZF1 is in use after bootstrapping our CLI environment,
  * we'll then start up the Application itself, bootstrap it, and do minimal front
  * controller configuration.  This allows us to get the configuration loaded, the
  * application resources in place, etc. without actually starting the dispatch cycle.
  */
 public function initializeCli()
 {
     $paths = new Paths();
     $root = $paths->getPluginRoot();
     // Define path to the parent of application/ and library/
     defined('PROJECT_ROOT') || define('PROJECT_ROOT', $root);
     defined('APPLICATION_PATH') || define('APPLICATION_PATH', PROJECT_ROOT . '/application');
     // Define application environment
     defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV'));
     if (class_exists('DeltaZend_Application')) {
         $applicationClass = 'DeltaZend_Application';
     } else {
         $applicationClass = 'Zend_Application';
     }
     /* @var $application \Zend_Application */
     $application = new $applicationClass(APPLICATION_ENV, PROJECT_ROOT . '/application/configs/application.ini');
     $application->bootstrap();
     /* @var $frontController Zend_Controller_Front */
     $bootstrap = $application->getBootstrap();
     $frontController = $bootstrap->getResource('FrontController');
     $frontController->setParam('bootstrap', $bootstrap);
 }
示例#8
0
 /**
  * Get a component object, injecting the supplied request so that we can
  * test different responses.
  *
  * @param Request $request
  * @return \Dewdrop\Admin\ComponentAbstract
  */
 public function getComponent(Request $request)
 {
     $paths = new Paths();
     $file = $paths->getAdmin() . '/' . $this->componentFolder . '/Component.php';
     $className = 'Admin\\' . $this->componentNamespace . '\\Component';
     require_once $file;
     return new $className($this->getDb(), $paths, $request);
 }
示例#9
0
 /**
  * Returns table metadata filesystem path.
  *
  * @return string
  */
 public function getTableMetadataPath()
 {
     if (null === $this->tableMetadataPath) {
         $paths = new Paths();
         $this->tableMetadataPath = $paths->getModels() . '/metadata';
     }
     return $this->tableMetadataPath;
 }