Skip to content

Commit

Permalink
using abstract interface and model assertation directly instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jturbide committed Feb 24, 2024
1 parent fd9eda3 commit 12305d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/Models/Interfaces/AbstractInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ interface AbstractInterface extends ModelInterface
{
public function setId($id);
public function getId();

public function toArray($columns = null, $useGetter = true): array;
}
5 changes: 4 additions & 1 deletion src/Mvc/Model/Behavior/Blameable.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

namespace Zemit\Mvc\Model\Behavior;

use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Behavior;
use Phalcon\Mvc\ModelInterface;
use Zemit\Models\Audit;
use Zemit\Models\AuditDetail;
use Zemit\Models\Interfaces\AbstractInterface;
use Zemit\Models\Interfaces\AuditDetailInterface;
use Zemit\Models\Interfaces\AuditInterface;
use Zemit\Models\User;
Expand Down Expand Up @@ -74,7 +76,7 @@ public function notify(string $type, ModelInterface $model)
* Create new audit
* Return true if the audit was created
*/
public function createAudit(string $type, ModelInterface $model): bool
public function createAudit(string $type, AbstractInterface $model): bool
{
$event = lcfirst(Helper::uncamelize(str_replace(['before', 'after'], ['', ''], $type)));

Expand All @@ -89,6 +91,7 @@ public function createAudit(string $type, ModelInterface $model): bool

$audit = new $auditClass();
assert($audit instanceof AuditInterface);
assert($audit instanceof Model);

$audit->setModel(get_class($model));
$audit->setTable($model->getSource());
Expand Down

0 comments on commit 12305d2

Please sign in to comment.