Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Chapter 2 code#12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base:chapter-1
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Chapter 2 code #12
Changes from all commits
c198d8a6a8465e715eef1fe04d0fb887f5f776f323b5a00a7d1c5d96a93cdc88ff40317a22f638761a5fcd1e8d94a20431File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,3 @@ | ||
| # tutorial-101 | ||
| Book tutorial starting from Dotkernel Light: Level 101 beginner | ||
| ### BRANCH : - main unde e documentatia , se compileaza documentatia. aplicatie din light, deploy functional !!!! --> 101.dotkernel.net | ||
| 1. instalezi light la tine pe WSL2 | ||
| 2. iei chapter 1, citesti documentation, implementezi una cite una | ||
| - CHAPTER-1-doctrine # protected - including Light, and add visible DIFF between branches | ||
| - CHAPTER-2- forms # protected | ||
| - CHAPTER-3- inputfilter # protected | ||
| - CHAPTER-4 -list books # protected | ||
| main: incepi de la light , clone | ||
| - adaigi folderul docs/book cu structura asta https://github.com/dotkernel/dot-session/tree/5.0/docs/book | ||
| - cu fisier symlink si etc. | ||
| Book tutorial starting from Dotkernel Light: Level 101 beginner |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/usr/bin/env php | ||
| <?php | ||
| declare(strict_types=1); | ||
| namespace Doctrine\Migrations; | ||
| require __DIR__ . '/../vendor/doctrine/migrations/bin/doctrine-migrations.php'; |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
| use Doctrine\Migrations\Configuration\EntityManager\ExistingEntityManager; | ||
| use Doctrine\Migrations\Configuration\Migration\ConfigurationArray; | ||
| use Doctrine\Migrations\DependencyFactory; | ||
| use Doctrine\ORM\EntityManager; | ||
| $container = require 'config/container.php'; | ||
| $entityManager = $container->get(EntityManager::class); | ||
| $entityManager->getEventManager(); | ||
| return DependencyFactory::fromEntityManager( | ||
| new ConfigurationArray($container->get('config')['doctrine']['migrations']), | ||
| new ExistingEntityManager($entityManager) | ||
| ); |
alexmerlin marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
alexmerlin marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
| namespace Light\App\DBAL\Types; | ||
| use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
| class UuidType extends \Ramsey\Uuid\Doctrine\UuidType | ||
| { | ||
| public const NAME = 'uuid'; | ||
| public function getSQLDeclaration(array $column, AbstractPlatform $platform): string | ||
| { | ||
| return 'UUID'; | ||
| } | ||
| } |
alexmerlin marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
| namespace Light\App\Entity; | ||
| use DateTimeImmutable; | ||
| use Doctrine\ORM\Mapping as ORM; | ||
| use Laminas\Stdlib\ArraySerializableInterface; | ||
| use Ramsey\Uuid\Uuid; | ||
| use Ramsey\Uuid\UuidInterface; | ||
| use function is_array; | ||
| use function method_exists; | ||
| use function ucfirst; | ||
| #[ORM\MappedSuperclass] | ||
| abstract class AbstractEntity implements ArraySerializableInterface | ||
| { | ||
| #[ORM\Id] | ||
| #[ORM\Column(name: 'id', type: 'uuid', unique: true, nullable: false)] | ||
| protected UuidInterface $id; | ||
| #[ORM\Column(name: 'created', type: 'datetime_immutable', nullable: false)] | ||
| protected DateTimeImmutable $created; | ||
| #[ORM\Column(name: 'updated', type: 'datetime_immutable', nullable: true)] | ||
| protected ?DateTimeImmutable $updated = null; | ||
| public function __construct() | ||
| { | ||
| $this->id = Uuid::uuid7(); | ||
| } | ||
| public function getId(): UuidInterface | ||
| { | ||
| return $this->id; | ||
| } | ||
| public function setId(UuidInterface $id): static | ||
| { | ||
| $this->id = $id; | ||
| return $this; | ||
| } | ||
| public function getCreated(): ?DateTimeImmutable | ||
| { | ||
| return $this->created; | ||
| } | ||
| public function getCreatedFormatted(string $dateFormat = 'Y-m-d H:i:s'): string | ||
| { | ||
| return $this->created->format($dateFormat); | ||
| } | ||
| public function getUpdated(): ?DateTimeImmutable | ||
| { | ||
| return $this->updated; | ||
| } | ||
| public function getUpdatedFormatted(string $dateFormat = 'Y-m-d H:i:s'): ?string | ||
| { | ||
| if ($this->updated instanceof DateTimeImmutable) { | ||
| return $this->updated->format($dateFormat); | ||
| } | ||
| return null; | ||
| } | ||
| #[ORM\PrePersist] | ||
| public function created(): void | ||
| { | ||
| $this->created = new DateTimeImmutable(); | ||
| } | ||
| #[ORM\PreUpdate] | ||
| public function touch(): void | ||
| { | ||
| $this->updated = new DateTimeImmutable(); | ||
| } | ||
| /** | ||
| * @param array<non-empty-string, mixed> $array | ||
| */ | ||
| public function exchangeArray(array $array): void | ||
| { | ||
| foreach ($array as $property => $values) { | ||
| if (is_array($values)) { | ||
| $method = 'add' . ucfirst($property); | ||
| if (! method_exists($this, $method)) { | ||
| continue; | ||
| } | ||
| foreach ($values as $value) { | ||
| $this->$method($value); | ||
| } | ||
| } else { | ||
| $method = 'set' . ucfirst($property); | ||
| if (! method_exists($this, $method)) { | ||
| continue; | ||
| } | ||
| $this->$method($values); | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
| namespace Light\App\Entity; | ||
| use DateTimeImmutable; | ||
| use Ramsey\Uuid\UuidInterface; | ||
| interface EntityInterface | ||
| { | ||
| public function getId(): UuidInterface; | ||
| public function getCreated(): ?DateTimeImmutable; | ||
| public function getCreatedFormatted(string $dateFormat = 'Y-m-d H:i:s'): string; | ||
| public function getUpdated(): ?DateTimeImmutable; | ||
| public function getUpdatedFormatted(string $dateFormat = 'Y-m-d H:i:s'): ?string; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.