1000 search results

36 lines | src/Form/StarshipPartType.php
// ... lines 1 - 6
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
// ... lines 8 - 12
class StarshipPartType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
// ... lines 18 - 20
->add('starship', EntityType::class, [
'class' => Starship::class,
'choice_label' => 'id',
])
// ... line 25
;
}
// ... lines 28 - 34
}
See Code Block in Script
I'm really hoping Doctrine ORM 3.4 comes out soon, so we can use Property Hooks. This makes lazy-loading MUCH easier, and will allow us to get rid of lots of boilerplate setters/getters. Please consider including that functionality with this course. I…
Tac-Tacelosky
Tac-Tacelosky
Read Full Comment
24 lines | config/packages/messenger.yaml
framework:
messenger:
// ... lines 3 - 5
transports:
// ... lines 7 - 8
failed: 'doctrine://default?queue_name=failed'
// ... lines 10 - 24
See Code Block in Script
At my doctrine.yaml I have the following configuration: ```yaml doctrine: dbal: url: '%env(resolve:DATABASE_URL)%' ``` I want to connect to 2 different databases with the following configuration: ```yaml dbal: connections: default_connection: default default: url: '%env(resolve:DATABASE_URL)%' old_wtb: url: '%env…
166 lines | src/Entity/DragonTreasure.php
// ... lines 1 - 4
use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Metadata\ApiFilter;
// ... lines 7 - 38
#[ApiFilter(BooleanFilter::class, properties: ['isPublished'])]
class DragonTreasure
{
// ... lines 42 - 164
}
See Code Block in Script
Last example in [Doctrine documentation about fetching entities automatically](https://symfony.com/doc/current/doctrine.html#fetch-automatically) is missing essential parameter to the MapEntity: FQCN of the Entity, it should be: ```php #[Route('/product/{id}/comments')] public function show( Product $product, #[MapEntity(expr: 'repository…
39 lines | src/Controller/MainController.php
// ... lines 1 - 6
use Pagerfanta\Doctrine\ORM\QueryAdapter;
// ... lines 8 - 14
class MainController extends AbstractController
{
// ... line 17
public function homepage(
// ... lines 19 - 23
): Response
{
$pager = Pagerfanta::createForCurrentPageWithMaxPerPage(
new QueryAdapter($voyageRepository->findBySearchQueryBuilder($query, $searchPlanets)),
$page,
10
);
// ... lines 31 - 36
}
}
See Code Block in Script
16 lines | src/ApiResource/UserApi.php
// ... lines 1 - 4
use ApiPlatform\Doctrine\Orm\State\CollectionProvider;
// ... lines 6 - 7
#[ApiResource(
shortName: 'User',
provider: CollectionProvider::class,
)]
class UserApi
{
public ?int $id = null;
}
See Code Block in Script
19 lines | src/ApiResource/UserApi.php
// ... lines 1 - 4
use ApiPlatform\Doctrine\Orm\State\CollectionProvider;
use ApiPlatform\Doctrine\Orm\State\Options;
// ... line 7
use App\Entity\User;
#[ApiResource(
shortName: 'User',
provider: CollectionProvider::class,
stateOptions: new Options(entityClass: User::class),
)]
class UserApi
{
public ?int $id = null;
}
See Code Block in Script
33 lines | src/ApiResource/UserApi.php
// ... lines 1 - 4
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
// ... line 6
use ApiPlatform\Metadata\ApiFilter;
// ... lines 8 - 16
#[ApiFilter(SearchFilter::class, properties: [
'username' => 'partial',
])]
class UserApi
{
// ... lines 22 - 31
}
See Code Block in Script
31 lines | src/State/DragonTreasureStateProcessor.php
// ... lines 1 - 10
#[AsDecorator('api_platform.doctrine.orm.state.persist_processor')]
class DragonTreasureStateProcessor implements ProcessorInterface
{
// ... lines 14 - 17
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): void
{
if ($data instanceof DragonTreasure && $data->getOwner() === null && $this->security->getUser()) {
$data->setOwner($this->security->getUser());
}
// ... lines 23 - 28
}
}
See Code Block in Script
41 lines | src/State/DragonTreasureStateProvider.php
// ... lines 1 - 4
use ApiPlatform\Doctrine\Orm\State\CollectionProvider;
// ... lines 6 - 13
class DragonTreasureStateProvider implements ProviderInterface
{
public function __construct(
// ... line 17
#[Autowire(service: CollectionProvider::class)] private ProviderInterface $collectionProvider,
// ... line 19
)
{
}
// ... lines 23 - 39
}
See Code Block in Script
// ... lines 1 - 5
use ApiPlatform\Doctrine\Orm\Extension\QueryItemExtensionInterface;
// ... lines 7 - 11
class DragonTreasureIsPublishedExtension implements QueryCollectionExtensionInterface, QueryItemExtensionInterface
{
// ... lines 14 - 24
public function applyToItem(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, array $identifiers, Operation $operation = null, array $context = []): void
{
// TODO: Implement applyToItem() method.
}
}
See Code Block in Script
131 lines | src/Entity/User.php
// ... lines 1 - 10
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
// ... lines 12 - 18
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
#[UniqueEntity(fields: ['username'], message: 'It looks like another dragon took your username. ROAR!')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
// ... lines 23 - 129
}
See Code Block in Script
131 lines | src/Entity/User.php
// ... lines 1 - 10
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
// ... lines 13 - 18
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
#[UniqueEntity(fields: ['username'], message: 'It looks like another dragon took your username. ROAR!')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
// ... lines 23 - 29
#[Assert\NotBlank]
// ... line 31
private ?string $email = null;
// ... lines 33 - 129
}
See Code Block in Script
131 lines | src/Entity/User.php
// ... lines 1 - 10
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
// ... lines 13 - 18
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
#[UniqueEntity(fields: ['username'], message: 'It looks like another dragon took your username. ROAR!')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
// ... lines 23 - 29
#[Assert\NotBlank]
#[Assert\Email]
private ?string $email = null;
// ... lines 33 - 45
#[Assert\NotBlank]
private ?string $username = null;
// ... lines 48 - 129
}
See Code Block in Script
Hey Dmitriy, But Doctrine already does this for you. You just need to generate an entity via MakerBundle, or make sure your User entity has this mapping config: ```php User { #[ORM\Id, ORM\Column, ORM\GeneratedValue] private ?int $id = null; } ``` Every time you will…
168 lines | src/Entity/DragonTreasure.php
// ... lines 1 - 5
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
// ... lines 7 - 39
class DragonTreasure
{
// ... lines 42 - 48
#[ApiFilter(SearchFilter::class, strategy: 'partial')]
private ?string $name = null;
// ... lines 51 - 166
}
See Code Block in Script
169 lines | src/Entity/DragonTreasure.php
// ... lines 1 - 5
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
// ... lines 7 - 39
class DragonTreasure
{
// ... lines 42 - 48
#[ApiFilter(SearchFilter::class, strategy: 'partial')]
private ?string $name = null;
// ... lines 51 - 53
#[ApiFilter(SearchFilter::class, strategy: 'partial')]
private ?string $description = null;
// ... lines 56 - 167
}
See Code Block in Script
171 lines | src/Entity/DragonTreasure.php
// ... lines 1 - 6
use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
// ... lines 8 - 40
class DragonTreasure
{
// ... lines 43 - 62
#[ApiFilter(RangeFilter::class)]
private ?int $value = null;
// ... lines 65 - 169
}
See Code Block in Script