Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9573350

Browse filesBrowse files
committed
added a micro kernel
1 parent a76eae8 commit 9573350
Copy full SHA for 9573350

File tree

2 files changed

+107
-0
lines changed
Filter options

2 files changed

+107
-0
lines changed
+102Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpKernel;
13+
14+
use Symfony\Bundle\FrameworkBundle\Routing\RouteCollectionBuilder;
15+
use Symfony\Component\Config\Loader\LoaderInterface;
16+
use Symfony\Component\Config\Resource\FileResource;
17+
use Symfony\Component\DependencyInjection\ContainerBuilder;
18+
19+
/**
20+
* A Kernel that provides configuration hooks.
21+
*
22+
* @author Ryan Weaver <ryan@knpuniversity.com>
23+
* @author Fabien Potencier <fabien@symfony.com>
24+
*/
25+
abstract class MicroKernel extends Kernel
26+
{
27+
/**
28+
* Add or import routes into your application.
29+
*
30+
* $routes->import('config/routing.yml');
31+
* $routes->add('/admin', 'AppBundle:Admin:dashboard', 'admin_dashboard');
32+
*
33+
* @param RouteCollectionBuilder $routes
34+
*/
35+
protected function configureRoutes(RouteCollectionBuilder $routes)
36+
{
37+
return $routes;
38+
}
39+
40+
/**
41+
* Configures container extensions.
42+
*
43+
* $c->loadFromExtension('framework', array(
44+
* 'secret' => '%secret%'
45+
* ));
46+
*
47+
* @param ContainerBuilder $c
48+
* @param LoaderInterface $loader
49+
*/
50+
protected function configureExtensions(ContainerBuilder $c, LoaderInterface $loader)
51+
{
52+
}
53+
54+
/**
55+
* Adds service definitions to the container.
56+
*
57+
* @param ContainerBuilder $c
58+
* @param LoaderInterface $loader
59+
*/
60+
protected function configureServices(ContainerBuilder $c, LoaderInterface $loader)
61+
{
62+
}
63+
64+
/**
65+
* {@inheritdoc}
66+
*/
67+
public function registerContainerConfiguration(LoaderInterface $loader)
68+
{
69+
$loader->load(function (ContainerBuilder $container) use ($loader) {
70+
$container->loadFromExtension('framework', array(
71+
'router' => array(
72+
'resource' => null,
73+
'type' => 'file',
74+
),
75+
));
76+
77+
$this->configureExtensions($container, $loader);
78+
$this->configureServices($container, $loader);
79+
80+
$container->addResource(new FileResource(__FILE__));
81+
});
82+
}
83+
84+
/**
85+
* {@inheritdoc}
86+
*/
87+
public function boot()
88+
{
89+
if (true === $this->booted) {
90+
return;
91+
}
92+
93+
parent::boot();
94+
95+
// 3.0 only
96+
$this->getContainer()->get('router')->setResource(function () {
97+
$loader = $this->getContainerLoader($this->getContainer());
98+
99+
return $this->configureRoutes(new RouteCollectionBuilder($loader))->build();
100+
});
101+
}
102+
}

‎src/Symfony/Component/Routing/Router.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Router.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ public function setContext(RequestContext $context)
208208
}
209209
}
210210

211+
public function setResource($resource)
212+
{
213+
$this->resource = $resource;
214+
}
215+
211216
/**
212217
* {@inheritdoc}
213218
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.