Download the PHP package somnambulist/entity-behaviours without Composer
On this page you can find all versions of the php package somnambulist/entity-behaviours. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download somnambulist/entity-behaviours
More information about somnambulist/entity-behaviours
Files in somnambulist/entity-behaviours
Package entity-behaviours
Short Description A set of behaviours and interfaces for use with entities
License MIT
Informations about the package entity-behaviours
Moved to https://github.com/dave-redfern/somnambulist-domain
This repository has been archived. Please update to the combined package.s
Entity Behaviours
Provides some useful interfaces and traits that can be used with entities. The traits implement on basic methods, and still require e.g. publish/unpublish to be implemented.
Requirements
- PHP 7+
Installation
Install using composer, or checkout / pull the files from github.com.
- composer require somnambulist/entity-behaviours
Behaviours
Unlike the somnambulist/laravel-doctrine-behaviours package, these behaviours are intended to be used in a much more controlled and DDD based system. As such they do not implement setters and in some cases even the methods defined in the interfaces as these are core domain methods that should raise events within your system.
-
Activatable
Adds
activate()
/deactivate()
methods to an entity controlling if it is active or not. The entity should implement activate/deactivate methods so that Events can be raised. -
GloballyTrackable
A collection of other interfaces: Identifiable, Nameable, Timestampable, UniversallyIdentifiable.
-
Identifiable
Adds an
id()
method that returns the primary identifier (int, string, object) -
IdentifiableWithTimestamps
A combination of Identifiable and Timestampable
-
Nameable
Adds a
name()
method that returns the entity name component. -
NumericallySortable
Adds an
ordinal()
and update method for adding a numerical sorting index to an entity. -
Publishable
Adds
publish()
/unpublish()
for controlling if an Entity is "published". Uses the DateTime value object. publish/unpublish are not implemented as they should raise events when used. -
Stringable
Adds
__toString()
and atoString()
method that will use try the following methods:displayAs()
title()
name()
If none are present an empty string is returned.
-
Timestampable
Adds
createdAt()
/updatedAt()
methods. Not setters are not defined as the entity should update the updatedAt when it is changed through update calls and not rely on database behaviour. -
Trackable
A collection of other interfaces: Identifiable, Nameable, Timestampable
-
UniversallyIdentifiable
Adds a
uuid()
method that returns a Uuid value object. -
Versionable
Adds a
version()
andincrementVersion()
methods for defining the current entity version. incrementVersion should be hooked in appropriate update methods when the entity is modified.
Utilities
-
EntityAccessor
Helper class for accessing property methods/properties. Intended to be used in unit tests only.