Skip to content

Commit

Permalink
attributes instead of annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
msalakhov committed Apr 12, 2022
1 parent 89f39ce commit 1422c27
Show file tree
Hide file tree
Showing 17 changed files with 196 additions and 584 deletions.
2 changes: 1 addition & 1 deletion app/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ doctrine:
mappings:
App:
is_bundle: false
type: annotation
type: attribute
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
4 changes: 1 addition & 3 deletions app/src/Controller/Admin/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

class AdminController extends AbstractDashboardController
{
/**
* @Route("/admin", name="admin")
*/
#[Route('/admin', name: 'admin')]
public function index(): Response
{
return parent::index();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\CollectionField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use phpDocumentor\Reflection\Types\Integer;

class InsuranceObjectsTypesFieldsCrudController extends AbstractCrudController
{
Expand Down
6 changes: 1 addition & 5 deletions app/src/Controller/Admin/UserCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use phpDocumentor\Reflection\Types\Boolean;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;

class UserCrudController extends AbstractCrudController
{
private $userRepository;

public function __construct(UserRepository $userRepository)
public function __construct(private UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}

public static function getEntityFqcn(): string
Expand Down
2 changes: 0 additions & 2 deletions app/src/Controller/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
use App\Repository\AttachmentsRepository;
use App\Repository\ClientInsuranceRepository;
use App\Repository\InsuranceAttachmentsRepository;
use App\Repository\UserRepository;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\ObjectManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down
8 changes: 2 additions & 6 deletions app/src/Controller/UserAuthSecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

class UserAuthSecurityController extends AbstractController
{
/**
* @Route("/login", name="app_login")
*/
#[Route('/login', name: 'app_login')]
public function login(AuthenticationUtils $authenticationUtils): Response
{
// if ($this->getUser()) {
Expand All @@ -26,9 +24,7 @@ public function login(AuthenticationUtils $authenticationUtils): Response
return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
}

/**
* @Route("/logout", name="app_logout")
*/
#[Route('/logout', name: 'app_logout')]
public function logout()
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
Expand Down
2 changes: 0 additions & 2 deletions app/src/DataFixtures/ClientFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

namespace App\DataFixtures;

use App\ImageOptimizer;
use App\Entity\Client;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use Faker\Factory;
use Faker\Generator;
use Symfony\Component\HttpFoundation\File\Exception\FileException;

class ClientFixture extends Fixture implements DependentFixtureInterface
{
Expand Down
25 changes: 8 additions & 17 deletions app/src/Entity/Attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,24 @@
namespace App\Entity;

use App\Repository\AttachmentsRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity(repositoryClass=AttachmentsRepository::class)
*/
#[ORM\Entity(repositoryClass: AttachmentsRepository::class)]
class Attachments
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue()]
#[ORM\Column(type: Types::INTEGER)]
private $id;

/**
* @ORM\Column(type="string", length=255)
*/
#[ORM\Column(type: Types::STRING, length: 255)]
private $path;

/**
* @ORM\Column(type="string", length=255)
*/
#[ORM\Column(type: Types::STRING, length: 255)]
private $name;

/**
* @ORM\Column(type="integer")
*/
#[ORM\Column(type: Types::INTEGER)]
private $userId;

public function getId(): ?int
Expand Down
59 changes: 16 additions & 43 deletions app/src/Entity/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,42 @@
namespace App\Entity;

use App\Repository\ClientRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
* @ORM\Entity(repositoryClass="App\Repository\ClientRepository", repositoryClass=ClientRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
#[ORM\Entity(repositoryClass: ClientRepository::class)]
#[ORM\HasLifecycleCallbacks()]
class Client
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue()]
#[ORM\Column(type: Types::INTEGER)]
private $id;

/**
* @ORM\Column(type="string", length=50)
*
* @Assert\NotBlank()
*/
#[ORM\Column(type: Types::STRING, length: 50)]
#[Assert\NotBlank()]
private $name;

/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
#[ORM\Column(type: Types::STRING, length: 100, nullable: true)]
private $city;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private $photo;

/**
* @ORM\Column(type="string", nullable=false)
*/
#[ORM\Column(type: Types::STRING, nullable: false)]
private $email;

/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="clients")
* @ORM\JoinColumn(nullable=false)
*/
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: "clients")]
#[ORM\JoinColumn(nullable: false)]
private $user;

/**
* @ORM\Column(type="date", nullable=true)
*/
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private $renewal_term;

/**
* @ORM\Column(type="datetime_immutable")
*/
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
private $createdAt;

// public function __construct($name, $city, $photo)
// {
// $this->name = $name;
// $this->city = $city;
// $this->photo = $photo;
// }

public function getId(): ?int
{
return $this->id;
Expand Down Expand Up @@ -144,9 +119,7 @@ public function getCreatedAt(): ?\DateTimeImmutable
return $this->createdAt;
}

/**
* @ORM\PrePersist
*/
#[ORM\PrePersist]
public function setCreatedAtValue(): void
{
$this->createdAt = new \DateTimeImmutable();
Expand Down
Loading

0 comments on commit 1422c27

Please sign in to comment.