symfony

Access currently logged in user in UserRepository in Sylius

六眼飞鱼酱① 提交于 2021-02-08 07:04:52
问题 I would like to do something like this. sylius_backend_user_index: pattern: / methods: [GET] defaults: _controller: sylius.controller.user:indexAction _sylius: template: SyliusWebBundle:Backend/User:index.html.twig method: createFilterPaginator arguments: [$criteria, $sorting, $deleted, @service_container] I would like to access service_container in createFilterPaginator method. Can any one help me to sort out this issue? 回答1: First of all, no need for the whole service container, you need

Access currently logged in user in UserRepository in Sylius

醉酒当歌 提交于 2021-02-08 07:01:29
问题 I would like to do something like this. sylius_backend_user_index: pattern: / methods: [GET] defaults: _controller: sylius.controller.user:indexAction _sylius: template: SyliusWebBundle:Backend/User:index.html.twig method: createFilterPaginator arguments: [$criteria, $sorting, $deleted, @service_container] I would like to access service_container in createFilterPaginator method. Can any one help me to sort out this issue? 回答1: First of all, no need for the whole service container, you need

Incompatibility with maker bundle and Registry - SYMFONY

为君一笑 提交于 2021-02-08 06:56:27
问题 I'm new to Symfony and I'm creating a blog for personal use. But when I try to add fields to an entity using the command php bin/console make:entity an error pops out. Argument 2 passed to Symfony\Bundle\MakerBundle\Validator::validateDoctrineFieldName() must be an instance of Doctrine\Common\Persistence\ManagerRegistry, instance of Doctrine\Bundle\DoctrineBundle\Registry given, call ed in C:\Users\user\Documents\CODING\Symfony\calidad\vendor\symfony\maker-bundle\src\Maker\MakeEntity.p hp on

How to subscribe to the DataTableFactory service?

坚强是说给别人听的谎言 提交于 2021-02-08 06:41:40
问题 I am trying to use DataTablesBundle in Symfony 4.2. There is very good manual and starter however it is used with extends Controller class. But I am trying to use it with AbstractController class. So I have such issue: Service " Omines\DataTablesBundle\DataTableFactory " not found: even though it exists in the app's container, the container inside " App\Controller\StaffController " is a smaller service locator that only knows about the " doctrine ", " form.factory ", " http_kernel ", "

How to do username case insensitive in login form?

本小妞迷上赌 提交于 2021-02-08 06:37:33
问题 I'm using the login form from Symfony, but I can't login, if the entered username is 'FOO' and in the DB is stored 'foo'. I'm using Postgres. It means the username-field is case sensitive. What can I do? 回答1: This depends mainly on your Database-Server. MySQL is case insensitive, PostgreSQL is case sensitive. But you can write query Like this $this->createQueryBuilder('user') ->where('LOWER(user.username) = :username') ->setParameter('username', strtolower($username)) ->getQuery() ->getResult

Use query_builder on CollectionType in symfony4 forms?

我怕爱的太早我们不能终老 提交于 2021-02-08 03:31:48
问题 In a symfony 4 form, I need to use something like a query_builder option that is available on EntityType but from a CollectionType . There is a similar question here with no good answers. In my project, each Site entity has many Goal . Each Goal has a numeric goal and a specific date. I'd like to edit the goals of a site for a specific date only. The problem is that a CollectionType form pulls all goals to show in the form, but I only want to pull the goals for a given date. How? There is no

Use query_builder on CollectionType in symfony4 forms?

☆樱花仙子☆ 提交于 2021-02-08 03:31:22
问题 In a symfony 4 form, I need to use something like a query_builder option that is available on EntityType but from a CollectionType . There is a similar question here with no good answers. In my project, each Site entity has many Goal . Each Goal has a numeric goal and a specific date. I'd like to edit the goals of a site for a specific date only. The problem is that a CollectionType form pulls all goals to show in the form, but I only want to pull the goals for a given date. How? There is no

How to attach cookies to JSON Response in symfony2?

孤街浪徒 提交于 2021-02-07 19:16:17
问题 I have JSON endpoint which is used to add product to cart. It checks whether the cart already exists or no. If not then it creates a cart and the cart Id is stored in cookie. So I how do I attach cookie to the symfony2's JsonResponse ? In a non ajax version if I am rendering a template from my action I can use: $response = new Response(); $response->headers->setCookie(new Cookie(‘cookie_name’, ‘cookie_value’)); $this->render('<template_path>', '<array_options>', $response); Please help me on

How to attach cookies to JSON Response in symfony2?

血红的双手。 提交于 2021-02-07 19:12:14
问题 I have JSON endpoint which is used to add product to cart. It checks whether the cart already exists or no. If not then it creates a cart and the cart Id is stored in cookie. So I how do I attach cookie to the symfony2's JsonResponse ? In a non ajax version if I am rendering a template from my action I can use: $response = new Response(); $response->headers->setCookie(new Cookie(‘cookie_name’, ‘cookie_value’)); $this->render('<template_path>', '<array_options>', $response); Please help me on

How to override bundled Doctrine repository in Symfony

大城市里の小女人 提交于 2021-02-07 14:35:13
问题 I have an independent Symfony bundle (installed with Composer) with entities and repositories to share between my applications that connect same database. Entities are attached to every applications using configuration (yml shown): doctrine: orm: mappings: acme: type: annotation dir: %kernel.root_dir%/../vendor/acme/entities/src/Entities prefix: Acme\Entities alias: Acme Well, it was the easiest way to include external entities in application, but looks a bit ugly. Whenever I get repository