Add StofDoctrineExtensions (Timestampable)

master
Julien Rosset 2 years ago
parent 703367a724
commit 1d1d681f89

@ -25,7 +25,7 @@ APP_SECRET=d484088b38870d327fe91ef10147c41d
# #
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" # DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4" # DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4"
DATABASE_URL="mysql://web_edm:%env(DATABASE_PASSWORD)%@127.0.0.1:3306/app?serverVersion=10.11.3-MariaDB&charset=utf8mb4" DATABASE_URL="mysql://web_edm:%env(DATABASE_PASSWORD)%@127.0.0.1:3306/web_edm?serverVersion=10.11.3-MariaDB&charset=utf8mb4"
# DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=15&charset=utf8" # DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=15&charset=utf8"
###< doctrine/doctrine-bundle ### ###< doctrine/doctrine-bundle ###

@ -138,6 +138,9 @@
<path value="$PROJECT_DIR$/vendor/symfony/finder" /> <path value="$PROJECT_DIR$/vendor/symfony/finder" />
<path value="$PROJECT_DIR$/vendor/symfony/framework-bundle" /> <path value="$PROJECT_DIR$/vendor/symfony/framework-bundle" />
<path value="$PROJECT_DIR$/vendor/symfony/form" /> <path value="$PROJECT_DIR$/vendor/symfony/form" />
<path value="$PROJECT_DIR$/vendor/gedmo/doctrine-extensions" />
<path value="$PROJECT_DIR$/vendor/behat/transliterator" />
<path value="$PROJECT_DIR$/vendor/stof/doctrine-extensions-bundle" />
</include_path> </include_path>
</component> </component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.1"> <component name="PhpProjectSharedConfiguration" php_language_level="8.1">

@ -130,6 +130,9 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/finder" /> <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/finder" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/framework-bundle" /> <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/framework-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/form" /> <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/form" />
<excludeFolder url="file://$MODULE_DIR$/vendor/gedmo/doctrine-extensions" />
<excludeFolder url="file://$MODULE_DIR$/vendor/behat/transliterator" />
<excludeFolder url="file://$MODULE_DIR$/vendor/stof/doctrine-extensions-bundle" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />

@ -13,6 +13,7 @@
"doctrine/orm": "^2.15", "doctrine/orm": "^2.15",
"phpdocumentor/reflection-docblock": "^5.3", "phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.20", "phpstan/phpdoc-parser": "^1.20",
"stof/doctrine-extensions-bundle": "^1.7",
"symfony/asset": "6.2.*", "symfony/asset": "6.2.*",
"symfony/console": "6.2.*", "symfony/console": "6.2.*",
"symfony/doctrine-messenger": "6.2.*", "symfony/doctrine-messenger": "6.2.*",

235
composer.lock generated

@ -4,8 +4,57 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "a736a817c023df9a07c982ffb5f7b2c9", "content-hash": "27ec98e1e5ebc13fb8e85dbf04b0edaa",
"packages": [ "packages": [
{
"name": "behat/transliterator",
"version": "v1.5.0",
"source": {
"type": "git",
"url": "https://github.com/Behat/Transliterator.git",
"reference": "baac5873bac3749887d28ab68e2f74db3a4408af"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Behat/Transliterator/zipball/baac5873bac3749887d28ab68e2f74db3a4408af",
"reference": "baac5873bac3749887d28ab68e2f74db3a4408af",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"require-dev": {
"chuyskywalker/rolling-curl": "^3.1",
"php-yaoi/php-yaoi": "^1.0",
"phpunit/phpunit": "^8.5.25 || ^9.5.19"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Behat\\Transliterator\\": "src/Behat/Transliterator"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Artistic-1.0"
],
"description": "String transliterator",
"keywords": [
"i18n",
"slug",
"transliterator"
],
"support": {
"issues": "https://github.com/Behat/Transliterator/issues",
"source": "https://github.com/Behat/Transliterator/tree/v1.5.0"
},
"time": "2022-03-30T09:27:43+00:00"
},
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
"version": "2.0.1", "version": "2.0.1",
@ -1458,6 +1507,116 @@
], ],
"time": "2023-01-14T14:17:03+00:00" "time": "2023-01-14T14:17:03+00:00"
}, },
{
"name": "gedmo/doctrine-extensions",
"version": "v3.11.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine-extensions/DoctrineExtensions.git",
"reference": "ae4bdf0d567e06b6bb1902a560ee78961b230953"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine-extensions/DoctrineExtensions/zipball/ae4bdf0d567e06b6bb1902a560ee78961b230953",
"reference": "ae4bdf0d567e06b6bb1902a560ee78961b230953",
"shasum": ""
},
"require": {
"behat/transliterator": "~1.2",
"doctrine/annotations": "^1.13 || ^2.0",
"doctrine/collections": "^1.2 || ^2.0",
"doctrine/common": "^2.13 || ^3.0",
"doctrine/event-manager": "^1.2 || ^2.0",
"doctrine/persistence": "^2.2 || ^3.0",
"php": "^7.2 || ^8.0",
"psr/cache": "^1 || ^2 || ^3",
"symfony/cache": "^4.4 || ^5.3 || ^6.0",
"symfony/deprecation-contracts": "^2.1 || ^3.0"
},
"conflict": {
"doctrine/cache": "<1.11",
"doctrine/dbal": "<2.13.1 || ^3.0 <3.2",
"doctrine/mongodb-odm": "<2.3",
"doctrine/orm": "<2.10.2",
"sebastian/comparator": "<2.0"
},
"require-dev": {
"doctrine/cache": "^1.11 || ^2.0",
"doctrine/dbal": "^2.13.1 || ^3.2",
"doctrine/doctrine-bundle": "^2.3",
"doctrine/mongodb-odm": "^2.3",
"doctrine/orm": "^2.10.2",
"friendsofphp/php-cs-fixer": "^3.4.0,<3.10",
"nesbot/carbon": "^2.55",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^8.5 || ^9.5",
"symfony/console": "^4.4 || ^5.3 || ^6.0",
"symfony/phpunit-bridge": "^6.0",
"symfony/yaml": "^4.4 || ^5.3 || ^6.0"
},
"suggest": {
"doctrine/mongodb-odm": "to use the extensions with the MongoDB ODM",
"doctrine/orm": "to use the extensions with the ORM",
"symfony/cache": "to cache parsed annotations"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.12-dev"
}
},
"autoload": {
"psr-4": {
"Gedmo\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gediminas Morkevicius",
"email": "gediminas.morkevicius@gmail.com"
},
{
"name": "Gustavo Falco",
"email": "comfortablynumb84@gmail.com"
},
{
"name": "David Buchmann",
"email": "david@liip.ch"
}
],
"description": "Doctrine behavioral extensions",
"homepage": "http://gediminasm.org/",
"keywords": [
"Blameable",
"behaviors",
"doctrine",
"extensions",
"gedmo",
"loggable",
"nestedset",
"odm",
"orm",
"sluggable",
"sortable",
"timestampable",
"translatable",
"tree",
"uploadable"
],
"support": {
"email": "gediminas.morkevicius@gmail.com",
"issues": "https://github.com/doctrine-extensions/DoctrineExtensions/issues",
"source": "https://github.com/doctrine-extensions/DoctrineExtensions/tree/v3.11.1",
"wiki": "https://github.com/Atlantic18/DoctrineExtensions/tree/main/doc"
},
"time": "2023-02-20T19:24:07+00:00"
},
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
"version": "3.3.1", "version": "3.3.1",
@ -2030,6 +2189,80 @@
}, },
"time": "2021-07-14T16:46:02+00:00" "time": "2021-07-14T16:46:02+00:00"
}, },
{
"name": "stof/doctrine-extensions-bundle",
"version": "v1.7.1",
"source": {
"type": "git",
"url": "https://github.com/stof/StofDoctrineExtensionsBundle.git",
"reference": "fa650e60e174afa06c09e28a54fb1854af04c7fe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stof/StofDoctrineExtensionsBundle/zipball/fa650e60e174afa06c09e28a54fb1854af04c7fe",
"reference": "fa650e60e174afa06c09e28a54fb1854af04c7fe",
"shasum": ""
},
"require": {
"gedmo/doctrine-extensions": "^2.3.4 || ^3.0.0",
"php": "^7.1.3 || ^8.0",
"symfony/config": "^4.4 || ^5.2 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.2 || ^6.0",
"symfony/event-dispatcher": "^4.4 || ^5.2 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.2 || ^6.0"
},
"require-dev": {
"symfony/mime": "^4.4 || ^5.2 || ^6.0",
"symfony/phpunit-bridge": "^v5.2.4 || ^6.0",
"symfony/security-core": "^4.4 || ^5.2 || ^6.0"
},
"suggest": {
"doctrine/doctrine-bundle": "to use the ORM extensions",
"doctrine/mongodb-odm-bundle": "to use the MongoDB ODM extensions",
"symfony/mime": "To use the Mime component integration for Uploadable"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-main": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Stof\\DoctrineExtensionsBundle\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christophe Coevoet",
"email": "stof@notk.org"
}
],
"description": "Integration of the gedmo/doctrine-extensions with Symfony",
"homepage": "https://github.com/stof/StofDoctrineExtensionsBundle",
"keywords": [
"behaviors",
"doctrine2",
"extensions",
"gedmo",
"loggable",
"nestedset",
"sluggable",
"sortable",
"timestampable",
"translatable",
"tree"
],
"support": {
"issues": "https://github.com/stof/StofDoctrineExtensionsBundle/issues",
"source": "https://github.com/stof/StofDoctrineExtensionsBundle/tree/v1.7.1"
},
"time": "2022-09-30T11:52:24+00:00"
},
{ {
"name": "symfony/asset", "name": "symfony/asset",
"version": "v6.2.7", "version": "v6.2.7",

@ -11,4 +11,5 @@ return [
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
]; ];

@ -0,0 +1,7 @@
# Read the documentation: https://symfony.com/doc/current/bundles/StofDoctrineExtensionsBundle/index.html
# See the official DoctrineExtensions documentation for more details: https://github.com/doctrine-extensions/DoctrineExtensions/tree/main/doc
stof_doctrine_extensions:
default_locale: en_US
orm:
default:
timestampable: true

@ -0,0 +1,46 @@
<?php
declare(strict_types = 1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230517165002 extends AbstractMigration {
public function getDescription (): string {
return '';
}
public function up (Schema $schema): void {
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE document (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, creation DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modification DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_D8698A76A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'
);
$this->addSql('CREATE TABLE document_tag (document_id int NOT NULL, tag_id int NOT NULL, INDEX IDX_D0234567C33F7837 (document_id), INDEX IDX_D0234567BAD26311 (tag_id), PRIMARY KEY(document_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'
);
$this->addSql('CREATE TABLE tag (id int AUTO_INCREMENT NOT NULL, name varchar(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'
);
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(180) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649F85E0677 (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'
);
$this->addSql('CREATE TABLE messenger_messages (id bigint AUTO_INCREMENT NOT NULL, body longtext NOT NULL, headers longtext NOT NULL, queue_name varchar(190) NOT NULL, created_at datetime NOT NULL, available_at datetime NOT NULL, delivered_at datetime DEFAULT NULL, INDEX IDX_75EA56E0FB7336F0 (queue_name), INDEX IDX_75EA56E0E3BD61CE (available_at), INDEX IDX_75EA56E016BA31DB (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'
);
$this->addSql('ALTER TABLE document ADD CONSTRAINT FK_D8698A76A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE document_tag ADD CONSTRAINT FK_D0234567C33F7837 FOREIGN KEY (document_id) REFERENCES document (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE document_tag ADD CONSTRAINT FK_D0234567BAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE');
}
public function down (Schema $schema): void {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE document DROP FOREIGN KEY FK_D8698A76A76ED395');
$this->addSql('ALTER TABLE document_tag DROP FOREIGN KEY FK_D0234567C33F7837');
$this->addSql('ALTER TABLE document_tag DROP FOREIGN KEY FK_D0234567BAD26311');
$this->addSql('DROP TABLE document');
$this->addSql('DROP TABLE document_tag');
$this->addSql('DROP TABLE tag');
$this->addSql('DROP TABLE user');
$this->addSql('DROP TABLE messenger_messages');
}
}

@ -7,6 +7,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation\Timestampable;
#[ORM\Entity(repositoryClass: DocumentRepository::class)] #[ORM\Entity(repositoryClass: DocumentRepository::class)]
class Document class Document
@ -26,17 +27,18 @@ class Document
#[ORM\Column(type: Types::TEXT, nullable: true)] #[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null; private ?string $description = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)] #[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
#[Timestampable(on: 'create')]
private ?\DateTimeInterface $creation = null; private ?\DateTimeInterface $creation = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)] #[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
#[Timestampable]
private ?\DateTimeInterface $modification = null; private ?\DateTimeInterface $modification = null;
#[ORM\ManyToMany(targetEntity: Tag::class, inversedBy: 'documents')] #[ORM\ManyToMany(targetEntity: Tag::class, inversedBy: 'documents')]
private Collection $tags; private Collection $tags;
public function __construct() public function __construct () {
{
$this->tags = new ArrayCollection(); $this->tags = new ArrayCollection();
} }

@ -49,6 +49,18 @@
"./tests/bootstrap.php" "./tests/bootstrap.php"
] ]
}, },
"stof/doctrine-extensions-bundle": {
"version": "1.7",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "main",
"version": "1.2",
"ref": "e805aba9eff5372e2d149a9ff56566769e22819d"
},
"files": [
"./config/packages/stof_doctrine_extensions.yaml"
]
},
"symfony/console": { "symfony/console": {
"version": "6.2", "version": "6.2",
"recipe": { "recipe": {

Loading…
Cancel
Save