Skip to content

Commit e8b24c4

Browse files
committed
move AbstractRegistry and CommandRegistry to "Plugin" namespace
1 parent 52f05e9 commit e8b24c4

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @link https://github.com/DevNet-Framework
88
*/
99

10-
namespace DevNet\CLI\Commands;
10+
namespace DevNet\CLI\Plugin;
1111

1212
use DevNet\System\Collections\Enumerator;
1313
use DevNet\System\Collections\IEnumerable;
@@ -29,12 +29,14 @@ public function __construct(string $type)
2929
/**
3030
* @param object|string $service object or class name of the injected service
3131
*/
32-
public function set(string $name, $service): void
32+
public function set(string $name, string|object $service): void
3333
{
3434
if (is_string($service)) {
35-
$this->classes[$name] = $service;
35+
if (is_subclass_of($service, $this->type->Name) || $service == $this->type->Name) {
36+
$this->classes[$name] = $service;
37+
}
3638
} else if (is_object($service)) {
37-
if ($this->type->isTypeOf($service)) {
39+
if (is_subclass_of($service, $this->type->Name) || $service::class == $this->type->Name) {
3840
$this->objects[$name] = $service;
3941
}
4042
}
@@ -50,10 +52,8 @@ public function get(string $name): ?object
5052
$class = $this->classes[$name] ?? '';
5153
if (class_exists($class)) {
5254
$object = new $class();
53-
if ($this->type->isTypeOf($object)) {
54-
$this->objects[$name] = $object;
55-
return $object;
56-
}
55+
$this->objects[$name] = $object;
56+
return $object;
5757
}
5858

5959
return null;

src/Plugin/CodeGeneratorRegistry.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace DevNet\CLI\Plugin;
1111

12-
use DevNet\CLI\Commands\AbstractRegistry;
13-
1412
class CodeGeneratorRegistry extends AbstractRegistry
1513
{
1614
private static ?CodeGeneratorRegistry $instance = null;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @link https://github.com/DevNet-Framework
88
*/
99

10-
namespace DevNet\CLI\Commands;
10+
namespace DevNet\CLI\Plugin;
1111

1212
use DevNet\System\Command\CommandLine;
1313

src/Plugin/TemplateRegistry.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace DevNet\CLI\Plugin;
1111

12-
use DevNet\CLI\Commands\AbstractRegistry;
13-
1412
class TemplateRegistry extends AbstractRegistry
1513
{
1614
private static ?TemplateRegistry $instance = null;

src/Program.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use DevNet\CLI\Commands\AddCommand;
1313
use DevNet\CLI\Commands\NewCommand;
1414
use DevNet\CLI\Commands\RunCommand;
15-
use DevNet\CLI\Commands\CommandRegistry;
15+
use DevNet\CLI\Plugin\CommandRegistry;
1616
use DevNet\System\Command\CommandEventArgs;
1717
use DevNet\System\Command\CommandLine;
1818
use DevNet\System\IO\ConsoleColor;

0 commit comments

Comments
 (0)