$methodMap = []; public function get($id) { // Re-use shared service instance if it exists. if (isset($this->services[$id])) { return $this->services[$id]; } // Lazy instantiate the service $method = $this->methodMap[$id]; return call_user_func(array($this, $method)); } }
Logger is simply fetched from array map $logger2 = $container->get('logger'); // Two variables reference same instance var_dump($logger1 === $logger2);
by the Security Component instead of the Form Component Keeping a backward compatibility layer with the old API until it’s removed in Symfony 3.0 Adapting the new CSRF API
CsrfTokenManagerInterface { public function getToken($tokenId); public function refreshToken($tokenId); public function removeToken($tokenId); public function isTokenValid(CsrfToken $token); }
$csrfProvider; public function __construct(CsrfProviderInterface $csrfProvider) { $this->csrfProvider = $csrfProvider; } public function refreshToken($tokenId) { throw new BadMethodCallException('Not supported'); } public function removeToken($tokenId) { throw new BadMethodCallException('Not supported'); } }
HttpKernel class doesn’t support caching capabilities. Symfony provides an HttpCache class to decorate an instance of HttpKernel in order to emulate an HTTP reverse proxy cache.
dispatch($eventName, Event $event = null); function getListeners($eventName); function hasListeners($eventName); function addListener($eventName, $listener, $priority = 0); function removeListener($eventName, $listener); function addSubscriber(EventSubscriberInterface $subscriber); function removeSubscriber(EventSubscriberInterface $subscriber); }
request kernel.controller Initializes the controller before it’s executed kernel.view Generates a template view kernel.response Prepares the HTTP response nefore it’s sent kernel.exception Handles all caught exceptions kernel.terminate Terminates the kernel
they’re bound to the form form.bind Changes data into the normalized representation form.post_bind Changes the data after they are bound to the form form.pre_set_data Changes the original form data form.post_set_data Changes data after they were mapped to the form
security.switch_user User switched to another user account. security.authentication.success User is authenticated by a provider security.authentication.failure User cannobt be authenticated by a provider
// Filesystem storage $fsStorage = new FileProfilerStorage('/tmp/profiler'); $profiler = new Profiler($fsStorage); $profiler->saveProfile($profile); // Mysql database storage $dsn = 'mysql:host=localhost'; $dbStorage = new MySQLProfilerStorage($dsn); $profiler = new Profiler($dbStorage); $profiler->saveProfile($profile); Using the Profiler