From ef99a26635925b6602f1bafa2b3d34ba9ece4f79 Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Wed, 26 Jun 2013 13:32:17 +0400 Subject: [PATCH] Modife CliController. --- app/CliController.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/CliController.php b/app/CliController.php index 33bd2ce..30e046c 100644 --- a/app/CliController.php +++ b/app/CliController.php @@ -55,13 +55,19 @@ class CliController * @param iCli $cli_class * @throws ErrorException */ - public function execute($cli_class) + public function execute($cli) { try { - if (!in_array('iCli', class_implements($cli_class))) { - throw new ErrorException('Runner "' . get_class($cli_class) . '" need implement of "iCli" interface.'); + if (is_string($cli)) { + if (!class_exists($cli)) { + throw new GeneralException('Action class "' . $cli . '" not found.'); + } + $cli = new $cli; + } + if (!in_array('iCli', class_implements($cli))) { + throw new ErrorException('Runner "' . get_class($cli) . '" need implement of "iCli" interface.'); } - $cli_class->run(); + $cli->run(); if (Config::get('PROFILER')) { $profile = Profiler::getInstance()->getCli(); if (Config::get('LOGGING')) {