Skip to content

Commit

Permalink
merge AbstractModel methods into AbstractService
Browse files Browse the repository at this point in the history
  • Loading branch information
albertborsos committed Jun 21, 2019
1 parent 00839a0 commit 9ff1ca3
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 143 deletions.
142 changes: 0 additions & 142 deletions src/models/AbstractModel.php

This file was deleted.

86 changes: 85 additions & 1 deletion src/models/AbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace albertborsos\ddd\models;

use albertborsos\ddd\interfaces\BusinessObject;
use albertborsos\ddd\interfaces\FormObject;
use yii\base\Component;
use yii\helpers\ArrayHelper;
use yii\web\Link;
use yii\web\Linkable;
Expand All @@ -10,10 +13,91 @@
* Class AbstractDomain
* @package albertborsos\ddd\models
*/
abstract class AbstractService extends AbstractModel
abstract class AbstractService extends Component
{
/**
* The ID of the (main) object
* @var integer|mixed
*/
private $_id;

/**
* @var \yii\base\Model|FormObject
*/
private $_form;

/**
* @var \yii\db\ActiveRecord|BusinessObject
*/
private $_model;

/**
* @var array
*/
private $_errors;

public function __construct(FormObject $form = null, BusinessObject $model = null)
{
if ($form) {
$this->setForm($form);
}
if ($model) {
$this->setModel($model);
}
parent::__construct([]);
}

/**
* @return boolean
*/
abstract public function execute();

/**
* @return FormObject|\yii\base\Model
*/
protected function getForm()
{
return $this->_form;
}


/**
* @return BusinessObject|ActiveRecord
*/
protected function getModel()
{
return $this->_model;
}

/**
* @param $id
*/
protected function setId($id)
{
$this->_id = $id;
}

/**
* @return int
*/
public function getId()
{
return $this->_id;
}

/**
* @param FormObject $form
*/
private function setForm(FormObject $form)
{
$this->_form = $form;
}

/**
* @param BusinessObject $model
*/
private function setModel(BusinessObject $model)
{
$this->_model = $model;
}
}

0 comments on commit 9ff1ca3

Please sign in to comment.