2017 © Pedro Peláez
 

lithium-library li3_behaviors

Model behaviors for the Lithium PHP framework

image

jails/li3_behaviors

Model behaviors for the Lithium PHP framework

  • Saturday, December 14, 2013
  • by jails
  • Repository
  • 4 Watchers
  • 7 Stars
  • 1,597 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Model behaviors base classes

Requirement

PHP 5.4, (*1)

Installation

Checkout the code to either of your library directories:, (*2)

cd libraries
git clone git@github.com:jails/li3_behaviors.git

Include the library in your /app/config/bootstrap/libraries.php, (*3)

Libraries::add('li3_behaviors');

Presentation

Model behaviors providing a simple way to extend models. This pattern allow common logic to be encapsulated inside behaviors for keeping models lite and composed only by its own business logic., (*4)

API

Simple model creation attached to a behavior:, (*5)

 [
        'fields' => ['title' => 'title', 'name' => 'slug']
    ]];
}
?>
 ['label' => 'slug']
        ];
        parent::__construct($config + $defaults);
    }

    protected function _init() {
        parent::_init();
        if ($model = $this->_model) {
            $behavior = $this;
            $model::applyFilter('save', function($self, $params, $chain) use ($behavior) {
                $params = $behavior->invokeMethod('_slug', array($params));
                return $chain->next($self, $params, $chain);
            });
        }
    }

    protected function _slug($params) {
        extract($this->_config);
        foreach ($fields as $from => $to) {
            if (isset($params['data'][$from])) {
                $params['data'][$to] = Inflector::slug($params['data'][$from]);
            }
        }
        return $params;
    }
}
?>

Greetings

The li3 team, Nateabele's filters system and all others which make that possible (including my parents which I love)., (*6)

Build status

Build Status, (*7)

The Versions

14/12 2013

dev-master

9999999-dev https://github.com/jails/li3_behaviors

Model behaviors for the Lithium PHP framework

  Sources   Download

BSD-3-Clause

The Requires

 

php model behavior lithium li3

19/05 2013

dev-php-5.3

dev-php-5.3 https://github.com/jails/li3_behaviors

Model behaviors for the Lithium PHP framework

  Sources   Download

BSD-3-Clause

The Requires

 

php model behavior lithium li3