Skip to content
This repository has been archived by the owner on May 28, 2021. It is now read-only.

Commit

Permalink
Update to core 1.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
nielssp committed Dec 20, 2016
1 parent 2445df5 commit b103fca
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"ext-json": "*",
"psr/log": "1.0",
"psr/cache": "1.0",
"jivoo/core": "^1.0",
"jivoo/core": "^1.3",
"composer/semver": "^1.2"
},
"require-dev": {
Expand Down
27 changes: 26 additions & 1 deletion src/ActiveModel/ActiveModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,24 @@
/**
* An active model containing active records, see also {@see ActiveRecord}.
*/
abstract class ActiveModel extends ModelBase
abstract class ActiveModel extends ModelBase implements \Jivoo\EventSubject
{
use \Jivoo\EventSubjectTrait;

/**
* ActiveModel events.
*
* @var string[]
*/
protected $events = array(
'beforeSave',
'afterSave',
'beforeValidate',
'afterValidate',
'afterCreate',
'afterLoad',
'beforeDelete'
);

/**
* @var string Name of database table used by model, null for default based
Expand Down Expand Up @@ -120,6 +136,7 @@ abstract class ActiveModel extends ModelBase
*/
final public function __construct(Schema $schema)
{
$this->e = new \Jivoo\EventManager($this);
$this->name = Utilities::getClassName(get_class($this));
$this->schema = $schema;
if (! isset($this->table)) {
Expand Down Expand Up @@ -176,6 +193,14 @@ final public function __construct(Schema $schema)
protected function init()
{
}

/**
* {@inheritdoc}
*/
public function getEvents()
{
return $this->events;
}

/**
* Call a mixin method.
Expand Down
2 changes: 1 addition & 1 deletion src/ActiveModel/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function getModel()
public function addData(array $data, $allowedFields = null)
{
if (! isset($allowedFields)) {
$allowedFields = $this->model->getDefinition->getFields();
$allowedFields = $this->model->getDefinition()->getFields();
}
if (is_array($allowedFields)) {
$allowedFields = array_flip($allowedFields);
Expand Down

0 comments on commit b103fca

Please sign in to comment.