Compare commits
27 Commits
230faaf3cc
...
1.1.0
Author | SHA1 | Date | |
---|---|---|---|
7fc7de7390 | |||
55275d2d75 | |||
3bc54fb9d1 | |||
123d46d33c | |||
65c224c636 | |||
6cd26a88ea | |||
022ba575b7 | |||
c913f65b91 | |||
c8a7781c88 | |||
1505539e61 | |||
3087a48c43 | |||
43f545516d | |||
b757ed19b2 | |||
9dc71e4d77 | |||
c6806a1c62 | |||
6fd19a11be | |||
7c727d93e9 | |||
e02b8c4063 | |||
89d1db7a7e | |||
8dc0a27fd9 | |||
ae172b902c | |||
7f81b987c9 | |||
af801e769f | |||
c40baaad3f | |||
a82fdce64b | |||
8126b1f67d | |||
2177cb4652 |
46
src/Implement/Model/Factory.php
Normal file
46
src/Implement/Model/Factory.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?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;
|
||||
}
|
||||
protected string $namespace;
|
||||
public function setNamespace(string $namespace): FactoryInterface
|
||||
{
|
||||
$this->namespace = $namespace;
|
||||
return $this;
|
||||
}
|
||||
public function getNamespace(): string
|
||||
{
|
||||
return $this->namespace;
|
||||
}
|
||||
protected function buildRepository(string $repository_name): string
|
||||
{
|
||||
return implode("\\", [
|
||||
$this->getNamespace(),
|
||||
$repository_name
|
||||
]);
|
||||
}
|
||||
public function get(string $repository_name): Repository
|
||||
{
|
||||
return $this->getContainer()->get($this->buildRepository($repository_name));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user