Skip to content

Commit

Permalink
Refs #4059 Converting updates files to use namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed Oct 8, 2013
1 parent ded987a commit b738433
Show file tree
Hide file tree
Showing 64 changed files with 298 additions and 103 deletions.
11 changes: 6 additions & 5 deletions core/Filechecks.php
Expand Up @@ -112,13 +112,14 @@ public static function getFileIntegrityInformation()
$messages[] = true;

$manifest = PIWIK_INCLUDE_PATH . '/config/manifest.inc.php';
if (!file_exists($manifest)) {
$suffix = " If you are deploying Piwik from Git, this message is normal.";
$messages[] = Piwik_Translate('General_WarningFileIntegrityNoManifest') . $suffix;
return $messages;
if (file_exists($manifest)) {
require_once $manifest;
}

require_once $manifest;
if(!class_exists('\\Piwik\\Manifest')){
$messages[] = Piwik_Translate('General_WarningFileIntegrityNoManifest') . " If you are deploying Piwik from Git, this message is normal.";
return $messages;
}

$files = \Piwik\Manifest::$files;

Expand Down
70 changes: 38 additions & 32 deletions core/FrontController.php
Expand Up @@ -37,36 +37,8 @@ class FrontController

private static $instance = null;

/**
* returns singleton
*
* @return \Piwik\FrontController
*/
public static function getInstance()
protected function prepareDispatch($module, $action, $parameters)
{
if (self::$instance == null) {
self::$instance = new self;
}
return self::$instance;
}

/**
* Dispatches the request to the right plugin and executes the requested action on the plugin controller.
*
* @throws Exception|\Piwik\PluginDeactivatedException in case the plugin doesn't exist, the action doesn't exist, there is not enough permission, etc.
*
* @param string $module
* @param string $action
* @param array $parameters
* @return void|mixed The returned value of the calls, often nothing as the module print but don't return data
* @see fetchDispatch()
*/
public function dispatch($module = null, $action = null, $parameters = null)
{
if (self::$enableDispatch === false) {
return;
}

if (is_null($module)) {
$defaultModule = 'CoreHome';
$module = Common::getRequestVar('module', $defaultModule, 'string');
Expand Down Expand Up @@ -94,7 +66,7 @@ public function dispatch($module = null, $action = null, $parameters = null)
throw new PluginDeactivatedException($module);
}

$controllerClassName = $this->getClassNameController( $module );
$controllerClassName = $this->getClassNameController($module);

// FrontController's autoloader
if (!class_exists($controllerClassName, false)) {
Expand All @@ -115,15 +87,49 @@ public function dispatch($module = null, $action = null, $parameters = null)
if (!is_callable(array($controller, $action))) {
throw new Exception("Action '$action' not found in the controller '$controllerClassName'.");
}
return array($module, $action, $parameters, $controller);
}

/**
* returns singleton
*
* @return \Piwik\FrontController
*/
public static function getInstance()
{
if (self::$instance == null) {
self::$instance = new self;
}
return self::$instance;
}

/**
* Dispatches the request to the right plugin and executes the requested action on the plugin controller.
*
* @throws Exception|\Piwik\PluginDeactivatedException in case the plugin doesn't exist, the action doesn't exist, there is not enough permission, etc.
*
* @param string $module
* @param string $action
* @param array $parameters
* @return void|mixed The returned value of the calls, often nothing as the module print but don't return data
* @see fetchDispatch()
*/
public function dispatch($module = null, $action = null, $parameters = null)
{
if (self::$enableDispatch === false) {
return;
}

// list($module, $action, $parameters, $controller)
$params = $this->prepareDispatch($module, $action, $parameters);

// Generic hook that plugins can use to modify any input to the function,
// or even change the plugin being called
$params = array($controller, $action, $parameters);
Piwik_PostEvent('Request.dispatch', $params);
Piwik_PostEvent(sprintf('Controller.%s.%s', $module, $action), array($parameters));

try {
$result = call_user_func_array(array($params[0], $params[1]), $params[2]);
$result = call_user_func_array(array($params[3], $params[1]), $params[2]);
Piwik_PostEvent(sprintf('Controller.%s.%s.end', $module, $action), array(&$result, $parameters));
Piwik_PostEvent('Request.dispatch.end', array(&$result, $parameters));

Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.2.10.php
Expand Up @@ -8,6 +8,9 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Common;
use Piwik\Filesystem;
use Piwik\Updater;
Expand All @@ -16,7 +19,7 @@
/**
* @package Updates
*/
class Piwik_Updates_0_2_10 extends Updates
class Updates_0_2_10 extends Updates
{
static function getSql($schema = 'Myisam')
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.2.12.php
Expand Up @@ -8,14 +8,17 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;

/**
* @package Updates
*/
class Piwik_Updates_0_2_12 extends Updates
class Updates_0_2_12 extends Updates
{
static function getSql($schema = 'Myisam')
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.2.13.php
Expand Up @@ -8,14 +8,17 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;

/**
* @package Updates
*/
class Piwik_Updates_0_2_13 extends Updates
class Updates_0_2_13 extends Updates
{
static function getSql($schema = 'Myisam')
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.2.24.php
Expand Up @@ -8,14 +8,17 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;

/**
* @package Updates
*/
class Piwik_Updates_0_2_24 extends Updates
class Updates_0_2_24 extends Updates
{
static function getSql($schema = 'Myisam')
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.2.27.php
Expand Up @@ -8,6 +8,9 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Common;
use Piwik\DbHelper;
use Piwik\Updater;
Expand All @@ -16,7 +19,7 @@
/**
* @package Updates
*/
class Piwik_Updates_0_2_27 extends Updates
class Updates_0_2_27 extends Updates
{
static function getSql($schema = 'Myisam')
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.2.32.php
Expand Up @@ -8,14 +8,17 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;

/**
* @package Updates
*/
class Piwik_Updates_0_2_32 extends Updates
class Updates_0_2_32 extends Updates
{
static function getSql($schema = 'Myisam')
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.2.33.php
Expand Up @@ -8,6 +8,9 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Common;
use Piwik\DbHelper;
use Piwik\Updater;
Expand All @@ -16,7 +19,7 @@
/**
* @package Updates
*/
class Piwik_Updates_0_2_33 extends Updates
class Updates_0_2_33 extends Updates
{
static function getSql($schema = 'Myisam')
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.2.34.php
Expand Up @@ -8,6 +8,9 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Piwik;
use Piwik\Plugins\SitesManager\API;
use Piwik\Tracker\Cache;
Expand All @@ -16,7 +19,7 @@
/**
* @package Updates
*/
class Piwik_Updates_0_2_34 extends Updates
class Updates_0_2_34 extends Updates
{
static function update($schema = 'Myisam')
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.2.35.php
Expand Up @@ -8,14 +8,17 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;

/**
* @package Updates
*/
class Piwik_Updates_0_2_35 extends Updates
class Updates_0_2_35 extends Updates
{
static function getSql($schema = 'Myisam')
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.2.37.php
Expand Up @@ -8,14 +8,17 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;

/**
* @package Updates
*/
class Piwik_Updates_0_2_37 extends Updates
class Updates_0_2_37 extends Updates
{
static function getSql($schema = 'Myisam')
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.4.1.php
Expand Up @@ -8,14 +8,17 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;

/**
* @package Updates
*/
class Piwik_Updates_0_4_1 extends Updates
class Updates_0_4_1 extends Updates
{
static function getSql($schema = 'Myisam')
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.4.2.php
Expand Up @@ -8,14 +8,17 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;

/**
* @package Updates
*/
class Piwik_Updates_0_4_2 extends Updates
class Updates_0_4_2 extends Updates
{
static function getSql($schema = 'Myisam')
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.4.4.php
Expand Up @@ -8,12 +8,15 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Updates;

/**
* @package Updates
*/
class Piwik_Updates_0_4_4 extends Updates
class Updates_0_4_4 extends Updates
{
static function update()
{
Expand Down
5 changes: 4 additions & 1 deletion core/Updates/0.4.php
Expand Up @@ -8,14 +8,17 @@
* @category Piwik
* @package Updates
*/

namespace Piwik\Updates;

use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;

/**
* @package Updates
*/
class Piwik_Updates_0_4 extends Updates
class Updates_0_4 extends Updates
{
static function getSql($schema = 'Myisam')
{
Expand Down

0 comments on commit b738433

Please sign in to comment.