Compare commits
1 Commits
2.2.0
...
12065b376b
Author | SHA1 | Date | |
---|---|---|---|
12065b376b |
@ -61,8 +61,4 @@ abstract class Model implements ModelInterface
|
|||||||
}
|
}
|
||||||
$this->isDirty();
|
$this->isDirty();
|
||||||
}
|
}
|
||||||
public function delete(): void
|
|
||||||
{
|
|
||||||
$this->getFactory()->get(get_class($this))->delete($this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -100,12 +100,6 @@ abstract class Repository implements RepositoryInterface
|
|||||||
}
|
}
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
public function delete(Model $model): void
|
|
||||||
{
|
|
||||||
$query = $this->getQueryBuilder()->delete($this->getTable())->where(['id = ?']);
|
|
||||||
$this->getConnection()->execute($query, [$model->getId()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function fetchById(int $id): Model
|
public function fetchById(int $id): Model
|
||||||
{
|
{
|
||||||
$query = $this->getQueryBuilder()
|
$query = $this->getQueryBuilder()
|
||||||
|
@ -15,5 +15,4 @@ interface Model
|
|||||||
public function isDirty(): bool;
|
public function isDirty(): bool;
|
||||||
public function save(): void;
|
public function save(): void;
|
||||||
public function edit(array $data): void;
|
public function edit(array $data): void;
|
||||||
public function delete(): void;
|
|
||||||
}
|
}
|
||||||
|
@ -7,5 +7,7 @@ interface Factory
|
|||||||
{
|
{
|
||||||
public function setContainer(ContainerInterface $container): Factory;
|
public function setContainer(ContainerInterface $container): Factory;
|
||||||
public function getContainer(): ContainerInterface;
|
public function getContainer(): ContainerInterface;
|
||||||
public function get(string $repository_class): Repository;
|
public function setNamespace(string $namespace): Factory;
|
||||||
|
public function getNamespace(): string;
|
||||||
|
public function get(string $repository_name): Repository;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ interface Repository
|
|||||||
public function save(Model $model): void;
|
public function save(Model $model): void;
|
||||||
public function edit(Model $model, array $data): Model;
|
public function edit(Model $model, array $data): Model;
|
||||||
public function create(array $data): Model;
|
public function create(array $data): Model;
|
||||||
public function delete(Model $model): void;
|
|
||||||
public function fetchById(int $id): Model;
|
public function fetchById(int $id): Model;
|
||||||
public function fetchAll(): array;
|
public function fetchAll(): array;
|
||||||
}
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace ProVM\Implement\Model;
|
|
||||||
|
|
||||||
use Psr\Container\ContainerInterface;
|
|
||||||
use ProVM\Concept\Model\Factory as FactoryInterface;
|
|
||||||
use ProVM\Concept\Model\Repository;
|
|
||||||
|
|
||||||
class Factory implements FactoryInterface
|
|
||||||
{
|
|
||||||
public function __construct(ContainerInterface $container)
|
|
||||||
{
|
|
||||||
$this->setContainer($container);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ContainerInterface $container;
|
|
||||||
public function setContainer(ContainerInterface $container): FactoryInterface
|
|
||||||
{
|
|
||||||
$this->container = $container;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
public function getContainer(): ContainerInterface
|
|
||||||
{
|
|
||||||
return $this->container;
|
|
||||||
}
|
|
||||||
public function get(string $repository_class): Repository
|
|
||||||
{
|
|
||||||
return $this->getContainer()->get($repository_class);
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user