Adds documentation.
This commit is contained in:
@@ -210,6 +210,9 @@ class Bootstrap
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the code to extend models.
|
||||
*/
|
||||
public function extendModels()
|
||||
{
|
||||
AnnotationRegistry::registerLoader("class_exists");
|
||||
|
||||
@@ -17,11 +17,19 @@ class EntityPostLoadEventListener
|
||||
/** @var Game $game */
|
||||
private $game;
|
||||
|
||||
/**
|
||||
* EntityPostLoadEventListener constructor.
|
||||
* @param Game $g
|
||||
*/
|
||||
public function __construct(Game $g)
|
||||
{
|
||||
$this->game = $g;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon event postLoad.
|
||||
* @param LifecycleEventArgs $args
|
||||
*/
|
||||
public function postLoad(LifecycleEventArgs $args)
|
||||
{
|
||||
$entity = $args->getEntity();
|
||||
|
||||
@@ -124,7 +124,7 @@ class LibraryConfiguration
|
||||
/**
|
||||
* Returns a subkey if it exists or null.
|
||||
* @param array $arguments
|
||||
* @return type
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSubKeyIfItExists(array $arguments)
|
||||
{
|
||||
|
||||
@@ -10,11 +10,20 @@ use ReflectionClass;
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use LotGD\Core\Doctrine\Annotations\Extension;
|
||||
|
||||
/**
|
||||
* Contains method to help the extension of a model.
|
||||
* @package LotGD\Core
|
||||
*/
|
||||
class ModelExtender
|
||||
{
|
||||
/** @var AnnotationReader */
|
||||
private $reader;
|
||||
/** @var array */
|
||||
private static $classes = [];
|
||||
|
||||
/**
|
||||
* ModelExtender constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->reader = new AnnotationReader();
|
||||
@@ -65,6 +74,12 @@ class ModelExtender
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a callback registered in the model extender globally.
|
||||
* @param string $modelClassName
|
||||
* @param string $methodName
|
||||
* @return callable|null
|
||||
*/
|
||||
public static function get(string $modelClassName, string $methodName): ?callable
|
||||
{
|
||||
if (empty(self::$classes[$modelClassName])) {
|
||||
|
||||
@@ -5,6 +5,10 @@ namespace LotGD\Core\Tools\Model;
|
||||
|
||||
use LotGD\Core\ModelExtender;
|
||||
|
||||
/**
|
||||
* Trait to add the __call class required for extendable models.
|
||||
* @package LotGD\Core\Tools\Model
|
||||
*/
|
||||
trait ExtendableModel
|
||||
{
|
||||
public function __call($method, $arguments)
|
||||
|
||||
Reference in New Issue
Block a user