Class Kohana_ORM_Behavior_LocalBehavior

Kohana_ORM_Behavior_LocalBehavior

extends ORM_Behavior
extends Kohana_ORM_Behavior

package
Kohana/ORM
author
Koseven Team
copyright
(c) 2016-2018 Koseven Team
license
https://koseven.ga/LICENSE.md


Properties

protected array $_callback

Callback to execute

Default value:
NULL

protected Database_Query_Builder_Select $_config

Database query builder

Default value:
NULL

Methods

public on_construct(ORM $model , mixed $id ) (defined in Kohana_ORM_Behavior_LocalBehavior)

Constructs a new model and loads a record if given

Parameters

  • ORM $model required - The model
  • mixed $id required - Parameter for find or object to load

Source Code

public function on_construct($model, $id)
{
	$params = ['construct', $id];
	$result = call_user_func_array($this->_callback, $params);
	
	if (is_bool($result))
		return $result;

	// Continue loading the record
	return TRUE;
}

public on_create(ORM $model ) (defined in Kohana_ORM_Behavior_LocalBehavior)

A new model is created

Parameters

  • ORM $model required - The model

Source Code

public function on_create($model)
{
$params = ['create'];
call_user_func_array($this->_callback, $params);
}

public on_update() (defined in Kohana_ORM_Behavior_LocalBehavior)

The model is updated

Source Code

public function on_update($model)
{
$params = ['update'];
call_user_func_array($this->_callback, $params);
}

public static factory(string $behavior [, mixed $config = NULL ] ) (defined in Kohana_ORM_Behavior)

Creates and returns a new ORM behavior.

Parameters

  • string $behavior required - $type Type name
  • mixed $config = NULL - $id Parameter for find()

Tags

  • Chainable -

Return Values

  • ORM

Source Code

public static function factory($behavior, $config = NULL)
{
	if ( ! is_string($behavior) AND is_array($config))
	{
		if ( ! is_callable($config))
			throw new Kohana_Exception('Behavior cannot be created: function does not exists');

		// This is either a callback as an array or a lambda
		return new ORM_Behavior_LocalBehavior($config);
	}

	// Set class name
	$behavior_name = 'ORM_Behavior_'.ucfirst($behavior);

	return new $behavior_name($config);
}

protected __construct(mixed $callback ) (defined in Kohana_ORM_Behavior_LocalBehavior)

Constructs a behavior object

Parameters

  • mixed $callback required - Callback to execute

Source Code

protected function __construct($callback)
{
  $this->_callback = $callback;
}

Do you want to contribute to Koseven?

We need YOUR help!

This project is open source. What does this mean? YOU can help:
  • Found a bug? Report it on Github
  • Need a feature? Add it Here
  • Want to help? Join the Forum
Go to Github