From cd9bbb9770ebbcc4d8333559cc0f9d4419dde56d Mon Sep 17 00:00:00 2001 From: evgen-d Date: Tue, 12 Aug 2014 10:42:38 +0400 Subject: [PATCH] remove document field --- ActiveRecord.php | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/ActiveRecord.php b/ActiveRecord.php index d0e7ffe..3cfbff4 100644 --- a/ActiveRecord.php +++ b/ActiveRecord.php @@ -16,16 +16,6 @@ use triagens\ArangoDb\Document; abstract class ActiveRecord extends BaseActiveRecord { - /** @var Document $document */ - private $document; - - public function __construct($config = []) - { - $this->document = new Document(); - - parent::__construct($config); - } - public function mergeAttribute($name, $value) { $newValue = $this->getAttribute($name); @@ -46,12 +36,6 @@ abstract class ActiveRecord extends BaseActiveRecord return Inflector::camel2id(StringHelper::basename(get_called_class()), '_'); } - public function setAttribute($name, $value) - { - $this->document->set($name, $value); - parent::setAttribute($name, $value); - } - /** * Returns the primary key **name(s)** for this AR class. * @@ -136,13 +120,10 @@ abstract class ActiveRecord extends BaseActiveRecord */ public static function populateRecord($record, $row) { - if (is_array($row)) { - $document = Document::createFromArray($row); - } else { - $document = $row; + if ($row instanceof Document) { $row = $row->getAll(); } - $record->document = $document; + parent::populateRecord($record, $row); } @@ -205,7 +186,7 @@ abstract class ActiveRecord extends BaseActiveRecord $this->setIsNewRecord(false); $changedAttributes = array_fill_keys(array_keys($values), null); - $this->setOldAttributes($this->document->getAll()); + $this->setOldAttributes($values); $this->afterSave(true, $changedAttributes); return true; @@ -397,20 +378,6 @@ abstract class ActiveRecord extends BaseActiveRecord return $result; } - /** - * Returns a value indicating whether the current record is new (not saved in the database). - * @return boolean whether the record is new and should be inserted when calling [[save()]]. - */ - public function getIsNewRecord() - { - return $this->document->getIsNew(); - } - - public function setIsNewRecord($value) - { - $this->document->setIsNew($value); - } - public function init() { parent::init();