1000 search results

93 lines | src/Entity/Article.php
// ... lines 1 - 4
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ArticleRepository")
*/
class Article
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="string", length=100)
*/
private $slug;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $content;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $publishedAt;
// ... lines 38 - 91
}
See Code Block in Script
54 lines | src/Repository/ArticleRepository.php
// ... lines 1 - 6
use Doctrine\ORM\QueryBuilder;
// ... lines 8 - 15
class ArticleRepository extends ServiceEntityRepository
{
// ... lines 18 - 48
private function addIsPublishedQueryBuilder(QueryBuilder $qb)
{
// ... line 51
}
}
See Code Block in Script
58 lines | src/Repository/ArticleRepository.php
// ... lines 1 - 6
use Doctrine\ORM\QueryBuilder;
// ... lines 8 - 15
class ArticleRepository extends ServiceEntityRepository
{
// ... lines 18 - 52
private function getOrCreateQueryBuilder(QueryBuilder $qb = null)
{
// ... line 55
}
}
See Code Block in Script
75 lines | src/Controller/ArticleController.php
// ... lines 1 - 8
use Doctrine\ORM\EntityManagerInterface;
// ... lines 10 - 16
class ArticleController extends AbstractController
{
// ... lines 19 - 61
/**
* @Route("/news/{slug}/heart", name="article_toggle_heart", methods={"POST"})
*/
public function toggleArticleHeart(Article $article, LoggerInterface $logger, EntityManagerInterface $em)
{
// ... lines 67 - 72
}
}
See Code Block in Script
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