Skip to content

Add d-block to bootstrap 4 alerts #26870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@

{% block form_errors -%}
{%- if errors|length > 0 -%}
<span class="{% if form is not rootform %}invalid-feedback d-block{% else %}alert alert-danger{% endif %}">
<span class="{% if form is not rootform %}invalid-feedback d-block{% else %}alert alert-danger d-block{% endif %}">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move the d-block class outside the {% if %} statement to have it only once in the line

{%- for error in errors -%}
<span class="mb-0 d-block">
<span class="initialism form-error-icon badge badge-danger">{{ 'Error'|trans({}, 'validators') }}</span> <span class="form-error-message">{{ error.message }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ private function autowireMethod(\ReflectionFunctionAbstract $reflectionMethod, a
if ($parameter->isOptional()) {
continue;
}
throw new AutowiringFailedException($this->currentId, sprintf('Cannot autowire service "%s": argument "$%s" of method "%s()" must have a type-hint or be given a value explicitly.', $this->currentId, $parameter->name, $class !== $this->currentId ? $class.'::'.$method : $method));
$type = ProxyHelper::getTypeHint($reflectionMethod, $parameter, false);
$type = $type ? sprintf('is type-hinted "%s"', $type) : 'has no type-hint';

throw new AutowiringFailedException($this->currentId, sprintf('Cannot autowire service "%s": argument "$%s" of method "%s()" %s, you should configure its value explicitly.', $this->currentId, $parameter->name, $class !== $this->currentId ? $class.'::'.$method : $method, $type));
}

// specifically pass the default value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ public function testSomeSpecificArgumentsAreSet()
// args are: A, Foo, Dunglas
->setArguments(array(
1 => new Reference('foo'),
3 => array('bar'),
));

(new ResolveClassPass())->process($container);
Expand All @@ -447,19 +448,38 @@ public function testSomeSpecificArgumentsAreSet()
new TypedReference(A::class, A::class, MultipleArguments::class),
new Reference('foo'),
new TypedReference(Dunglas::class, Dunglas::class, MultipleArguments::class),
array('bar'),
),
$definition->getArguments()
);
}

/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\AutowiringFailedException
* @expectedExceptionMessage Cannot autowire service "arg_no_type_hint": argument "$foo" of method "Symfony\Component\DependencyInjection\Tests\Compiler\MultipleArguments::__construct()" must have a type-hint or be given a value explicitly.
* @expectedExceptionMessage Cannot autowire service "arg_no_type_hint": argument "$bar" of method "Symfony\Component\DependencyInjection\Tests\Compiler\MultipleArguments::__construct()" is type-hinted "array", you should configure its value explicitly.
*/
public function testScalarArgsCannotBeAutowired()
{
$container = new ContainerBuilder();

$container->register(A::class);
$container->register(Dunglas::class);
$container->register('arg_no_type_hint', __NAMESPACE__.'\MultipleArguments')
->setArguments(array(1 => 'foo'))
->setAutowired(true);

(new ResolveClassPass())->process($container);
(new AutowirePass())->process($container);
}

/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\AutowiringFailedException
* @expectedExceptionMessage Cannot autowire service "arg_no_type_hint": argument "$foo" of method "Symfony\Component\DependencyInjection\Tests\Compiler\MultipleArguments::__construct()" has no type-hint, you should configure its value explicitly.
*/
public function testNoTypeArgsCannotBeAutowired()
{
$container = new ContainerBuilder();

$container->register(A::class);
$container->register(Dunglas::class);
$container->register('arg_no_type_hint', __NAMESPACE__.'\MultipleArguments')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function __construct(A $k)
}
class MultipleArguments
{
public function __construct(A $k, $foo, Dunglas $dunglas)
public function __construct(A $k, $foo, Dunglas $dunglas, array $bar)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testRow()
[
./label[@for="name"]
[
./span[@class="alert alert-danger"]
./span[@class="alert alert-danger d-block"]
[./span[@class="mb-0 d-block"]
[./span[.="[trans]Error[/trans]"]]
[./span[.="[trans]Error![/trans]"]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testRow()
[
./label[@for="name"]
[
./span[@class="alert alert-danger"]
./span[@class="alert alert-danger d-block"]
[./span[@class="mb-0 d-block"]
[./span[.="[trans]Error[/trans]"]]
[./span[.="[trans]Error![/trans]"]]
Expand Down Expand Up @@ -161,7 +161,7 @@ public function testErrors()

$this->assertMatchesXpath($html,
'/span
[@class="alert alert-danger"]
[@class="alert alert-danger d-block"]
[
./span[@class="mb-0 d-block"]
[./span[.="[trans]Error[/trans]"]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function onKernelResponse(FilterResponseEvent $event)
$session->save();
}

if ($session instanceof Session ? !$session->isEmpty() || $session->getId() !== $this->sessionId : $wasStarted) {
if ($session instanceof Session ? !$session->isEmpty() || (null !== $this->sessionId && $session->getId() !== $this->sessionId) : $wasStarted) {
$params = session_get_cookie_params();
$event->getResponse()->headers->setCookie(new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : time() + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']));
$this->sessionId = $session->getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
Expand Down Expand Up @@ -46,6 +45,9 @@ protected function setUp()
{
$this->listener = $this->getMockForAbstractClass('Symfony\Component\HttpKernel\EventListener\AbstractTestSessionListener');
$this->session = $this->getSession();
$this->listener->expects($this->any())
->method('getSession')
->will($this->returnValue($this->session));
}

public function testShouldSaveMasterRequestSession()
Expand Down Expand Up @@ -95,7 +97,7 @@ public function testEmptySessionWithNewSessionIdDoesSendCookie()
$this->fixSessionId('456');

$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$request = Request::create('/', 'GET', array(), array(new Cookie('MOCKSESSID', '123')));
$request = Request::create('/', 'GET', array(), array('MOCKSESSID' => '123'));
$event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$this->listener->onKernelRequest($event);

Expand Down