*/ class Application extends SilexApplication { /** * @var string */ protected $rootDir; /* * Init the application. */ public function init() { Propel::init($this->getRootDir().'etc/propel/config.php'); $users = json_decode(file_get_contents($this->getRootDir().'/etc/security/users.json'), true); $this->register(new SecurityServiceProvider(), [ 'security.firewalls' => [ 'api' => [ 'pattern' => '^/api', 'http' => true, 'users' => $users, ], ], ]); $this['sms.validator'] = new SmsValidator(); $this['sms.factory'] = new SmsFactory(); $this->error(function (\Exception $e, Request $request, $code) { return $this->json([ 'status' => false, 'code' => $code, 'message' => $e->getMessage(), ]); }); return $this; } /* * Set the value of "rootDir". * * @param string $rootDir * * @return */ public function setRootDir($rootDir) { $this->rootDir = $rootDir; return $this; } /* * Get the value of "rootDir". * * @return string */ public function getRootDir() { return $this->rootDir; } public function addController(Controller $controller) { $controller->setApp($this); $controller->registerRoutes(); return $this; } }