Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 538a71d

Browse files
committed
Merge branch '2.8'
* 2.8: (31 commits) [DomCrawler] Invalid uri created from forms if base tag present [VarDumper] Add caster for OuterIterator objects [Console] update param type phpdoc for StreamOutput [Console] fix typo in OutputInterface Use stderr by default when a specific output is not injected fixed bad merge [Debug] Fix case mismatch detection [HttpKernel] Add entry point to more easily create/configure the DI extension [DX] Added a logout link in the security panel of the web debug toolbar [HttpKernel] fix broken multiline <esi:remove> [DoctrineBridge] Fixed #14840 [FrameworkBundle] add a suggest for the serializer component fixed CS removed non-working tests [WIP] #15502 Make template shortcuts be usable without Templating component Redesigned the Symfony Profiler [Yaml] Fix the parsing of float keys Make the exception output visible even in quiet mode, fixes #15680 Convert Output::write's type to an options arg where verbosity can be passed in as well [Console] Ensure the console output is only detected as decorated when both stderr and stdout support colors ...
2 parents 95a1e90 + 6393ec3 commit 538a71d

File tree

95 files changed

+3147
-1889
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+3147
-1889
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,15 @@ protected function setMappingDriverAlias($mappingConfig, $mappingName)
129129
*/
130130
protected function setMappingDriverConfig(array $mappingConfig, $mappingName)
131131
{
132-
if (!is_dir($mappingConfig['dir'])) {
132+
$mappingDirectory = $mappingConfig['dir'];
133+
if (!is_dir($mappingDirectory)) {
133134
throw new \InvalidArgumentException(sprintf('Invalid Doctrine mapping path given. Cannot load Doctrine mapping/bundle named "%s".', $mappingName));
134135
}
135136

136-
$this->drivers[$mappingConfig['type']][$mappingConfig['prefix']] = realpath($mappingConfig['dir']);
137+
if (substr($mappingDirectory, 0, 7) !== 'phar://') {
138+
$mappingDirectory = realpath($mappingDirectory);
139+
}
140+
$this->drivers[$mappingConfig['type']][$mappingConfig['prefix']] = $mappingDirectory;
137141
}
138142

139143
/**

src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1515
use Doctrine\ORM\QueryBuilder;
1616
use Doctrine\DBAL\Connection;
17-
use Doctrine\ORM\EntityManager;
17+
use Doctrine\Common\Persistence\ObjectManager;
1818

1919
/**
2020
* Loads entities using a {@link QueryBuilder} instance.
@@ -43,7 +43,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
4343
* deprecated and will not be
4444
* supported anymore as of
4545
* Symfony 3.0.
46-
* @param EntityManager $manager Deprecated.
46+
* @param ObjectManager $manager Deprecated.
4747
* @param string $class Deprecated.
4848
*
4949
* @throws UnexpectedTypeException
@@ -59,8 +59,8 @@ public function __construct($queryBuilder, $manager = null, $class = null)
5959
if ($queryBuilder instanceof \Closure) {
6060
@trigger_error('Passing a QueryBuilder closure to '.__CLASS__.'::__construct() is deprecated since version 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
6161

62-
if (!$manager instanceof EntityManager) {
63-
throw new UnexpectedTypeException($manager, 'Doctrine\ORM\EntityManager');
62+
if (!$manager instanceof ObjectManager) {
63+
throw new UnexpectedTypeException($manager, 'Doctrine\Common\Persistence\ObjectManager');
6464
}
6565

6666
@trigger_error('Passing an EntityManager to '.__CLASS__.'::__construct() is deprecated since version 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);

src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ public function close()
120120
*/
121121
public function onCommand(ConsoleCommandEvent $event)
122122
{
123-
$this->setOutput($event->getOutput());
123+
$output = $event->getOutput();
124+
if ($output instanceof ConsoleOutputInterface) {
125+
$output = $output->getErrorOutput();
126+
}
127+
128+
$this->setOutput($output);
124129
}
125130

126131
/**
@@ -149,11 +154,7 @@ public static function getSubscribedEvents()
149154
*/
150155
protected function write(array $record)
151156
{
152-
if ($record['level'] >= Logger::ERROR && $this->output instanceof ConsoleOutputInterface) {
153-
$this->output->getErrorOutput()->write((string) $record['formatted']);
154-
} else {
155-
$this->output->write((string) $record['formatted']);
156-
}
157+
$this->output->write((string) $record['formatted']);
157158
}
158159

159160
/**

src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function testGetFormatter()
110110

111111
public function testWritingAndFormatting()
112112
{
113-
$output = $this->getMock('Symfony\Component\Console\Output\ConsoleOutputInterface');
113+
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
114114
$output
115115
->expects($this->any())
116116
->method('getVerbosity')
@@ -122,19 +122,6 @@ public function testWritingAndFormatting()
122122
->with('<info>[2013-05-29 16:21:54] app.INFO:</info> My info message '."\n")
123123
;
124124

125-
$errorOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
126-
$errorOutput
127-
->expects($this->once())
128-
->method('write')
129-
->with('<error>[2013-05-29 16:21:54] app.ERROR:</error> My error message '."\n")
130-
;
131-
132-
$output
133-
->expects($this->any())
134-
->method('getErrorOutput')
135-
->will($this->returnValue($errorOutput))
136-
;
137-
138125
$handler = new ConsoleHandler(null, false);
139126
$handler->setOutput($output);
140127

@@ -149,18 +136,6 @@ public function testWritingAndFormatting()
149136
);
150137

151138
$this->assertTrue($handler->handle($infoRecord), 'The handler finished handling the log as bubble is false.');
152-
153-
$errorRecord = array(
154-
'message' => 'My error message',
155-
'context' => array(),
156-
'level' => Logger::ERROR,
157-
'level_name' => Logger::getLevelName(Logger::ERROR),
158-
'channel' => 'app',
159-
'datetime' => new \DateTime('2013-05-29 16:21:54'),
160-
'extra' => array(),
161-
);
162-
163-
$this->assertTrue($handler->handle($errorRecord), 'The handler finished handling the log as bubble is false.');
164139
}
165140

166141
public function testLogsFromListeners()

src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,20 @@ public function getMacroCount()
7474
public function getHtmlCallGraph()
7575
{
7676
$dumper = new \Twig_Profiler_Dumper_Html();
77-
78-
return new \Twig_Markup($dumper->dump($this->getProfile()), 'UTF-8');
77+
$dump = $dumper->dump($this->getProfile());
78+
79+
// needed to remove the hardcoded CSS styles
80+
$dump = str_replace(array(
81+
'<span style="background-color: #ffd">',
82+
'<span style="color: #d44">',
83+
'<span style="background-color: #dfd">',
84+
), array(
85+
'<span class="status-warning">',
86+
'<span class="status-error">',
87+
'<span class="status-success">',
88+
), $dump);
89+
90+
return new \Twig_Markup($dump, 'UTF-8');
7991
}
8092

8193
public function getProfile()
Lines changed: 27 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
22

33
{% block toolbar %}
4-
{% set dumps_count = collector.dumpsCount %}
5-
6-
{% if dumps_count %}
4+
{% if collector.dumpsCount %}
75
{% set icon %}
8-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" height="24" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
9-
<path fill="#AAAAAA" d="M12,22.6c-5.8,0-10.5-4.7-10.5-10.5C1.5,6.3,6.2,1.5,12,1.5s10.5,4.7,10.5,10.5C22.5,17.9,17.8,22.6,12,22.6z M12,4.5c-4.2,0-7.5,3.4-7.5,7.5c0,4.2,3.4,7.5,7.5,7.5s7.5-3.4,7.5-7.5C19.5,7.9,16.2,4.5,12,4.5z"/>
10-
<path fill="#AAAAAA" d="M12,9.1c-0.8,0-1.5-0.7-1.5-1.5v-6c0-0.8,0.7-1.5,1.5-1.5s1.5,0.7,1.5,1.5v6C13.5,8.4,12.8,9.1,12,9.1zM13.5,22.4v-6c0-0.8-0.7-1.5-1.5-1.5s-1.5,0.7-1.5,1.5v6c0,0.8,0.7,1.5,1.5,1.5S13.5,23.2,13.5,22.4z M23.9,12c0-0.8-0.7-1.5-1.5-1.5h-6c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5h6C23.2,13.5,23.9,12.8,23.9,12z M9.1,12c0-0.8-0.7-1.5-1.5-1.5h-6c-0.8,0-1.5,0.7-1.5,1.5s0.7,1.5,1.5,1.5h6C8.4,13.5,9.1,12.8,9.1,12z"/>
11-
</svg>
12-
<span class="sf-toolbar-value">{{ dumps_count }}</span>
6+
{{ include('@Debug/Profiler/icon.svg') }}
7+
<span class="sf-toolbar-value">{{ collector.dumpsCount }}</span>
138
{% endset %}
149

1510
{% set text %}
@@ -28,6 +23,7 @@
2823
{% endif %}
2924
</span>
3025
<span class="sf-toolbar-file-line">line {{ dump.line }}</span>
26+
3127
{{ dump.data|raw }}
3228
</div>
3329
{% endfor %}
@@ -39,42 +35,18 @@
3935
{% endblock %}
4036

4137
{% block menu %}
42-
<span class="label">
43-
<span class="icon">
44-
{{- "" -}}
45-
<svg width="28" height="28" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 28 28" enable-background="new 0 0 28 28" xml:space="preserve"><path fill="#3F3F3F" d="M28 13h-1.1C26.5 6.6 21.4 1.5 15 1.1V0h-2v1.1C6.6 1.5 1.5 6.6 1.1 13H0v2h1.1C1.5 21.4 6.6 26.5 13 26.9 V28h2v-1.1c6.4-0.5 11.5-5.6 11.9-11.9H28V13z M15 24.9V19h-2v5.9c-5.3-0.5-9.5-4.7-9.9-9.9H9v-2H3.1C3.5 7.7 7.7 3.5 13 3.1V9h2 V3.1c5.3 0.5 9.5 4.7 9.9 9.9H19v2h5.9C24.5 20.3 20.3 24.5 15 24.9z"/></svg>
46-
{{- "" -}}
47-
</span>
48-
<strong>dump()</strong>
49-
<span class="count">
50-
<span>{{ collector.dumpsCount }}</span>
51-
</span>
38+
<span class="label {{ collector.dumpsCount == 0 ? 'disabled' }}">
39+
<span class="icon">{{ include('@Debug/Profiler/icon.svg') }}</span>
40+
<strong>Debug</strong>
5241
</span>
5342
{% endblock %}
5443

5544
{% block panel %}
56-
<h2>dump()</h2>
45+
<h2>Dumped Contents</h2>
5746

58-
<style>
59-
li.sf-dump {
60-
list-style-type: disc;
61-
}
62-
.sf-dump ol>li {
63-
padding: 0;
64-
}
65-
.sf-dump a {
66-
cursor: pointer;
67-
}
68-
.sf-dump-compact {
69-
display: none;
70-
}
71-
</style>
72-
73-
{% if collector.dumpsCount %}
74-
<ul class="alt">
75-
{% for dump in collector.getDumps('html') %}
76-
<li class="sf-dump sf-reset">
77-
in
47+
{% for dump in collector.getDumps('html') %}
48+
<div class="sf-dump sf-reset">
49+
<h3>In
7850
{% if dump.line %}
7951
{% set link = dump.file|file_link(dump.line) %}
8052
{% if link %}
@@ -85,19 +57,22 @@
8557
{% else %}
8658
{{ dump.name }}
8759
{% endif %}
88-
line {{ dump.line }}:
89-
<a onclick="var s = this.nextElementSibling; if ('sf-dump-compact' == s.className) {this.innerHTML = '&#9660;'; s.className = 'sf-dump-expanded';} else {this.innerHTML = '&#9654;'; s.className = 'sf-dump-compact';}">&#9654;</a>
90-
<span class="sf-dump-compact">
91-
{% if dump.fileExcerpt %}{{ dump.fileExcerpt|raw }}{% else %}{{ dump.file|file_excerpt(dump.line) }}{% endif %}
92-
</span>
60+
<small>line {{ dump.line }}</small>
9361

94-
{{ dump.data|raw }}
95-
</li>
96-
{% endfor %}
97-
</ul>
62+
<a class="text-small sf-toggle" data-toggle-selector="#sf-trace-{{ loop.index0 }}" data-toggle-alt-content="Hide code">Show code</a>
63+
</h3>
64+
65+
<div class="sf-dump-compact hidden" id="sf-trace-{{ loop.index0 }}">
66+
<div class="trace">
67+
{{ dump.fileExcerpt ? dump.fileExcerpt|raw : dump.file|file_excerpt(dump.line) }}
68+
</div>
69+
</div>
70+
71+
{{ dump.data|raw }}
72+
</div>
9873
{% else %}
99-
<p>
100-
<em>No dumped variable</em>
101-
</p>
102-
{% endif %}
74+
<div class="empty">
75+
<p>No content was dumped.</p>
76+
</div>
77+
{% endfor %}
10378
{% endblock %}
Lines changed: 4 additions & 0 deletions
Loading

src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,15 @@ protected function denyAccessUnlessGranted($attributes, $object = null, $message
159159
*/
160160
protected function renderView($view, array $parameters = array())
161161
{
162-
return $this->container->get('templating')->render($view, $parameters);
162+
if ($this->container->has('templating')) {
163+
return $this->container->get('templating')->render($view, $parameters);
164+
}
165+
166+
if (!$this->container->has('twig')) {
167+
throw new \LogicException('You can not use the "renderView" method if the Templating Component or the Twig Bundle are not available.');
168+
}
169+
170+
return $this->container->get('twig')->render($view, $parameters);
163171
}
164172

165173
/**
@@ -173,7 +181,21 @@ protected function renderView($view, array $parameters = array())
173181
*/
174182
protected function render($view, array $parameters = array(), Response $response = null)
175183
{
176-
return $this->container->get('templating')->renderResponse($view, $parameters, $response);
184+
if ($this->container->has('templating')) {
185+
return $this->container->get('templating')->renderResponse($view, $parameters, $response);
186+
}
187+
188+
if (!$this->container->has('twig')) {
189+
throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available.');
190+
}
191+
192+
if (null === $response) {
193+
$response = new Response();
194+
}
195+
196+
$response->setContent($this->container->get('twig')->render($view, $parameters));
197+
198+
return $response;
177199
}
178200

179201
/**
@@ -187,11 +209,21 @@ protected function render($view, array $parameters = array(), Response $response
187209
*/
188210
protected function stream($view, array $parameters = array(), StreamedResponse $response = null)
189211
{
190-
$templating = $this->container->get('templating');
191-
192-
$callback = function () use ($templating, $view, $parameters) {
193-
$templating->stream($view, $parameters);
194-
};
212+
if ($this->container->has('templating')) {
213+
$templating = $this->container->get('templating');
214+
215+
$callback = function () use ($templating, $view, $parameters) {
216+
$templating->stream($view, $parameters);
217+
};
218+
} elseif ($this->container->has('twig')) {
219+
$twig = $this->container->get('twig');
220+
221+
$callback = function () use ($twig, $view, $parameters) {
222+
$twig->display($view, $parameters);
223+
};
224+
} else {
225+
throw new \LogicException('You can not use the "stream" method if the Templating Component or the Twig Bundle are not available.');
226+
}
195227

196228
if (null === $response) {
197229
return new StreamedResponse($callback);

0 commit comments

Comments
 (0)