Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (36 sloc) 1.25 KB
<?php
/**
* @author Patsura Dmitry https://github.com/ovr <talk@dmtry.me>
*/
namespace Api;
use Phalcon\DiInterface;
use Phalcony\Rest\Dispatcher;
class Module implements \Phalcon\Mvc\ModuleDefinitionInterface
{
public function registerAutoloaders(DiInterface $dependencyInjector = null)
{
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(array(
'Api\Controller' => APPLICATION_PATH . '/modules/api/controllers/',
'Api\Model' => APPLICATION_PATH . '/modules/api/models/',
));
$loader->register();
}
public function registerServices(DiInterface $di = null)
{
$dispatcher = new Dispatcher();
$dispatcher->setDI($di);
$dispatcher->setDefaultNamespace('Api\Controller');
$dispatcher->setExceptionPath(array(
'namespace' => 'Api\Controller',
'module' => 'api',
'controller' => 'index',
'action' => 'exception'
));
$di->set('dispatcher', $dispatcher);
/** @var \Phalcon\Http\ResponseInterface $response */
$response = $di->get('response');
$response->setHeader('Access-Control-Allow-Origin', '*')
->setContentType('application/json', 'utf-8');
}
}
You can’t perform that action at this time.