diff --git a/app/library/Application.php b/app/library/Services.php similarity index 93% rename from app/library/Application.php rename to app/library/Services.php index a517fb7..2dea742 100644 --- a/app/library/Application.php +++ b/app/library/Services.php @@ -2,7 +2,7 @@ namespace Httpcb; -use Phalcon\Di\DiInterface, +use Phalcon\DiInterface, Phalcon\Di\FactoryDefault as DiDefault, Phalcon\Config\Adapter\Yaml as Config, Phalcon\Mvc\View, @@ -32,25 +32,12 @@ use App\Listener\AclListener, App\Listener\DispatchListener, App\Listener\ActivityLog; - -class Application extends \Phalcon\Mvc\Application +class Services extends DiDefault { - public function __construct(\Phalcon\DiInterface $di = null) + public function __construct() { - if ($di === null) { - $di = new DiDefault(); - } + parent::__construct(); - parent::__construct($di); - } - - /** - * Bootstrap the application (register services) - * - * @return Application - */ - public function bootstrap() - { $reflection = new \ReflectionObject($this); $methods = $reflection->getMethods(\ReflectionMethod::IS_PROTECTED); @@ -58,28 +45,13 @@ class Application extends \Phalcon\Mvc\Application if (substr($method->getName(),0, 11) == '_initShared') { $service = lcfirst(substr($method->getName(), 11)); - $this->di->setShared($service, $method->getClosure($this)); + $this->setShared($service, $method->getClosure($this)); } else if (substr($method->getName(),0, 5) == '_init') { $service = lcfirst(substr($method->getName(), 5)); - $this->di->set($service, $method->getClosure($this)); + $this->set($service, $method->getClosure($this)); } } - - return $this; - } - - /** - * @return string - */ - public function run() - { - return $this->handle()->getContent(); - } - - public function get($service, $parameters = null) - { - return $this->di->get($service, $parameters); } protected function _initSharedConfig() diff --git a/public/index.php b/public/index.php index f87dc1c..6862c0a 100644 --- a/public/index.php +++ b/public/index.php @@ -19,5 +19,5 @@ include APP_PATH . "/app/config/loader.php"; /** * Handle the request */ -$app = new Httpcb\Application(); -echo $app->bootstrap()->run(); +$app = new Phalcon\Mvc\Application(new Httpcb\Services()); +echo $app->handle()->getContent();