static function factory($cn, \cherry\Mvc\Request $req) { \Cherry\Log(\Cherry\LOG_DEBUG, "Invoking controller: %s", $cn); // Check the namespace $app = \cherry\Application::getInstance(); $cfg = $app->getConfiguration('application', 'application'); $ns = $cfg['namespace']; if (substr($cn, 0, strlen($ns)) == $ns) { $cpath = explode('\\', strToLower($cn)); $fpath = CHERRY_APP . _DS_ . 'application' . _DS_ . join(_DS_, array_slice($cpath, 2)); } else { $fpath = strToLower($cn); } $fpath = str_replace('\\', DIRECTORY_SEPARATOR, $fpath); if (substr($fpath, -10, 10) == 'controller') { $fpath = substr($fpath, 0, strlen($fpath) - 10); } $fpath .= '.php'; if (file_exists($fpath)) { require_once $fpath; $cobj = new $cn($req); return $cobj; } else { throw new \Exception("Could not include file; " . $fpath); } }
function __construct() { parent::__construct(); App::config()->addConfiguration(APP_ROOT . _DS_ . 'config.json'); App::extend('router', new \Cherry\Mvc\Router()); App::extend('server', new \Cherry\Mvc\Server()); }
public function __construct() { $this->setLogTarget([]); parent::__construct(); $this->loadConfig(); App::extend('router', new \Cherry\Mvc\Router()); App::extend('server', new \Cherry\Mvc\Server()); }
public function write($str) { static $con; if (!$con) { $con = Console::getAdapter(); } $args = func_get_args(); call_user_func_array([$con, 'write'], $args); parent::write(call_user_func_array('sprintf', $args)); }
public function createArtWork(Application $app) { return $app['twig']->render('Admin/artWorkCreate.html.twig', ['form' => $app->form([], [], ArtWorkType::class)->getForm()->createView()]); }