Skip to content

Commit

Permalink
Dev Added new console launcher that loads custom application class.
Browse files Browse the repository at this point in the history
Dev Added custom application class that implements some required functions for use in LS.
  • Loading branch information
SamMousa committed Jan 22, 2013
1 parent e3e400e commit cc08017
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
48 changes: 48 additions & 0 deletions application/commands/console.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/php
<?php
/*
* LimeSurvey (tm)
* Copyright (C) 2011 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
*
* File edited by Sam Mousa for Marcel Minke.
* This loader bypasses the default Yii loader and loads a custom console class instead.
*/
if (!isset($argv[0])) die();
define('BASEPATH','.');

// Load configuration.
$sCurrentDir=dirname(__FILE__);
$config=require (dirname($sCurrentDir).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');
$core = dirname($sCurrentDir) . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR;
unset ($config['defaultController']);
unset ($config['config']);



// fix for fcgi
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));

defined('YII_DEBUG') or define('YII_DEBUG',true);

require_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR . 'yii.php');

if(isset($config))
{
require_once($core . 'ConsoleApplication.php');
$app=Yii::createApplication('ConsoleApplication', $config);
define('APPPATH', Yii::app()->getBasePath() . DIRECTORY_SEPARATOR);
$app->commandRunner->addCommands(YII_PATH.'/cli/commands');
$env=@getenv('YII_CONSOLE_COMMANDS');
if(!empty($env))
$app->commandRunner->addCommands($env);
}
$app->run();
?>
37 changes: 37 additions & 0 deletions application/core/ConsoleApplication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php


class ConsoleApplication extends CConsoleApplication
{

public $lang = null;

public function __construct($config = null) {
parent::__construct($config);
}
/**
* This function is implemented since em_core_manager incorrectly requires
* it to create urls.
*/
public function getController()
{
return $this;

}


/**
* Returns a config variable from the config
*
* @access public
* @param string $name
* @return mixed
*/
public function getConfig($name)
{
return isset($this->$name) ? $this->$name : false;
}


}
?>

0 comments on commit cc08017

Please sign in to comment.