Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
54be4f51
Commit
54be4f51
authored
May 03, 2013
by
Igor Wiedler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[1.1] Remove symfony <2.3 hacks
parent
2b45f600
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
13 additions
and
91 deletions
+13
-91
src/Silex/Application.php
src/Silex/Application.php
+1
-7
src/Silex/Provider/RememberMeServiceProvider.php
src/Silex/Provider/RememberMeServiceProvider.php
+1
-6
src/Silex/Provider/SecurityServiceProvider.php
src/Silex/Provider/SecurityServiceProvider.php
+2
-11
src/Silex/Provider/ValidatorServiceProvider.php
src/Silex/Provider/ValidatorServiceProvider.php
+5
-16
src/Silex/RedirectableUrlMatcher.php
src/Silex/RedirectableUrlMatcher.php
+1
-6
src/Silex/RequestContext.php
src/Silex/RequestContext.php
+0
-33
src/Silex/Route.php
src/Silex/Route.php
+0
-2
tests/Silex/Tests/Provider/SecurityServiceProviderTest.php
tests/Silex/Tests/Provider/SecurityServiceProviderTest.php
+1
-7
tests/Silex/Tests/Provider/ValidatorServiceProviderTest.php
tests/Silex/Tests/Provider/ValidatorServiceProviderTest.php
+2
-3
No files found.
src/Silex/Application.php
View file @
54be4f51
...
@@ -28,9 +28,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
...
@@ -28,9 +28,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
use
Symfony\Component\HttpFoundation\StreamedResponse
;
use
Symfony\Component\HttpFoundation\StreamedResponse
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\Routing\RouteCollection
;
use
Symfony\Component\Routing\RouteCollection
;
use
Silex\RequestContext
;
use
Symfony\Component\Routing\RequestContext
;
use
Silex\RedirectableUrlMatcher
;
use
Silex\ControllerResolver
;
use
Silex\EventListener\LocaleListener
;
use
Silex\EventListener\LocaleListener
;
use
Silex\EventListener\MiddlewareListener
;
use
Silex\EventListener\MiddlewareListener
;
use
Silex\EventListener\ConverterListener
;
use
Silex\EventListener\ConverterListener
;
...
@@ -437,10 +435,6 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
...
@@ -437,10 +435,6 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
*/
*/
public
function
sendFile
(
$file
,
$status
=
200
,
$headers
=
array
(),
$contentDisposition
=
null
)
public
function
sendFile
(
$file
,
$status
=
200
,
$headers
=
array
(),
$contentDisposition
=
null
)
{
{
if
(
!
class_exists
(
'Symfony\Component\HttpFoundation\BinaryFileResponse'
))
{
throw
new
\RuntimeException
(
'The "sendFile" method is only supported as of Http Foundation 2.2.'
);
}
return
new
BinaryFileResponse
(
$file
,
$status
,
$headers
,
true
,
$contentDisposition
);
return
new
BinaryFileResponse
(
$file
,
$status
,
$headers
,
true
,
$contentDisposition
);
}
}
...
...
src/Silex/Provider/RememberMeServiceProvider.php
View file @
54be4f51
...
@@ -101,11 +101,6 @@ class RememberMeServiceProvider implements ServiceProviderInterface
...
@@ -101,11 +101,6 @@ class RememberMeServiceProvider implements ServiceProviderInterface
throw
new
\LogicException
(
'You must register the SecurityServiceProvider to use the RememberMeServiceProvider'
);
throw
new
\LogicException
(
'You must register the SecurityServiceProvider to use the RememberMeServiceProvider'
);
}
}
// In Symfony 2.2, this is a proper subscriber
$app
[
'dispatcher'
]
->
addSubscriber
(
$app
[
'security.remember_me.response_listener'
]);
if
(
$app
[
'security.remember_me.response_listener'
]
instanceof
EventSubscriberInterface
)
{
$app
[
'dispatcher'
]
->
addSubscriber
(
$app
[
'security.remember_me.response_listener'
]);
}
else
{
$app
[
'dispatcher'
]
->
addListener
(
'kernel.response'
,
array
(
$app
[
'security.remember_me.response_listener'
],
'onKernelResponse'
));
}
}
}
}
}
src/Silex/Provider/SecurityServiceProvider.php
View file @
54be4f51
...
@@ -33,7 +33,6 @@ use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
...
@@ -33,7 +33,6 @@ use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter;
use
Symfony\Component\Security\Core\Authorization\AccessDecisionManager
;
use
Symfony\Component\Security\Core\Authorization\AccessDecisionManager
;
use
Symfony\Component\Security\Core\Role\RoleHierarchy
;
use
Symfony\Component\Security\Core\Role\RoleHierarchy
;
use
Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator
;
use
Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator
;
use
Symfony\Component\Security\Core\Validator\Constraint\UserPasswordValidator
as
DeprecatedUserPasswordValidator
;
use
Symfony\Component\Security\Http\Firewall
;
use
Symfony\Component\Security\Http\Firewall
;
use
Symfony\Component\Security\Http\FirewallMap
;
use
Symfony\Component\Security\Http\FirewallMap
;
use
Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener
;
use
Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener
;
...
@@ -524,13 +523,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
...
@@ -524,13 +523,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
if
(
isset
(
$app
[
'validator'
]))
{
if
(
isset
(
$app
[
'validator'
]))
{
$app
[
'security.validator.user_password_validator'
]
=
$app
->
share
(
function
(
$app
)
{
$app
[
'security.validator.user_password_validator'
]
=
$app
->
share
(
function
(
$app
)
{
// FIXME: in Symfony 2.2 Symfony\Component\Security\Core\Validator\Constraint
return
new
UserPasswordValidator
(
$app
[
'security'
],
$app
[
'security.encoder_factory'
]);
// is replaced by Symfony\Component\Security\Core\Validator\Constraints
if
(
class_exists
(
'Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator'
))
{
return
new
UserPasswordValidator
(
$app
[
'security'
],
$app
[
'security.encoder_factory'
]);
}
return
new
DeprecatedUserPasswordValidator
(
$app
[
'security'
],
$app
[
'security.encoder_factory'
]);
});
});
if
(
!
isset
(
$app
[
'validator.validator_service_ids'
]))
{
if
(
!
isset
(
$app
[
'validator.validator_service_ids'
]))
{
...
@@ -543,9 +536,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
...
@@ -543,9 +536,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
public
function
boot
(
Application
$app
)
public
function
boot
(
Application
$app
)
{
{
// FIXME: in Symfony 2.2, this is a proper subscriber
$app
[
'dispatcher'
]
->
addSubscriber
(
$app
[
'security.firewall'
]);
//$app['dispatcher']->addSubscriber($app['security.firewall']);
$app
[
'dispatcher'
]
->
addListener
(
'kernel.request'
,
array
(
$app
[
'security.firewall'
],
'onKernelRequest'
),
8
);
foreach
(
$this
->
fakeRoutes
as
$route
)
{
foreach
(
$this
->
fakeRoutes
as
$route
)
{
list
(
$method
,
$pattern
,
$name
)
=
$route
;
list
(
$method
,
$pattern
,
$name
)
=
$route
;
...
...
src/Silex/Provider/ValidatorServiceProvider.php
View file @
54be4f51
...
@@ -36,22 +36,11 @@ class ValidatorServiceProvider implements ServiceProviderInterface
...
@@ -36,22 +36,11 @@ class ValidatorServiceProvider implements ServiceProviderInterface
$app
[
'translator'
]
->
addResource
(
'xliff'
,
dirname
(
$r
->
getFilename
())
.
'/Resources/translations/validators.'
.
$app
[
'locale'
]
.
'.xlf'
,
$app
[
'locale'
],
'validators'
);
$app
[
'translator'
]
->
addResource
(
'xliff'
,
dirname
(
$r
->
getFilename
())
.
'/Resources/translations/validators.'
.
$app
[
'locale'
]
.
'.xlf'
,
$app
[
'locale'
],
'validators'
);
}
}
$params
=
$r
->
getConstructor
()
->
getParameters
();
return
new
Validator
(
if
(
'validatorInitializers'
===
$params
[
2
]
->
getName
())
{
$app
[
'validator.mapping.class_metadata_factory'
],
// BC: to be removed before 1.0
$app
[
'validator.validator_factory'
],
// Compatibility with symfony/validator 2.1
isset
(
$app
[
'translator'
])
?
$app
[
'translator'
]
:
new
DefaultTranslator
()
// can be removed once silex requires 2.2
);
return
new
Validator
(
$app
[
'validator.mapping.class_metadata_factory'
],
$app
[
'validator.validator_factory'
]
);
}
else
{
return
new
Validator
(
$app
[
'validator.mapping.class_metadata_factory'
],
$app
[
'validator.validator_factory'
],
isset
(
$app
[
'translator'
])
?
$app
[
'translator'
]
:
new
DefaultTranslator
()
);
}
});
});
$app
[
'validator.mapping.class_metadata_factory'
]
=
$app
->
share
(
function
(
$app
)
{
$app
[
'validator.mapping.class_metadata_factory'
]
=
$app
->
share
(
function
(
$app
)
{
...
...
src/Silex/RedirectableUrlMatcher.php
View file @
54be4f51
...
@@ -28,12 +28,7 @@ class RedirectableUrlMatcher extends BaseRedirectableUrlMatcher
...
@@ -28,12 +28,7 @@ class RedirectableUrlMatcher extends BaseRedirectableUrlMatcher
public
function
redirect
(
$path
,
$route
,
$scheme
=
null
)
public
function
redirect
(
$path
,
$route
,
$scheme
=
null
)
{
{
$url
=
$this
->
context
->
getBaseUrl
()
.
$path
;
$url
=
$this
->
context
->
getBaseUrl
()
.
$path
;
$query
=
$this
->
context
->
getQueryString
()
?:
''
;
// Query string support was added to RequestContext in 2.3
// Fall back to parameter injected by url_matcher closure for earlier versions
$query
=
method_exists
(
$this
->
context
,
'getQueryString'
)
?
$this
->
context
->
getQueryString
()
:
$this
->
context
->
getParameter
(
'QUERY_STRING'
)
?:
''
;
if
(
$query
!==
''
)
{
if
(
$query
!==
''
)
{
$url
.=
'?'
.
$query
;
$url
.=
'?'
.
$query
;
...
...
src/Silex/RequestContext.php
deleted
100644 → 0
View file @
2b45f600
<?php
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Silex
;
use
Symfony\Component\Routing\RequestContext
as
BaseRequestContext
;
use
Symfony\Component\HttpFoundation\Request
;
/**
* Request Context for Symfony <= 2.2
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class
RequestContext
extends
BaseRequestContext
{
public
function
fromRequest
(
Request
$request
)
{
parent
::
fromRequest
(
$request
);
// Inject the query string as a parameter for Symfony versions <= 2.2
if
(
!
method_exists
(
$this
,
'getQueryString'
)
&&
''
!==
$qs
=
$request
->
server
->
get
(
'QUERY_STRING'
))
{
$this
->
setParameter
(
'QUERY_STRING'
,
$qs
);
}
}
}
src/Silex/Route.php
View file @
54be4f51
...
@@ -89,8 +89,6 @@ class Route extends BaseRoute
...
@@ -89,8 +89,6 @@ class Route extends BaseRoute
/**
/**
* Sets the requirement of host on this Route.
* Sets the requirement of host on this Route.
*
*
* Note that this only works with at least version 2.2 of the Symfony Routing component.
*
* @param string $host The host for which this route should be enabled
* @param string $host The host for which this route should be enabled
*
*
* @return Route $this The current Route instance
* @return Route $this The current Route instance
...
...
tests/Silex/Tests/Provider/SecurityServiceProviderTest.php
View file @
54be4f51
...
@@ -142,13 +142,7 @@ class SecurityServiceProviderTest extends WebTestCase
...
@@ -142,13 +142,7 @@ class SecurityServiceProviderTest extends WebTestCase
$app
->
boot
();
$app
->
boot
();
// FIXME: in Symfony 2.2 Symfony\Component\Security\Core\Validator\Constraint
$this
->
assertInstanceOf
(
'Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator'
,
$app
[
'security.validator.user_password_validator'
]);
// is replaced by Symfony\Component\Security\Core\Validator\Constraints
if
(
class_exists
(
'Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator'
))
{
$this
->
assertInstanceOf
(
'Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator'
,
$app
[
'security.validator.user_password_validator'
]);
}
else
{
$this
->
assertInstanceOf
(
'Symfony\Component\Security\Core\Validator\Constraint\UserPasswordValidator'
,
$app
[
'security.validator.user_password_validator'
]);
}
}
}
public
function
createApplication
(
$authenticationMethod
=
'form'
)
public
function
createApplication
(
$authenticationMethod
=
'form'
)
...
...
tests/Silex/Tests/Provider/ValidatorServiceProviderTest.php
View file @
54be4f51
...
@@ -87,9 +87,8 @@ class ValidatorServiceProviderTest extends \PHPUnit_Framework_TestCase
...
@@ -87,9 +87,8 @@ class ValidatorServiceProviderTest extends \PHPUnit_Framework_TestCase
));
));
$builder
=
$app
[
'form.factory'
]
->
createBuilder
(
'form'
,
array
(),
array
(
$builder
=
$app
[
'form.factory'
]
->
createBuilder
(
'form'
,
array
(),
array
(
'validation_constraint'
=>
$constraints
,
// symfony/validator >=2.1,<2.3
'constraints'
=>
$constraints
,
'constraints'
=>
$constraints
,
// symfony/validator ~2.3
'csrf_protection'
=>
false
,
'csrf_protection'
=>
false
,
));
));
$form
=
$builder
$form
=
$builder
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment