|
|
|
@ -7,8 +7,24 @@ |
|
|
|
|
* @package chamilo.services |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
// Needed to use the "entity" option in symfony forms |
|
|
|
|
use Doctrine\Common\Persistence\AbstractManagerRegistry; |
|
|
|
|
use FranMoreno\Silex\Provider\PagerfantaServiceProvider; |
|
|
|
|
use Silex\Application; |
|
|
|
|
use Silex\ServiceProviderInterface; |
|
|
|
|
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder; |
|
|
|
|
|
|
|
|
|
// Flint |
|
|
|
|
$app->register(new Flint\Provider\ConfigServiceProvider()); |
|
|
|
|
$app['root_dir'] = $app['root_sys']; |
|
|
|
|
|
|
|
|
|
$app->register(new Flint\Provider\RoutingServiceProvider(), array( |
|
|
|
|
'routing.resource' => $app['sys_config_path'].'routing.yml', |
|
|
|
|
'routing.options' => array( |
|
|
|
|
'cache_dir' => $app['debug'] == true ? null : $app['sys_temp_path'] |
|
|
|
|
//'cache_dir' => $app['sys_temp_path'] |
|
|
|
|
), |
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
// Monolog. |
|
|
|
|
if (is_writable($app['sys_temp_path'])) { |
|
|
|
@ -39,7 +55,15 @@ $app->register(new Silex\Provider\HttpCacheServiceProvider(), array( |
|
|
|
|
|
|
|
|
|
// http://symfony.com/doc/master/reference/configuration/security.html |
|
|
|
|
|
|
|
|
|
$app->register(new Silex\Provider\SecurityServiceProvider(), array( |
|
|
|
|
class SecurityServiceProvider extends \Silex\Provider\SecurityServiceProvider |
|
|
|
|
{ |
|
|
|
|
public function addFakeRoute($method, $pattern, $name) |
|
|
|
|
{ |
|
|
|
|
// Don't do anything otherwise the closures will be dumped and that leads to fatal errors. |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$app->register(new SecurityServiceProvider, array( |
|
|
|
|
'security.firewalls' => array( |
|
|
|
|
'login' => array( |
|
|
|
|
'pattern' => '^/login$', |
|
|
|
@ -63,15 +87,11 @@ $app->register(new Silex\Provider\SecurityServiceProvider(), array( |
|
|
|
|
return $app['orm.em']->getRepository('Entity\User'); |
|
|
|
|
}), |
|
|
|
|
'anonymous' => true |
|
|
|
|
),/* |
|
|
|
|
'classic' => array( |
|
|
|
|
'pattern' => '^/.*$' |
|
|
|
|
)*/ |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
// Registering Password encoder. |
|
|
|
|
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder; |
|
|
|
|
$app['security.encoder.digest'] = $app->share(function($app) { |
|
|
|
|
// use the sha1 algorithm |
|
|
|
|
// don't base64 encode the password |
|
|
|
@ -91,7 +111,14 @@ $app['security.authentication.logout_handler.admin'] = $app->share(function($app |
|
|
|
|
|
|
|
|
|
// Role hierarchy |
|
|
|
|
$app['security.role_hierarchy'] = array( |
|
|
|
|
'ROLE_ADMIN' => array('ROLE_QUESTION_MANAGER', 'ROLE_SESSION_MANAGER', 'ROLE_TEACHER', 'ROLE_ALLOWED_TO_SWITCH', 'ROLE_DIRECTOR'), |
|
|
|
|
'ROLE_ADMIN' => array( |
|
|
|
|
'ROLE_QUESTION_MANAGER', |
|
|
|
|
'ROLE_SESSION_MANAGER', |
|
|
|
|
'ROLE_TEACHER', |
|
|
|
|
'ROLE_ALLOWED_TO_SWITCH', |
|
|
|
|
'ROLE_DIRECTOR', |
|
|
|
|
'ROLE_JURY_PRESIDENT' |
|
|
|
|
), |
|
|
|
|
'ROLE_RRHH' => array('ROLE_TEACHER'), |
|
|
|
|
'ROLE_TEACHER' => array('ROLE_STUDENT'), |
|
|
|
|
'ROLE_QUESTION_MANAGER' => array('ROLE_STUDENT', 'ROLE_QUESTION_MANAGER'), |
|
|
|
@ -138,9 +165,6 @@ $app->register(new Silex\Provider\FormServiceProvider()); |
|
|
|
|
// URL generator provider |
|
|
|
|
$app->register(new Silex\Provider\UrlGeneratorServiceProvider()); |
|
|
|
|
|
|
|
|
|
// Needed to use the "entity" option in symfony forms |
|
|
|
|
use Doctrine\Common\Persistence\AbstractManagerRegistry; |
|
|
|
|
|
|
|
|
|
class ManagerRegistry extends AbstractManagerRegistry |
|
|
|
|
{ |
|
|
|
|
protected $container; |
|
|
|
@ -317,8 +341,6 @@ if (is_writable($app['sys_temp_path'])) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Pagerfanta settings (Pagination using Doctrine2, arrays, etc) |
|
|
|
|
use FranMoreno\Silex\Provider\PagerfantaServiceProvider; |
|
|
|
|
|
|
|
|
|
$app->register(new PagerfantaServiceProvider()); |
|
|
|
|
|
|
|
|
|
// Custom route params see https://github.com/franmomu/silex-pagerfanta-provider/pull/2 |
|
|
|
@ -503,7 +525,6 @@ $app->register(new ChamiloServiceProvider(), array()); |
|
|
|
|
|
|
|
|
|
// Controller as services definitions. |
|
|
|
|
|
|
|
|
|
/* @todo use Flint to manage controllers, routes */ |
|
|
|
|
|
|
|
|
|
$app['pages.controller'] = $app->share( |
|
|
|
|
function () use ($app) { |
|
|
|
|