2017 © Pedro Peláez
 

asgard-bundle behaviors

image

asgard/behaviors

  • Friday, May 13, 2016
  • by leyou
  • Repository
  • 1 Watchers
  • 0 Stars
  • 444 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Behaviors

Build Status, (*1)

The Behaviors package provides some behaviors ready to use out-of-the-box for your entities. This page defines what the usage, the properties, the hooks and the methods brought by the behavior., (*2)

, (*3)

Installation

If you are working on an Asgard project you don't need to install this library as it is already part of the standard libraries., (*4)

composer require asgard/behaviors 0.*

, (*5)

MetasBehavior

Usage

In your entity definition:, (*6)

$definition->behaviors = [
    new \Asgard\Behaviors\MetasBehavior
];

Properties

meta_title:
    type: text
    required: false
meta_description:
    type: text
    required: false
meta_keywords:
    type: text
    required: false

Methods

$entity->showMetas();

outputs the entity metas in the html, (*7)

, (*8)

PublishBehavior

Usage

In your entity definition:, (*9)

$definition->behaviors = [
    new \Asgard\Behaviors\PublishBehavior
];

Properties

published:
    type: boolean
    default: true

Methods

Entity::published();

returns an orm with a published entities scope., (*10)

Entity::loadPublished($id);

returns an entity from a given id only if the entity is published., (*11)

, (*12)

SlugifyBehavior

Usage

In your entity definition:, (*13)

$definition->behaviors = [
    new \Asgard\Behaviors\SlugifyBehavior
];

This will use the first entity property as a slug., (*14)

To use a speficic property as slug:, (*15)

$definition->behaviors = [
    new \Asgard\Behaviors\SlugifyBehavior('title')
];

Properties

slug:
    type: text
    required: false

Methods

$entity->slug();

returns the entity slug, (*16)

, (*17)

SortableBehavior

Usage

In your entity definition:, (*18)

$definition->behaviors = [
    new \Asgard\Behaviors\SortableBehavior
];

Properties

position:
    type: integer
    required: false
    default: 0
    editable: false

Hooks

If the position is not set, when saving the entity, the position will be incremented from the last entity., (*19)

Methods

$entity->moveAfter($anotherEntityId);

moves the entity after another entity with a given id, (*20)

$entity->previous();

returns the entity before the current one., (*21)

$entity->next();

returns the entity after the current one., (*22)

, (*23)

TimestampsBehavior

Usage

In your entity definition:, (*24)

$definition->behaviors = [
    new \Asgard\Behaviors\TimestampsBehavior
];

Properties

created_at:
    type: datetime
    required: false
    default: function() { return \Asgard\Common\Datetime::now(); }
    editable: false
updated_at:
    type: datetime
    required: false
    default: function() { return \Asgard\Common\Datetime::now(); }
    editable: false

Hooks

Upon saving an entity, the updated_at property will be updated with the current date and time., (*25)

Contributing

Please submit all issues and pull requests to the asgardphp/asgard repository., (*26)

License

The Asgard framework is open-sourced software licensed under the MIT license, (*27)

The Versions

13/05 2016

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by Michel Hognerud

13/05 2016

v0.3.1

0.3.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Michel Hognerud

12/05 2016

v0.3.0

0.3.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Michel Hognerud

19/06 2015

v0.2.1

0.2.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Michel Hognerud

13/06 2015

v0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Michel Hognerud

10/09 2014

v0.1.1

0.1.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Michel Hognerud

09/09 2014

v0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Michel Hognerud