Skip to content

Commit fa376c9

Browse files
committed
wip
1 parent 3c56b7d commit fa376c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1039
-653
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
[![codecov](https://codecov.io/gh/SoureCode/DoctrineExtensionBundle/branch/master/graph/badge.svg?token=GBFBVXQYK4)](https://codecov.io/gh/SoureCode/DoctrineExtensionBundle)
88
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FSoureCode%2FDoctrineExtensionBundle%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/SoureCode/DoctrineExtensionBundle/master)
99

10-
[Documentation](./docs/index.md)
11-
[License](./LICENSE)
10+
- [Documentation](./docs/index.md)
11+
- [License](./LICENSE)
1212

1313
## Installation
1414

docs/timestampable.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ namespace App\Entity;
1414

1515
use Doctrine\ORM\Mapping as ORM;
1616
use SoureCode\Bundle\DoctrineExtension\Contracts\TimestampableInterface;
17-
use SoureCode\Bundle\DoctrineExtension\Traits\TimestampableTrait;
17+
use SoureCode\Bundle\DoctrineExtension\Traits\TimestampAwareTrait;
1818

1919
#[ORM\Entity]
2020
class User implements TimestampableInterface {
21-
use TimestampableTrait;
21+
use TimestampAwareTrait;
2222

2323
#[ORM\Id]
2424
#[ORM\GeneratedValue]

src/Attributes/SetOnCreation.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace SoureCode\Bundle\DoctrineExtension\Attributes;
4+
5+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
6+
final class SetOnCreation
7+
{
8+
public function __construct(
9+
public ?string $type = null,
10+
) {
11+
}
12+
}

src/Attributes/SetOnUpdate.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace SoureCode\Bundle\DoctrineExtension\Attributes;
4+
5+
#[\Attribute(\Attribute::TARGET_PROPERTY)]
6+
final class SetOnUpdate
7+
{
8+
public function __construct(
9+
public ?string $type = null,
10+
) {
11+
}
12+
}

src/Attributes/Translatable.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@
55
use SoureCode\Bundle\DoctrineExtension\Contracts\TranslationInterface;
66

77
#[\Attribute(\Attribute::TARGET_CLASS)]
8-
final class Translatable
8+
final readonly class Translatable
99
{
10-
public function __construct(
11-
/**
12-
* @var class-string
13-
*/
14-
public string $translationClass,
15-
) {
10+
/**
11+
* @var class-string<TranslationInterface>
12+
*/
13+
public string $translationClass;
14+
15+
/**
16+
* @param class-string $translationClass
17+
*/
18+
public function __construct(string $translationClass)
19+
{
1620
if (!is_subclass_of($translationClass, TranslationInterface::class)) {
1721
throw new \InvalidArgumentException(\sprintf('The class "%s" must implement "%s".', $translationClass, TranslationInterface::class));
1822
}
23+
24+
$this->translationClass = $translationClass;
1925
}
2026
}

src/Contracts/BlameableInterface.php

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace SoureCode\Bundle\DoctrineExtension\Contracts;
4+
5+
interface LocaleAwareInterface
6+
{
7+
public function getLocale(): string;
8+
9+
public function setLocale(string $locale): self;
10+
}

src/Contracts/TimestampableInterface.php

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Contracts/TranslatableInterface.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/Contracts/TranslationInterface.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
namespace SoureCode\Bundle\DoctrineExtension\Contracts;
44

5-
interface TranslationInterface
5+
interface TranslationInterface extends LocaleAwareInterface
66
{
7-
public function getLocale(): string;
7+
public function setTranslatable(object $translatable): self;
88

9-
public function setLocale(string $locale): self;
10-
11-
public function getTranslatable(): TranslatableInterface;
12-
13-
public function setTranslatable(TranslatableInterface $translatable): self;
14-
}
9+
public function getTranslatable(): object;
10+
}

0 commit comments

Comments
 (0)