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
c7536412
Commit
c7536412
authored
May 26, 2012
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added the ServiceProviderInterface::boot() method
parent
95393c5b
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
77 additions
and
6 deletions
+77
-6
doc/changelog.rst
doc/changelog.rst
+2
-0
src/Silex/Application.php
src/Silex/Application.php
+20
-0
src/Silex/Provider/DoctrineServiceProvider.php
src/Silex/Provider/DoctrineServiceProvider.php
+4
-0
src/Silex/Provider/FormServiceProvider.php
src/Silex/Provider/FormServiceProvider.php
+4
-0
src/Silex/Provider/HttpCacheServiceProvider.php
src/Silex/Provider/HttpCacheServiceProvider.php
+4
-0
src/Silex/Provider/MonologServiceProvider.php
src/Silex/Provider/MonologServiceProvider.php
+3
-0
src/Silex/Provider/SessionServiceProvider.php
src/Silex/Provider/SessionServiceProvider.php
+5
-2
src/Silex/Provider/SwiftmailerServiceProvider.php
src/Silex/Provider/SwiftmailerServiceProvider.php
+7
-4
src/Silex/Provider/TranslationServiceProvider.php
src/Silex/Provider/TranslationServiceProvider.php
+4
-0
src/Silex/Provider/TwigServiceProvider.php
src/Silex/Provider/TwigServiceProvider.php
+4
-0
src/Silex/Provider/UrlGeneratorServiceProvider.php
src/Silex/Provider/UrlGeneratorServiceProvider.php
+4
-0
src/Silex/Provider/ValidatorServiceProvider.php
src/Silex/Provider/ValidatorServiceProvider.php
+4
-0
src/Silex/ServiceProviderInterface.php
src/Silex/ServiceProviderInterface.php
+12
-0
No files found.
doc/changelog.rst
View file @
c7536412
...
@@ -3,6 +3,8 @@ Changelog
...
@@ -3,6 +3,8 @@ Changelog
This changelog references all backward incompatibilities as we introduce them:
This changelog references all backward incompatibilities as we introduce them:
* **2012-05-26**: added ``boot()`` to ``ServiceProviderInterface``
* **2012-05-26**: Removed ``SymfonyBridgesServiceProvider``
* **2012-05-26**: Removed ``SymfonyBridgesServiceProvider``
* **2012-05-26**: Removed the ``translator.messages`` parameter (use
* **2012-05-26**: Removed the ``translator.messages`` parameter (use
...
...
src/Silex/Application.php
View file @
c7536412
...
@@ -48,6 +48,9 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
...
@@ -48,6 +48,9 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
{
{
const
VERSION
=
'@package_version@'
;
const
VERSION
=
'@package_version@'
;
private
$providers
=
array
();
private
$booted
=
false
;
/**
/**
* Constructor.
* Constructor.
*/
*/
...
@@ -147,9 +150,22 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
...
@@ -147,9 +150,22 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
$this
[
$key
]
=
$value
;
$this
[
$key
]
=
$value
;
}
}
$this
->
providers
[]
=
$provider
;
$provider
->
register
(
$this
);
$provider
->
register
(
$this
);
}
}
public
function
boot
()
{
if
(
!
$this
->
booted
)
{
foreach
(
$this
->
providers
as
$provider
)
{
$provider
->
boot
(
$this
);
}
$this
->
booted
=
true
;
}
}
/**
/**
* Maps a pattern to a callable.
* Maps a pattern to a callable.
*
*
...
@@ -439,6 +455,10 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
...
@@ -439,6 +455,10 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
*/
*/
public
function
handle
(
Request
$request
,
$type
=
HttpKernelInterface
::
MASTER_REQUEST
,
$catch
=
true
)
public
function
handle
(
Request
$request
,
$type
=
HttpKernelInterface
::
MASTER_REQUEST
,
$catch
=
true
)
{
{
if
(
!
$this
->
booted
)
{
$this
->
boot
();
}
$this
->
beforeDispatched
=
false
;
$this
->
beforeDispatched
=
false
;
$current
=
HttpKernelInterface
::
SUB_REQUEST
===
$type
?
$this
[
'request'
]
:
$this
[
'request_error'
];
$current
=
HttpKernelInterface
::
SUB_REQUEST
===
$type
?
$this
[
'request'
]
:
$this
[
'request_error'
];
...
...
src/Silex/Provider/DoctrineServiceProvider.php
View file @
c7536412
...
@@ -119,4 +119,8 @@ class DoctrineServiceProvider implements ServiceProviderInterface
...
@@ -119,4 +119,8 @@ class DoctrineServiceProvider implements ServiceProviderInterface
return
$dbs
[
$app
[
'dbs.default'
]];
return
$dbs
[
$app
[
'dbs.default'
]];
});
});
}
}
public
function
boot
(
Application
$app
)
{
}
}
}
src/Silex/Provider/FormServiceProvider.php
View file @
c7536412
...
@@ -52,4 +52,8 @@ class FormServiceProvider implements ServiceProviderInterface
...
@@ -52,4 +52,8 @@ class FormServiceProvider implements ServiceProviderInterface
return
new
DefaultCsrfProvider
(
$app
[
'form.secret'
]);
return
new
DefaultCsrfProvider
(
$app
[
'form.secret'
]);
});
});
}
}
public
function
boot
(
Application
$app
)
{
}
}
}
src/Silex/Provider/HttpCacheServiceProvider.php
View file @
c7536412
...
@@ -42,4 +42,8 @@ class HttpCacheServiceProvider implements ServiceProviderInterface
...
@@ -42,4 +42,8 @@ class HttpCacheServiceProvider implements ServiceProviderInterface
$app
[
'http_cache.options'
]
=
array
();
$app
[
'http_cache.options'
]
=
array
();
}
}
}
}
public
function
boot
(
Application
$app
)
{
}
}
}
src/Silex/Provider/MonologServiceProvider.php
View file @
c7536412
...
@@ -50,7 +50,10 @@ class MonologServiceProvider implements ServiceProviderInterface
...
@@ -50,7 +50,10 @@ class MonologServiceProvider implements ServiceProviderInterface
return
Logger
::
DEBUG
;
return
Logger
::
DEBUG
;
};
};
}
}
}
public
function
boot
(
Application
$app
)
{
$app
->
before
(
function
(
Request
$request
)
use
(
$app
)
{
$app
->
before
(
function
(
Request
$request
)
use
(
$app
)
{
$app
[
'monolog'
]
->
addInfo
(
'> '
.
$request
->
getMethod
()
.
' '
.
$request
->
getRequestUri
());
$app
[
'monolog'
]
->
addInfo
(
'> '
.
$request
->
getMethod
()
.
' '
.
$request
->
getRequestUri
());
});
});
...
...
src/Silex/Provider/SessionServiceProvider.php
View file @
c7536412
...
@@ -49,8 +49,6 @@ class SessionServiceProvider implements ServiceProviderInterface
...
@@ -49,8 +49,6 @@ class SessionServiceProvider implements ServiceProviderInterface
);
);
});
});
$app
[
'dispatcher'
]
->
addListener
(
KernelEvents
::
REQUEST
,
array
(
$this
,
'onKernelRequest'
),
128
);
if
(
!
isset
(
$app
[
'session.storage.options'
]))
{
if
(
!
isset
(
$app
[
'session.storage.options'
]))
{
$app
[
'session.storage.options'
]
=
array
();
$app
[
'session.storage.options'
]
=
array
();
}
}
...
@@ -70,4 +68,9 @@ class SessionServiceProvider implements ServiceProviderInterface
...
@@ -70,4 +68,9 @@ class SessionServiceProvider implements ServiceProviderInterface
$request
->
getSession
()
->
start
();
$request
->
getSession
()
->
start
();
}
}
}
}
public
function
boot
(
Application
$app
)
{
$app
[
'dispatcher'
]
->
addListener
(
KernelEvents
::
REQUEST
,
array
(
$this
,
'onKernelRequest'
),
128
);
}
}
}
src/Silex/Provider/SwiftmailerServiceProvider.php
View file @
c7536412
...
@@ -76,14 +76,17 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface
...
@@ -76,14 +76,17 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface
return
new
\Swift_Events_SimpleEventDispatcher
();
return
new
\Swift_Events_SimpleEventDispatcher
();
});
});
$app
->
finish
(
function
()
use
(
$app
)
{
$app
[
'swiftmailer.spooltransport'
]
->
getSpool
()
->
flushQueue
(
$app
[
'swiftmailer.transport'
]);
});
if
(
isset
(
$app
[
'swiftmailer.class_path'
]))
{
if
(
isset
(
$app
[
'swiftmailer.class_path'
]))
{
require_once
$app
[
'swiftmailer.class_path'
]
.
'/Swift.php'
;
require_once
$app
[
'swiftmailer.class_path'
]
.
'/Swift.php'
;
\Swift
::
registerAutoload
(
$app
[
'swiftmailer.class_path'
]
.
'/../swift_init.php'
);
\Swift
::
registerAutoload
(
$app
[
'swiftmailer.class_path'
]
.
'/../swift_init.php'
);
}
}
}
}
public
function
boot
(
Application
$app
)
{
$app
->
finish
(
function
()
use
(
$app
)
{
$app
[
'swiftmailer.spooltransport'
]
->
getSpool
()
->
flushQueue
(
$app
[
'swiftmailer.transport'
]);
});
}
}
}
src/Silex/Provider/TranslationServiceProvider.php
View file @
c7536412
...
@@ -53,4 +53,8 @@ class TranslationServiceProvider implements ServiceProviderInterface
...
@@ -53,4 +53,8 @@ class TranslationServiceProvider implements ServiceProviderInterface
return
new
MessageSelector
();
return
new
MessageSelector
();
});
});
}
}
public
function
boot
(
Application
$app
)
{
}
}
}
src/Silex/Provider/TwigServiceProvider.php
View file @
c7536412
...
@@ -90,4 +90,8 @@ class TwigServiceProvider implements ServiceProviderInterface
...
@@ -90,4 +90,8 @@ class TwigServiceProvider implements ServiceProviderInterface
));
));
});
});
}
}
public
function
boot
(
Application
$app
)
{
}
}
}
src/Silex/Provider/UrlGeneratorServiceProvider.php
View file @
c7536412
...
@@ -31,4 +31,8 @@ class UrlGeneratorServiceProvider implements ServiceProviderInterface
...
@@ -31,4 +31,8 @@ class UrlGeneratorServiceProvider implements ServiceProviderInterface
return
new
UrlGenerator
(
$app
[
'routes'
],
$app
[
'request_context'
]);
return
new
UrlGenerator
(
$app
[
'routes'
],
$app
[
'request_context'
]);
});
});
}
}
public
function
boot
(
Application
$app
)
{
}
}
}
src/Silex/Provider/ValidatorServiceProvider.php
View file @
c7536412
...
@@ -43,4 +43,8 @@ class ValidatorServiceProvider implements ServiceProviderInterface
...
@@ -43,4 +43,8 @@ class ValidatorServiceProvider implements ServiceProviderInterface
return
new
ConstraintValidatorFactory
();
return
new
ConstraintValidatorFactory
();
});
});
}
}
public
function
boot
(
Application
$app
)
{
}
}
}
src/Silex/ServiceProviderInterface.php
View file @
c7536412
...
@@ -21,7 +21,19 @@ interface ServiceProviderInterface
...
@@ -21,7 +21,19 @@ interface ServiceProviderInterface
/**
/**
* Registers services on the given app.
* Registers services on the given app.
*
*
* This method should only be used to configure services and parameters.
* It should not get services.
*
* @param Application $app An Application instance
* @param Application $app An Application instance
*/
*/
function
register
(
Application
$app
);
function
register
(
Application
$app
);
/**
* Bootstraps the application.
*
* This method is called after all services are registers
* and should be used for "dynamic" configuration (whenever
* a service must be requested).
*/
function
boot
(
Application
$app
);
}
}
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