Skip to content
Pavel Linkesch edited this page Aug 3, 2015 · 2 revisions

Configuration file will only take you so far. But Marvin's architecture will let you customize, extend, and override everything.

/app/bootstrap.php

A good place to start further customizing your website is to create /app/bootstrap.php file. This is an entry point for your customized application.

/app/bootstrap.php has access to a global $app variable which is an instance of Silex\Application.

Do you want to enable new service provider? Add it to /app/bootstrap.php. This is how you enable translations:

<?php
// /app/bootstrap.php

use Symfony\Component\Translation\Loader\YamlFileLoader;
use Symfony\Component\Translation\Loader\XliffFileLoader;
use Symfony\Component\HttpFoundation\Request;

$app->register(new Silex\Provider\TranslationServiceProvider(), array(
    'translator.domains' => array(),
    'locale' => 'sk',
    'locale_fallback' => 'sk',
));

$app['translator'] = $app->share($app->extend('translator', function($translator, $app) {
    $translator->addLoader('xlf', new XliffFileLoader());
    $translator->addResource('xlf', __DIR__.'/../vendor/symfony/validator/Symfony/Component/Validator/Resources/translations/validators.sk.xlf', 'sk', 'validators');

    $translator->addLoader('yaml', new YamlFileLoader());
    $translator->addResource('yaml', __DIR__.'/locales/sk.yml', 'sk');

    return $translator;
}));

Do you want to extend how /admin/pages behaves? Find the original controller in /vendor/marvin/pages/Controller/AdminControllerProvider.php, copy and paste a controller you want to change to /app/bootstrap.php. Now change $controllers variable to global $app and you're ready to customize the selected controller.

<?php
// /app/bootstrap.php

$app->get('/', function () use ($app) {
    $pages = $app['db']->fetchAll("SELECT * FROM page ORDER BY sort ASC");

    return $app['twig']->render('admin/pages/list.twig', array(
        'pages' => $pages,
    ));
})
->bind('admin_pages');

-- « Configuration | Themes »

Clone this wiki locally