symfony-2.3

No cache header with annotation

会有一股神秘感。 提交于 2019-11-27 15:15:30
问题 In order to set the response without the cache in the controller you can do this: $response = new Response(); $result = $this->renderView( 'AcmeDemoBundle:Default:index.html.twig', array('products' => $products, 'form' => $form->createView())); $response->headers->addCacheControlDirective('no-cache', true); $response->headers->addCacheControlDirective('max-age', 0); $response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->addCacheControlDirective('no-store',

Symfony2 LTS: how to upgrade from 2.3 to 2.7?

六眼飞鱼酱① 提交于 2019-11-27 13:23:24
问题 Symfony 2.7 was released on 30th April 2015 and is the current LTS (Long Term Support) version after the 2.3 version. Maintenance for these versions will end on May 2016 for Symfony 2.3 and May 2018 for Symfony 2.7. Security fixes will be released during one year after end of maintenance for both versions. As suggested by Massimiliano Arione in the announce comments, what are the changes required to upgrade from Symfony 2.3 from 2.7 without having to check all the minor upgrades (2.3 → 2.4, 2

How to give container as argument to services

六眼飞鱼酱① 提交于 2019-11-27 08:15:17
in my services constructor public function __construct( EntityManager $entityManager, SecurityContextInterface $securityContext) { $this->securityContext = $securityContext; $this->entityManager = $entityManager; I pass entityManager and securityContext as argument. also my services.xml is here <service id="acme.memberbundle.calendar_listener" class="Acme\MemberBundle\EventListener\CalendarEventListener"> <argument type="service" id="doctrine.orm.entity_manager" /> <argument type="service" id="security.context" /> but now,I want to use container in services such as $this->container->get(

Translations in Symfony 2.3 locale in request

天大地大妈咪最大 提交于 2019-11-27 08:05:38
问题 How can I change locale in Symfony 2.3 ? I created this controller: public function changelocaleAction($lang) { $request = $this->get('request'); $request->setLocale($lang); return $this->redirect($request->headers->get('referer')); } It doesn't show changes when the page is refreshed. Why? 回答1: Based on Symfony2 documentation: namespace Acme\LocaleBundle\EventListener; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony

How do I read from parameters.yml in a controller in symfony2?

雨燕双飞 提交于 2019-11-27 00:00:52
问题 I have put a couple of custom variables in my app/config/parameters.yml. parameters: api_pass: apipass api_user: apiuser I need to access these from my controller, and have tried to fetch them with $this->get('api_user'); from within my controller file. When I try this, I get this error message: You have requested a non-existent service "api_user". What is the correct way to do this? 回答1: In Symfony 2.6 and older versions , to get a parameter in a controller - you should get the container

How does the login check_path route work without default controller/action?

元气小坏坏 提交于 2019-11-26 20:24:33
I am working on symfony 2.3 project having the following routing code just2_frontend_logincheck: pattern: /login_check It doesn't have defaults:{ _controller: testBundle:User:login } But it is working. But I don't know how the routing is working. Is it possible? Please advice me about the routing. Nicolai Fröhlich The check_path route/path is used by your firewall to catch login requests. This route's action is never really accessed. It's the route/url your login form posts to and the request should be processed by your firewall's provider service. If the check_path route's action is being

Symfony how to return all logged in Active Users

烈酒焚心 提交于 2019-11-26 19:39:23
问题 I want to return all Logged in users of my application and render it in my Dashboard. The user_id and user_name should be retrieved from the session (I am using an external LDAP Library for authentication) I have created a field in the database called lastActivity which will contain the last login time and then I can query the database for lastActivity display users logged in in the last 2 minutes. ActivityListener.php <?php namespace Bnpp\SecurityBundle\EventListener; use Doctrine\ORM