|
// ... lines 1 - 4
|
|
use Doctrine\ORM\QueryBuilder; |
|
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; |
|
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection; |
|
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; |
|
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; |
|
|
|
class QuestionPendingApprovalCrudController extends QuestionCrudController |
|
{ |
|
public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder |
|
{ |
|
return parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters) |
|
->andWhere('entity.isApproved = :approved') |
|
->setParameter('approved', false); |
|
} |
|
} |
See Code Block in Script
|
// ... lines 1 - 2
|
|
namespace App\Entity; |
|
|
|
use App\Repository\UserRepository; |
|
use Doctrine\ORM\Mapping as ORM; |
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; |
|
use Symfony\Component\Security\Core\User\UserInterface; |
|
|
|
|
|
|
|
|
|
class User implements UserInterface |
|
{ |
|
|
|
|
|
|
|
|
|
|
|
private $id; |
|
|
|
|
|
|
|
|
|
private $email; |
|
|
|
|
|
|
|
|
|
private $roles = []; |
|
// ... lines 31 - 113
|
|
} |
See Code Block in Script
|
// ... lines 1 - 2
|
|
namespace App\Entity; |
|
|
|
use App\Repository\TagRepository; |
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
|
|
|
|
|
class Tag |
|
{ |
|
|
|
|
|
|
|
|
|
|
|
private $id; |
|
|
|
|
|
|
|
|
|
private $name; |
|
|
|
public function getId(): ?int |
|
{ |
|
return $this->id; |
|
} |
|
|
|
public function getName(): ?string |
|
{ |
|
return $this->name; |
|
} |
|
|
|
public function setName(string $name): self |
|
{ |
|
$this->name = $name; |
|
|
|
return $this; |
|
} |
|
} |
See Code Block in Script
Hey Yehuda Am-Baruch!
Very good detective work! When you query for an entity (doesn't matter if it's find(), findAll(), custom query, etc) - Doctrine does *not* call your object's `__construct` method. That can be ...
... this into an object, you could create a class (in any directory, this is not managed by Doctrine) that looks like this:
```
class SalesStatistics
{
public $totalSales;
public $averageSales;
public ...
Hi Ziad!
Ah, that makes things a bit more complex :). I'm sure you're aware, but OpenSky was the company that famously setup their Doctrine to do types of things like this. There are some resources out there (http ...
... /category/list page, doctrine creates a query for every single category, because I use this inside the twig template:
```
{% for category in categories %}
...
{% for sub_category in category.children ...
... orphanRemoval option so that Doctrine fully deletes the removed Creditcards (not just unlink them from the Survey). Your way is much easier.
3) We talk about this a little bit here: http://knpuniversity.com/screencast ...
... ": "",
"file": "/home/mono/Projects/Goodness/vendor/api-platform/core/src/Bridge/Doctrine/Orm/Extension/EagerLoadingExtension.php",
"line": 137,
"args": []
},
i try to find the solution from api platform. but ...
... \Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Common\Filter\SearchFilterInterface;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter ...
... using them all at once. In that context, it's probably not that helpful.
2) How to organize Symfony project without ORM (Doctrine) to keep controllers clean and slim?
In general, the important thing is this: create ...
... () and I do not want to launch other doctrine transactions prematurely... Is lowering the priority of the event an option? If yes, to what level?
... config also automatically if you start a Symfony 4 project).
Without *any* config, Doctrine names the columns the same as your properties, which is what you're seeing. Symfony gives you this ...
Hey Joseph,
Kinda difficult to implement this feature right now. This course is introduction into Symfony 4, and we know nothing about Doctrine and relations in it. Well, probably you do, but other users may do not ...
... in case you're on Symfony 4 and use environment variables, you should not forget about resolve filter to handle the "kernel.project_dir" parameter, i.e. do this:
```
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
```
Anyway, I'm glad you found a working solution. And thanks for sharing it with others!
Cheers!
Hey Lopoi,
Yes, we do have plans to make a tutorial about Forms for Symfony 4 track. Right now we're releasing Doctrine tutorial, the Forms one should be the next I think in Symfony 4 track. But between those tutorials ...
... # src/Yoda/UserBundle/Resources/config/services.yml
services:
doctrine.user_listener:
class: Yoda\UserBundle\Doctrine\UserListener
arugments: ["@security.encoder_factory"]
tags ...
Hey Mauro!
Yea, these commands are still being updated to work with Symfony 4. The big issue is actually pretty simple: you don't have a bundle in Symfony 4 :). Here are some more details: https://github.com/doctrine ...
Hey Nizar!
You can read about all of that here: https://symfony.com/doc/current/doctrine/multiple_entity_managers.html. The configuration in that article will need to be a bit different to support environment variables ...
... Doctrine's DQL and doing object's hydration by your own,
This course may give some good ideas: https://knpuniversity.com/screencast/doctrine-queries
Cheers and thanks for sharing your solution!
2725
Doctrine
Filter Results