123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608 |
- <?php
- use Silex\Application;
- use Silex\ServiceProviderInterface;
- if (is_writable($app['sys_temp_path'])) {
-
- $app->register(
- new Silex\Provider\MonologServiceProvider(),
- array(
- 'monolog.logfile' => $app['chamilo.log'],
- 'monolog.name' => 'chamilo',
- )
- );
- }
- $app->register(new Silex\Provider\ServiceControllerServiceProvider());
- $app->register(new Silex\Provider\ValidatorServiceProvider());
- $app->register(new Silex\Provider\TranslationServiceProvider(), array(
- 'locale' => 'es',
- 'locale_fallback' => 'es'
- ));
- use Symfony\Component\Translation\Loader\PoFileLoader;
- use Symfony\Component\Translation\Loader\MoFileLoader;
- use Symfony\Component\Finder\Finder;
- $app['translator.cache.enabled'] = true;
-
- $app->register(new Silex\Provider\FormServiceProvider());
- $app->register(new Silex\Provider\UrlGeneratorServiceProvider());
- if (isset($app['configuration']['main_database'])) {
-
- $defaultDatabaseOptions = array(
- 'db_read' => array(
- 'driver' => 'pdo_mysql',
- 'host' => $app['configuration']['db_host'],
- 'dbname' => $app['configuration']['main_database'],
- 'user' => $app['configuration']['db_user'],
- 'password' => $app['configuration']['db_password'],
- 'charset' => 'utf8',
-
- ),
- 'db_write' => array(
- 'driver' => 'pdo_mysql',
- 'host' => $app['configuration']['db_host'],
- 'dbname' => $app['configuration']['main_database'],
- 'user' => $app['configuration']['db_user'],
- 'password' => $app['configuration']['db_password'],
- 'charset' => 'utf8',
-
- ),
- );
-
- if (isset($app['configuration']['db.options'])) {
- $defaultDatabaseOptions = $app['configuration']['db.options'];
- }
- $app->register(
- new Silex\Provider\DoctrineServiceProvider(),
- array(
- 'dbs.options' => $defaultDatabaseOptions
- )
- );
- $mappings = array(
- array(
-
- 'use_simple_annotation_reader' => false,
- 'type' => 'annotation',
- 'namespace' => 'Entity',
- 'path' => api_get_path(INCLUDE_PATH).'Entity',
-
- ),
- array(
- 'use_simple_annotation_reader' => false,
- 'type' => 'annotation',
- 'namespace' => 'Gedmo',
- 'path' => api_get_path(SYS_PATH).'vendors/gedmo/doctrine-extensions/lib/Gedmo',
- )
- );
-
- $app->register(
- new Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider,
- array(
- 'orm.auto_generate_proxies' => true,
- 'orm.proxies_dir' => $app['db.orm.proxies_dir'],
-
- 'orm.ems.default' => 'db_read',
- 'orm.ems.options' => array(
- 'db_read' => array(
- 'connection' => 'db_read',
- 'mappings' => $mappings,
- ),
- 'db_write' => array(
- 'connection' => 'db_write',
- 'mappings' => $mappings,
- ),
- ),
- )
- );
- }
- $app->register(
- new Silex\Provider\TwigServiceProvider(),
- array(
- 'twig.path' => array(
- api_get_path(SYS_CODE_PATH).'template',
- api_get_path(SYS_PLUGIN_PATH)
- ),
-
- 'twig.form.templates' => array('form_div_layout.html.twig', 'default/form/form_custom_template.tpl'),
- 'twig.options' => array(
- 'debug' => $app['debug'],
- 'charset' => 'utf-8',
- 'strict_variables' => false,
- 'autoescape' => false,
- 'cache' => $app['debug'] ? false : $app['twig.cache.path'],
- 'optimizations' => -1,
- )
- )
- );
- $app['twig'] = $app->share(
- $app->extend('twig', function ($twig) {
- $twig->addFilter('get_lang', new Twig_Filter_Function('get_lang'));
- $twig->addFilter('get_path', new Twig_Filter_Function('api_get_path'));
- $twig->addFilter('get_setting', new Twig_Filter_Function('api_get_setting'));
- $twig->addFilter('var_dump', new Twig_Filter_Function('var_dump'));
- $twig->addFilter('return_message', new Twig_Filter_Function('Display::return_message_and_translate'));
- $twig->addFilter('display_page_header', new Twig_Filter_Function('Display::page_header_and_translate'));
- $twig->addFilter(
- 'display_page_subheader',
- new Twig_Filter_Function('Display::page_subheader_and_translate')
- );
- $twig->addFilter('icon', new Twig_Filter_Function('Template::get_icon_path'));
- $twig->addFilter('format_date', new Twig_Filter_Function('Template::format_date'));
- return $twig;
- })
- );
- if (is_writable($app['sys_temp_path'])) {
- if ($app['debug'] && $app['show_profiler']) {
-
- $app->register(
- $p = new Silex\Provider\WebProfilerServiceProvider(),
- array(
- 'profiler.cache_dir' => $app['profiler.cache_dir'],
- )
- );
- $app->mount('/_profiler', $p);
-
- $app->register(new Whoops\Provider\Silex\WhoopsServiceProvider);
- }
- }
- use FranMoreno\Silex\Provider\PagerfantaServiceProvider;
- $app->register(new PagerfantaServiceProvider());
- $app['pagerfanta.view.options'] = array(
- 'routeName' => null,
- 'routeParams' => array(),
- 'pageParameter' => '[page]',
- 'proximity' => 3,
- 'next_message' => '»',
- 'prev_message' => '«',
- 'default_view' => 'twitter_bootstrap'
- );
- $app->register(new \Knp\Menu\Silex\KnpMenuServiceProvider());
- define('IMAGE_PROCESSOR', 'gd');
- $app->register(new Grom\Silex\ImagineServiceProvider(), array(
- 'imagine.factory' => 'Gd'
- ));
- $app['dbal_logger'] = $app->share(function() {
-
- });
- if ($app['debug']) {
-
- }
- $app->register(new Silex\Provider\SwiftmailerServiceProvider(), array(
- 'swiftmailer.options' => array(
- 'host' => isset($platform_email['SMTP_HOST']) ? $platform_email['SMTP_HOST'] : null,
- 'port' => isset($platform_email['SMTP_PORT']) ? $platform_email['SMTP_PORT'] : null,
- 'username' => isset($platform_email['SMTP_USER']) ? $platform_email['SMTP_USER'] : null,
- 'password' => isset($platform_email['SMTP_PASS']) ? $platform_email['SMTP_PASS'] : null,
- 'encryption' => null,
- 'auth_mode' => null
- )
- ));
- $app['mailer'] = $app->share(function ($app) {
- return new \Swift_Mailer($app['swiftmailer.transport']);
- });
- if ($app['assetic.enabled']) {
- $app->register(new SilexAssetic\AsseticServiceProvider(), array(
- 'assetic.options' => array(
- 'debug' => $app['debug'],
- 'auto_dump_assets' => $app['assetic.auto_dump_assets'],
- )
- ));
-
- $app['assetic.filter_manager'] = $app->share(
- $app->extend('assetic.filter_manager', function($fm, $app) {
- $fm->set('lessphp', new Assetic\Filter\LessphpFilter());
- return $fm;
- })
- );
- $app['assetic.asset_manager'] = $app->share(
- $app->extend('assetic.asset_manager', function($am, $app) {
- $am->set('styles', new Assetic\Asset\AssetCache(
- new Assetic\Asset\GlobAsset(
- $app['assetic.input.path_to_css'],
- array($app['assetic.filter_manager']->get('lessphp'))
- ),
- new Assetic\Cache\FilesystemCache($app['assetic.path_to_cache'])
- ));
- $am->get('styles')->setTargetPath($app['assetic.output.path_to_css']);
- $am->set('scripts', new Assetic\Asset\AssetCache(
- new Assetic\Asset\GlobAsset($app['assetic.input.path_to_js']),
- new Assetic\Cache\FilesystemCache($app['assetic.path_to_cache'])
- ));
- $am->get('scripts')->setTargetPath($app['assetic.output.path_to_js']);
- return $am;
- })
- );
- }
- $app->register(new Neutron\Silex\Provider\FilesystemServiceProvider());
- class ChamiloServiceProvider implements ServiceProviderInterface
- {
- public function register(Application $app)
- {
-
- $app['template'] = $app->share(function () use ($app) {
- $template = new Template($app);
- return $template;
- });
- $app['paths'] = $app->share(function () use ($app) {
- return array(
-
- 'root_sys' => $app['root_sys'],
- 'sys_data_path' => $app['sys_data_path'],
- 'sys_config_path' => $app['sys_config_path'],
- 'sys_temp_path' => $app['sys_temp_path'],
- 'sys_log_path' => $app['sys_log_path']
- );
- });
-
- $app['chamilo.filesystem'] = $app->share(function () use ($app) {
- $filesystem = new ChamiloLMS\Component\DataFilesystem\DataFilesystem($app['paths'], $app['filesystem']);
- return $filesystem;
- });
-
- $app['page_controller'] = $app->share(function () use ($app) {
- $pageController = new PageController($app);
- return $pageController;
- });
-
- $app['mail_generator'] = $app->share(function () use ($app) {
- $mailGenerator = new ChamiloLMS\Component\Mail\MailGenerator($app['twig'], $app['mailer']);
- return $mailGenerator;
- });
-
- $app['database'] = $app->share(function () use ($app) {
- $db = new Database($app['db'], $app['dbs']);
- return $db;
- });
- }
- public function boot(Application $app)
- {
- }
- }
- $app->register(new ChamiloServiceProvider(), array());
- $app['pages.controller'] = $app->share(
- function () use ($app) {
- return new PagesController($app['pages.repository']);
- }
- );
- $app['index.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\IndexController();
- }
- );
- $app['legacy.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\LegacyController();
- }
- );
- $app['userPortal.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\UserPortalController();
- }
- );
- $app['learnpath.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\LearnpathController();
- }
- );
- $app['course_home.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\CourseHomeController();
- }
- );
- $app['course_home.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\CourseHomeController();
- }
- );
- $app['introduction_tool.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\IntroductionToolController();
- }
- );
- $app['certificate.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\CertificateController();
- }
- );
- $app['user.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\UserController();
- }
- );
- $app['news.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\NewsController();
- }
- );
- $app['editor.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\EditorController();
- }
- );
- $app['question_manager.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Admin\QuestionManager\QuestionManagerController();
- }
- );
- $app['exercise_manager.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\ExerciseController();
- }
- );
- $app['role.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\Admin\Administrator\RoleController($app);
- }
- );
- $app['model_ajax.controller'] = $app->share(
- function () use ($app) {
- return new ChamiloLMS\Controller\ModelAjaxController();
- }
- );
|