Skip to content
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

Add all features for v3 #32

Merged
merged 12 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
3.0.0 (unreleased)
=====

* (improvement) Bump required Symfony.
* (bc) Remove sortable handlers.
* (bc) Remove simple entity search handler.
* (bc) Remove `Model`.
* (bc) Fix missing return types in `ModelInterface`.
* (internal) Use HtmlBuilder for `DataContainer`.
* (bc) Replace `IdTrait` + `TimestampsTrait` to `EntityFieldsTrait` and `ModifiableEntityFieldsTrait`.
* (bc) Moved `EntityInterface` to new namespace and add time created getter.
* (bc) Remove `Routable`.
* (improvement) Use the clock for setting date values.


2.6.1
=====

Expand Down
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

* `Routable` was removed in favor of `Linkable` and `LinkableInterface`.
* The `BaseController` methods `::normalizeFormErrors()`, `::getLogger()` and `::fetchJsonRequestBody()` have been changed from `public` to `protected`. Please make sure that these methods are not being used externally within your controllers.
* The sortable handlers were removed. There is no replacement.
* The simple entity search handlers were removed. There is no replacement.
* The `Model` class was removed. Use `EntityModel` instead.
* The missing return types in `ModelInterface` were added.
* `IdTrait` and `TimestampsTrait` were removed. Migrate to `EntityFieldsTrait` and `ModifiableEntityFieldsTrait` instead.
* `EntityInterface` was moved to a new namespace and has an additional method.


1.x to 2.0
Expand Down
27 changes: 14 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,27 @@
"php": ">= 8.2",
"ext-json": "*",
"21torr/bundle-helpers": "^2.1",
"21torr/html-builder": "^2.1",
"psr/log": "^3.0",
"symfony/dependency-injection": "^6.2",
"symfony/deprecation-contracts": "^3.1",
"symfony/framework-bundle": "^6.2",
"symfony/http-foundation": "^6.2",
"symfony/http-kernel": "^6.2"
"symfony/deprecation-contracts": "^3.4",
"symfony/framework-bundle": "^6.4",
"symfony/http-foundation": "^6.4",
"symfony/http-kernel": "^6.4"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8",
"doctrine/dbal": "^2.13",
"doctrine/orm": "^2.13",
"phpunit/phpunit": "^9.5",
"doctrine/orm": "^2.16",
"phpunit/phpunit": "^9.6",
"roave/security-advisories": "dev-latest",
"symfony/console": "^6.2",
"symfony/form": "^6.2",
"symfony/phpunit-bridge": "^6.2",
"symfony/routing": "^6.2",
"symfony/security-bundle": "^6.2",
"symfony/translation": "^6.2",
"twig/twig": "^3.4"
"symfony/console": "^6.4",
"symfony/form": "^6.4",
"symfony/phpunit-bridge": "^6.4",
"symfony/routing": "^6.4",
"symfony/security-bundle": "^6.4",
"symfony/translation": "^6.4",
"twig/twig": "^3.8"
},
"suggest": {
"doctrine/dbal": "To add the SerializedType",
Expand Down
58 changes: 58 additions & 0 deletions src/Entity/EntityFieldsTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php declare(strict_types=1);

namespace Torr\Rad\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

/**
* Base trait that adds base fields to any entity.
*
* If your entity is modifiable, you should use {@see ModifiableEntityFieldsTrait} instead.
*
* Implement {@see EntityInterface} in your entity as well.
*/
trait EntityFieldsTrait
{
/**
*
*/
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "AUTO")]
#[ORM\Column(name: "id", type: Types::INTEGER)]
private ?int $id = null;


/**
*
*/
#[ORM\Column(name: "time_created", type: Types::DATETIMETZ_IMMUTABLE)]
private \DateTimeImmutable $timeCreated;


/**
*
*/
public function getId () : ?int
{
return $this->id;
}


/**
*
*/
public function isNew () : bool
{
return null === $this->id;
}


/**
*
*/
public function getTimeCreated () : \DateTimeImmutable
{
return $this->timeCreated;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Torr\Rad\Entity\Interfaces;
namespace Torr\Rad\Entity;

interface EntityInterface
{
Expand All @@ -16,4 +16,10 @@ public function getId () : ?int;
* @return bool true if new (= not yet flushed), false otherwise
*/
public function isNew () : bool;


/**
* Returns the time the entity was created.
*/
public function getTimeCreated () : \DateTimeImmutable;
}
18 changes: 0 additions & 18 deletions src/Entity/Interfaces/SortableEntityInterface.php

This file was deleted.

48 changes: 48 additions & 0 deletions src/Entity/ModifiableEntityFieldsTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php declare(strict_types=1);

namespace Torr\Rad\Entity;

use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use function Symfony\Component\Clock\now;

/**
* Base trait for any entity that is modifiable
*
* Implement {@see EntityInterface} in your entity as well.
*/
trait ModifiableEntityFieldsTrait
{
use EntityFieldsTrait;

/**
*
*/
#[ORM\Column(name: "time_modified", type: Types::DATETIMETZ_IMMUTABLE, nullable: true)]
private ?\DateTimeImmutable $timeModified = null;


/**
*
*/
public function getTimeModified () : ?\DateTimeImmutable
{
return $this->timeModified;
}

/**
*
*/
public function markAsModified () : void
{
$this->timeModified = now();
}

/**
* Returns the time the entity was last touched (either created or modified).
*/
public function getLastModificationTime () : \DateTimeImmutable
{
return $this->getTimeModified() ?? $this->getTimeCreated();
}
}
45 changes: 0 additions & 45 deletions src/Entity/Traits/IdTrait.php

This file was deleted.

36 changes: 0 additions & 36 deletions src/Entity/Traits/SortOrderTrait.php

This file was deleted.

52 changes: 0 additions & 52 deletions src/Entity/Traits/TimestampsTrait.php

This file was deleted.

9 changes: 0 additions & 9 deletions src/Exception/Route/InvalidRoutableException.php

This file was deleted.

Loading