li3_behaviors\data\model\Behaviors::behavior()

public static method

Returns a behavior instance. Configuration of the instance can be accessed as follows.

{{{ Posts::behavior('Slug')->config(); Posts::behavior('Slug')->config('fields'); }}}

Parameters

  • string $name

    The name of the behavior.

Returns

\li3_behaviors\data\model\Behavior

Intance of the behavior.

Source

	public static function behavior($name) {
		$class = Libraries::locate('behavior', $name);
		$model = get_called_class();

		if (!isset(static::$_behaviors[$model][$class])) {
			throw new RuntimeException("Behavior `{$class}` not bound to model `{$model}`.");
		}
		return static::$_behaviors[$model][$class];
	}