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
6dfc390b
Commit
6dfc390b
authored
Apr 05, 2011
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added an extension for the Symfony2 Validator component
parent
628714a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
src/Silex/Extension/ValidationExtension.php
src/Silex/Extension/ValidationExtension.php
+45
-0
No files found.
src/Silex/Extension/ValidationExtension.php
0 → 100644
View file @
6dfc390b
<?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\Extension
;
use
Silex\Application
;
use
Silex\ExtensionInterface
;
use
Symfony\Component\Validator\Validator
;
use
Symfony\Component\Validator\Mapping\ClassMetadataFactory
;
use
Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader
;
use
Symfony\Component\Validator\ConstraintValidatorFactory
;
class
ValidationExtension
implements
ExtensionInterface
{
public
function
register
(
Application
$app
)
{
$app
[
'validator'
]
=
$app
->
share
(
function
()
use
(
$app
)
{
return
new
Validator
(
$app
[
'validator.mapping.class_metadata_factory'
],
$app
[
'validator.validator_factory'
]
);
});
$app
[
'validator.mapping.class_metadata_factory'
]
=
$app
->
share
(
function
()
use
(
$app
)
{
return
new
ClassMetadataFactory
(
new
StaticMethodLoader
());
});
$app
[
'validator.validator_factory'
]
=
$app
->
share
(
function
()
{
return
new
ConstraintValidatorFactory
();
});
if
(
isset
(
$app
[
'validation.class_path'
]))
{
$app
[
'autoloader'
]
->
registerNamespace
(
'Symfony\\Component\\Validation'
,
$app
[
'validation.class_path'
]);
}
}
}
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