- Added a new MsSQL adapter
- Some bugfixes were made within annotations. - Added a new Object Instanciator which allows to manipulate and define how an object from an entity must be instanciated with given value.
This commit is contained in:
1 parent
9df7e65dcf
commit
5bd60129ea
22 files changed
+547
-103
No files matched your search
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Entity;
|
||||
|
||||
class ObjectInstanciator {
|
||||
|
||||
protected array $objectCallbackDefinition;
|
||||
|
||||
public function instanciate(string $type, array $arguments) : object
|
||||
{
|
||||
if ( isset($this->objectCallbackDefinition[$type]) ) {
|
||||
return $this->objectCallbackDefinition[$type](...$arguments);
|
||||
}
|
||||
else {
|
||||
return new $type(...$arguments);
|
||||
}
|
||||
}
|
||||
|
||||
public function registerObject(string $type, Callable $callback) : void
|
||||
{
|
||||
$this->objectCallbackDefinition[$type] = $callback;
|
||||
}
|
||||
|
||||
public function unregisterObject(string $type) : void
|
||||
{
|
||||
unset($this->objectCallbackDefinition[$type]);
|
||||
}
|
||||
|
||||
public function isObjectRegistered(string $type) : bool
|
||||
{
|
||||
return isset($this->objectCallbackDefinition[$type]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user