Statistics
30678
12
1
265d
Badges
Dependencies

Doctrine Behaviors

Build Status Quality Score Code Coverage Downloads total Latest stable

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!

  • v2.5.1 v2.5.1

  • v2.5.0 v2.5.0

    • Update to KnpLabs/DoctrineBehaviors v1.4 (thanks to @TomasPilar)
  • v2.4.0 Released version 2.4.0

  • v2.3.0 Released version 2.3.0

    • Fix compatibility with KnpLabs/DoctrineBehaviors v1.3 (thanks to @TomasPilaru)
    • Fix compatibility with Kdyby/Doctrine v3.0 (thanks to @dejv88)
  • v2.2.0 Released version 2.2.0

    • updated to KnpLabs\DoctrineBehaviors v1.1 (diff to v1.0.3)
    • #5 fixed translatable trait (thanks to @TomasPilaru )

    Full diff to 2.1.0: v2.1.0...v2.2.0

  • v2.1.0 Released version 2.1.0

    Full diff to 2.0.0: v2.0.0...v2.1.0

  • v2.0.0 Released version 2.0.0

    • lock to KnpLabs\DoctrineBehaviors stable version v1.0.2
    • bump min version to PHP 5.5
    • Zenify\CodingStandard updated to v2.0
    • nicer badges + code quality badge added

    Diff to 1.1.3: v1.1.3...v2.0.0

  • v1.1.3 Released version 1.1.3

    • tests added
    • allows callable in service or class form
    • configuration is now validated
    • support for PHP 5.3 added
    • Blameable: dummy UserCallable added
    • Loggable: removed dependency on Symfony

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com