2017 © Pedro Peláez
 

library yii2-nox-behaviors

Yii2 NOX Behaviors

image

nox-it/yii2-nox-behaviors

Yii2 NOX Behaviors

  • Saturday, May 27, 2017
  • by jsas-development
  • Repository
  • 2 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Yii PHP Framework Version 2 / NYX Behaviors

Collection of useful behaviors for Yii Framework 2.0 (at the present there is only one behavior, the datetime behavior.)., (*1)

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads Daily Downloads composer.lock, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist nyx-solutions/yii2-nyx-behaviors "*"

or add, (*5)

"nyx-solutions/yii2-nyx-behaviors": "*"

to the require section of your composer.json file., (*6)

Usage

In your base ActiveRecord Model you can add the following behaviors method:, (*7)

namespace common\models;

use \yii\helpers\ArrayHelper;

/**
 * Class ActiveRecordModel
 *
 * @package common\models
 */
class ActiveRecordModel extends \yii\db\ActiveRecord
{
    #region Behaviors
    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        $behaviors = [];

        if ($this->hasAttribute('createdAt') && $this->hasAttribute('updatedAt')) {
            $behaviors['datetime'] = [
                'class'      => \nyx\behaviors\DateTimeBehavior::className(),
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ['createdAt', 'updatedAt'],
                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updatedAt'
                ]
            ];
        }

        return ArrayHelper::merge(parent::behaviors(), $behaviors);
    }
    #endregion
}

License

yii2-nyx-behaviors is released under the BSD 3-Clause License. See the bundled LICENSE.md for details., (*8)

Yii2, (*9)

The Versions

27/05 2017

dev-master

9999999-dev

Yii2 NOX Behaviors

  Sources   Download

BSD-3-Clause

The Requires

 

by Jonatas Sas

framework extension php yii2 behaviors

27/05 2017

1.0.2

1.0.2.0

Yii2 NOX Behaviors

  Sources   Download

BSD-3-Clause

The Requires

 

by Jonatas Sas

framework extension php yii2 behaviors

14/10 2016

1.0.1

1.0.1.0

Yii2 NOX Behaviors

  Sources   Download

BSD-3-Clause

The Requires

 

by Jonatas Sas

framework extension php yii2 behaviors

30/05 2016

1.0.0

1.0.0.0

Yii2 NOX Behaviors

  Sources   Download

Apache-2.0

The Requires

 

by Jonatas Sas

framework extension php yii2 behaviors