balicekt / doctrine-behaviors
Integration of KnpLabs/DoctrineBehaviors to Nette\DI
5.0.0
2019-01-30 20:21 UTC
Requires
- php: >=7.1.0
- kdyby/events: ~3.0
- knplabs/doctrine-behaviors: ~1.6
- tracy/tracy: ~2.4
Requires (Dev)
- kdyby/doctrine: ~3.1
- nette/bootstrap: ~2.4
- nette/di: ~2.4
- nette/http: ~2.4
- nette/reflection: ~2.4
- nette/security: ~2.4
- phpunit/phpunit: ^5.6
- zenify/coding-standard: ^4.0
- dev-master
- 5.0.0
- v4.2.2
- v4.2.1
- v4.2
- v4.1
- v2.6.0
- v2.5.1
- v2.5.0
- v2.4.0
- v2.3.0
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.2
- v2.0.1
- v2.0.0
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-ECOM-133
- dev-clear-74-2
- dev-clear-74
- dev-ECOM-62
This package is auto-updated.
Last update: 2025-03-01 00:20:13 UTC
README
Port of KnpLabs/DoctrineBehaviors to Nette DI
Supported behaviors:
- Blameable
- Geocodable
- Loggable
- Sluggable
- SoftDeletable
- Translatable
- Timestampable
- Tree
For implementation to entities, check tests.
Install
Via Composer:
$ composer require zenify/doctrine-behaviors
Register extensions you need in config.neon
:
extensions: translatable: Zenify\DoctrineBehaviors\DI\TranslatableExtension - Zenify\DoctrineBehaviors\DI\TimestampableExtension
Usage
Translatable
Setup your translator locale callback in config.neon
:
translatable: currentLocaleCallable: [@Translator, getLocale]
Place trait to your entity:
class Article { use Knp\DoctrineBehaviors\Model\Translatable\Translatable; // returns translated property for $article->getTitle() or $article->title use Zenify\DoctrineBehaviors\Entities\Attributes\Translatable; }
And its translation entity:
class ArticleTranslation { use Knp\DoctrineBehaviors\Model\Translatable\Translation; /** * @ORM\Column(type="string") * @var string */ public $title; }
For deeper knowledge see test for:
Timestampable
Place trait to your entity to ad $createdAt
and $updatedAt
properties:
class Article { use Knp\DoctrineBehaviors\Model\Timestampable\Timestampable; }
Testing
composer check-cs vendor/bin/phpunit
Contributing
Rules are simple:
- new feature needs tests
- all tests must pass
- 1 feature per PR
We would be happy to merge your feature then!