Skip to content
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [0.1.6] - 2025-04-24
### Added
- Prefix and Suffix for Slug
- Uuid tests
- Ip tests
- Authored tests
- TimeStamped tests

## [0.1.5] - 2025-04-19
### Added
- UUID
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ Open a command console, enter your project directory and execute:
composer require rami/entity-kit-bundle
```

Test
=

```console
./vendor/bin/phpunit
```

check the `tests` directory
2 changes: 2 additions & 0 deletions docs/slug.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ fields: [] // An array of fields the entity has for slug generation
ensureUnique: true // True by default. if a slug exists, it appends an incremental number at the end
separator: '-' // defaults to '-'
shouldRegenerateOnUpdate: false // False by default
prefix: string // beginning of the slug
suffix: string // ending of the slug
```
2 changes: 2 additions & 0 deletions src/Common/Attributes/Slugged.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class Slugged
{
public function __construct(
public ?array $fields = [],
public ?string $prefix = null,
public ?string $suffix = null,
public bool $ensureUnique = true,
public string $separator = '-',
public bool $shouldRegenerateOnUpdate = false
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/Authored/AuthoredListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private function getCurrentUserIdentifier(): string|null
return null;
}

$user = $this->tokenStorage->getToken()->getUser();
$user = $this->tokenStorage?->getToken()?->getUser();

if (!$user instanceof UserInterface) {
return null;
Expand Down
8 changes: 8 additions & 0 deletions src/EventListener/Slugged/SluggedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ private function applySlug($entity): void

$slugger = new AsciiSlugger();

if (null !== $attributes->prefix) {
$slugFied = $attributes->prefix . ' ' . $slugFied;
}

if (null !== $attributes->suffix) {
$slugFied = $slugFied . ' ' . $attributes->suffix;
}

$slugFied = $slugger->slug($slugFied, $separator)->lower();

if (true === $attributes->ensureUnique) {
Expand Down
Empty file removed tests/bootstrap.php
Empty file.
Loading