Skip to content

Instantly share code, notes, and snippets.

@splittingred
Created June 10, 2011 14:47
Show Gist options
  • Save splittingred/1018976 to your computer and use it in GitHub Desktop.
Save splittingred/1018976 to your computer and use it in GitHub Desktop.
base Resource manager controller class
<?php
abstract class ResourceManagerController extends modManagerController {
public static function getInstance(modX &$modx,$className,array $config = array()) {
if (!empty($_REQUEST['class_key'])) {
$resourceClass = str_replace(array('../','..','/','\\'),'',$_REQUEST['class_key']);
$delegateView = $modx->call($resourceClass,'getControllerPath',array(&$modx));
$action = strtolower(str_replace(array('Resource','ManagerController'),'',$className));
$className = str_replace('mod','',$resourceClass).ucfirst($action).'ManagerController';
$controllerFile = $delegateView.$action.'.class.php';
require_once $controllerFile;
}
$controller = new $className($modx,$config);
return $controller;
}
/* ... */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment