@@ -6,5 +6,5 @@ |
||
| 6 | 6 | |
| 7 | 7 | class EntityMapNotFoundException extends RuntimeException |
| 8 | 8 | { |
| 9 | - // |
|
| 9 | + // |
|
| 10 | 10 | } |
@@ -9,9 +9,9 @@ |
||
| 9 | 9 | |
| 10 | 10 | class ValueObject implements Mappable, ArrayAccess, Jsonable, JsonSerializable, Arrayable |
| 11 | 11 | { |
| 12 | - use MappableTrait; |
|
| 13 | - use MagicGetters; |
|
| 14 | - use MagicSetters; |
|
| 15 | - use MagicCasting; |
|
| 12 | + use MappableTrait; |
|
| 13 | + use MagicGetters; |
|
| 14 | + use MagicSetters; |
|
| 15 | + use MagicCasting; |
|
| 16 | 16 | } |
| 17 | 17 | |
@@ -4,97 +4,97 @@ |
||
| 4 | 4 | |
| 5 | 5 | class ValueMap |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * @var string |
|
| 9 | - */ |
|
| 10 | - protected $name; |
|
| 7 | + /** |
|
| 8 | + * @var string |
|
| 9 | + */ |
|
| 10 | + protected $name; |
|
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - protected $class; |
|
| 12 | + /** |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + protected $class; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @var array |
|
| 19 | - */ |
|
| 20 | - protected $embeddables = []; |
|
| 17 | + /** |
|
| 18 | + * @var array |
|
| 19 | + */ |
|
| 20 | + protected $embeddables = []; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @var array |
|
| 24 | - */ |
|
| 25 | - protected $attributes = []; |
|
| 22 | + /** |
|
| 23 | + * @var array |
|
| 24 | + */ |
|
| 25 | + protected $attributes = []; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var array |
|
| 29 | - */ |
|
| 30 | - protected $properties = []; |
|
| 27 | + /** |
|
| 28 | + * @var array |
|
| 29 | + */ |
|
| 30 | + protected $properties = []; |
|
| 31 | 31 | |
| 32 | - protected $arrayName = null; |
|
| 32 | + protected $arrayName = null; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @return array |
|
| 36 | - */ |
|
| 37 | - public function getAttributes() |
|
| 38 | - { |
|
| 39 | - return $this->attributes; |
|
| 40 | - } |
|
| 34 | + /** |
|
| 35 | + * @return array |
|
| 36 | + */ |
|
| 37 | + public function getAttributes() |
|
| 38 | + { |
|
| 39 | + return $this->attributes; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * [getAttributesArrayName description]. |
|
| 44 | - * |
|
| 45 | - * @return [type] [description] |
|
| 46 | - */ |
|
| 47 | - public function getAttributesArrayName() |
|
| 48 | - { |
|
| 49 | - return $this->arrayName; |
|
| 50 | - } |
|
| 42 | + /** |
|
| 43 | + * [getAttributesArrayName description]. |
|
| 44 | + * |
|
| 45 | + * @return [type] [description] |
|
| 46 | + */ |
|
| 47 | + public function getAttributesArrayName() |
|
| 48 | + { |
|
| 49 | + return $this->arrayName; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - public function usesAttributesArray() |
|
| 53 | - { |
|
| 54 | - return $this->arrayName != null; |
|
| 55 | - } |
|
| 52 | + public function usesAttributesArray() |
|
| 53 | + { |
|
| 54 | + return $this->arrayName != null; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @return array |
|
| 59 | - */ |
|
| 60 | - public function getProperties() |
|
| 61 | - { |
|
| 62 | - return $this->properties; |
|
| 63 | - } |
|
| 57 | + /** |
|
| 58 | + * @return array |
|
| 59 | + */ |
|
| 60 | + public function getProperties() |
|
| 61 | + { |
|
| 62 | + return $this->properties; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @return array |
|
| 67 | - */ |
|
| 68 | - public function getEmbeddables() |
|
| 69 | - { |
|
| 70 | - return $this->embeddables; |
|
| 71 | - } |
|
| 65 | + /** |
|
| 66 | + * @return array |
|
| 67 | + */ |
|
| 68 | + public function getEmbeddables() |
|
| 69 | + { |
|
| 70 | + return $this->embeddables; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @param $class |
|
| 75 | - */ |
|
| 76 | - public function setClass($class) |
|
| 77 | - { |
|
| 78 | - $this->class = $class; |
|
| 79 | - } |
|
| 73 | + /** |
|
| 74 | + * @param $class |
|
| 75 | + */ |
|
| 76 | + public function setClass($class) |
|
| 77 | + { |
|
| 78 | + $this->class = $class; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * @return mixed |
|
| 83 | - */ |
|
| 84 | - public function getClass() |
|
| 85 | - { |
|
| 86 | - return $this->class; |
|
| 87 | - } |
|
| 81 | + /** |
|
| 82 | + * @return mixed |
|
| 83 | + */ |
|
| 84 | + public function getClass() |
|
| 85 | + { |
|
| 86 | + return $this->class; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * @return string |
|
| 91 | - */ |
|
| 92 | - public function getName() |
|
| 93 | - { |
|
| 94 | - if (isset($this->name)) { |
|
| 95 | - return $this->name; |
|
| 96 | - } else { |
|
| 97 | - return class_basename($this); |
|
| 98 | - } |
|
| 99 | - } |
|
| 89 | + /** |
|
| 90 | + * @return string |
|
| 91 | + */ |
|
| 92 | + public function getName() |
|
| 93 | + { |
|
| 94 | + if (isset($this->name)) { |
|
| 95 | + return $this->name; |
|
| 96 | + } else { |
|
| 97 | + return class_basename($this); |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | 100 | } |
@@ -7,28 +7,28 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | trait MagicSetters |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Dynamically set attributes on the entity. |
|
| 12 | - * |
|
| 13 | - * @param string $key |
|
| 14 | - * @param mixed $value |
|
| 15 | - * |
|
| 16 | - * @return void |
|
| 17 | - */ |
|
| 18 | - public function __set($key, $value) |
|
| 19 | - { |
|
| 20 | - $this->attributes[$key] = $value; |
|
| 21 | - } |
|
| 10 | + /** |
|
| 11 | + * Dynamically set attributes on the entity. |
|
| 12 | + * |
|
| 13 | + * @param string $key |
|
| 14 | + * @param mixed $value |
|
| 15 | + * |
|
| 16 | + * @return void |
|
| 17 | + */ |
|
| 18 | + public function __set($key, $value) |
|
| 19 | + { |
|
| 20 | + $this->attributes[$key] = $value; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Unset an attribute on the entity. |
|
| 25 | - * |
|
| 26 | - * @param string $key |
|
| 27 | - * |
|
| 28 | - * @return void |
|
| 29 | - */ |
|
| 30 | - public function __unset($key) |
|
| 31 | - { |
|
| 32 | - unset($this->attributes[$key]); |
|
| 33 | - } |
|
| 23 | + /** |
|
| 24 | + * Unset an attribute on the entity. |
|
| 25 | + * |
|
| 26 | + * @param string $key |
|
| 27 | + * |
|
| 28 | + * @return void |
|
| 29 | + */ |
|
| 30 | + public function __unset($key) |
|
| 31 | + { |
|
| 32 | + unset($this->attributes[$key]); |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -7,32 +7,32 @@ |
||
| 7 | 7 | |
| 8 | 8 | abstract class Command |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * The aggregated entity on which the command is executed. |
|
| 12 | - * |
|
| 13 | - * @var \Analogue\ORM\System\Aggregate |
|
| 14 | - */ |
|
| 15 | - protected $aggregate; |
|
| 10 | + /** |
|
| 11 | + * The aggregated entity on which the command is executed. |
|
| 12 | + * |
|
| 13 | + * @var \Analogue\ORM\System\Aggregate |
|
| 14 | + */ |
|
| 15 | + protected $aggregate; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Query Builder instance. |
|
| 19 | - * |
|
| 20 | - * @var \Illuminate\Database\Query\Builder |
|
| 21 | - */ |
|
| 22 | - protected $query; |
|
| 17 | + /** |
|
| 18 | + * Query Builder instance. |
|
| 19 | + * |
|
| 20 | + * @var \Illuminate\Database\Query\Builder |
|
| 21 | + */ |
|
| 22 | + protected $query; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Command constructor. |
|
| 26 | - * |
|
| 27 | - * @param Aggregate $aggregate |
|
| 28 | - * @param QueryAdapter|\Analogue\ORM\Drivers\IlluminateQueryAdapter $query |
|
| 29 | - */ |
|
| 30 | - public function __construct(Aggregate $aggregate, Builder $query) |
|
| 31 | - { |
|
| 32 | - $this->aggregate = $aggregate; |
|
| 24 | + /** |
|
| 25 | + * Command constructor. |
|
| 26 | + * |
|
| 27 | + * @param Aggregate $aggregate |
|
| 28 | + * @param QueryAdapter|\Analogue\ORM\Drivers\IlluminateQueryAdapter $query |
|
| 29 | + */ |
|
| 30 | + public function __construct(Aggregate $aggregate, Builder $query) |
|
| 31 | + { |
|
| 32 | + $this->aggregate = $aggregate; |
|
| 33 | 33 | |
| 34 | - $this->query = $query->from($aggregate->getEntityMap()->getTable()); |
|
| 35 | - } |
|
| 34 | + $this->query = $query->from($aggregate->getEntityMap()->getTable()); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - abstract public function execute(); |
|
| 37 | + abstract public function execute(); |
|
| 38 | 38 | } |
@@ -6,39 +6,39 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Delete extends Command |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Execute the Delete Statement. |
|
| 11 | - * |
|
| 12 | - * @throws MappingException |
|
| 13 | - * @throws \InvalidArgumentException |
|
| 14 | - * |
|
| 15 | - * @return false|void |
|
| 16 | - */ |
|
| 17 | - public function execute() |
|
| 18 | - { |
|
| 19 | - $aggregate = $this->aggregate; |
|
| 9 | + /** |
|
| 10 | + * Execute the Delete Statement. |
|
| 11 | + * |
|
| 12 | + * @throws MappingException |
|
| 13 | + * @throws \InvalidArgumentException |
|
| 14 | + * |
|
| 15 | + * @return false|void |
|
| 16 | + */ |
|
| 17 | + public function execute() |
|
| 18 | + { |
|
| 19 | + $aggregate = $this->aggregate; |
|
| 20 | 20 | |
| 21 | - $entity = $aggregate->getEntityObject(); |
|
| 21 | + $entity = $aggregate->getEntityObject(); |
|
| 22 | 22 | |
| 23 | - $mapper = $aggregate->getMapper(); |
|
| 23 | + $mapper = $aggregate->getMapper(); |
|
| 24 | 24 | |
| 25 | - if ($mapper->fireEvent('deleting', $entity) === false) { |
|
| 26 | - return false; |
|
| 27 | - } |
|
| 25 | + if ($mapper->fireEvent('deleting', $entity) === false) { |
|
| 26 | + return false; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - $keyName = $aggregate->getEntityMap()->getKeyName(); |
|
| 29 | + $keyName = $aggregate->getEntityMap()->getKeyName(); |
|
| 30 | 30 | |
| 31 | - $id = $this->aggregate->getEntityId(); |
|
| 31 | + $id = $this->aggregate->getEntityId(); |
|
| 32 | 32 | |
| 33 | - if (is_null($id)) { |
|
| 34 | - throw new MappingException('Executed a delete command on an entity with "null" as primary key'); |
|
| 35 | - } |
|
| 33 | + if (is_null($id)) { |
|
| 34 | + throw new MappingException('Executed a delete command on an entity with "null" as primary key'); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - $this->query->where($keyName, '=', $id)->delete(); |
|
| 37 | + $this->query->where($keyName, '=', $id)->delete(); |
|
| 38 | 38 | |
| 39 | - $mapper->fireEvent('deleted', $entity, false); |
|
| 39 | + $mapper->fireEvent('deleted', $entity, false); |
|
| 40 | 40 | |
| 41 | - // Once the Entity is successfully deleted, we'll just set the primary key to null. |
|
| 42 | - $aggregate->setEntityAttribute($keyName, null); |
|
| 43 | - } |
|
| 41 | + // Once the Entity is successfully deleted, we'll just set the primary key to null. |
|
| 42 | + $aggregate->setEntityAttribute($keyName, null); |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -4,54 +4,54 @@ |
||
| 4 | 4 | |
| 5 | 5 | trait MagicGetters |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Contains the entity's attributes. |
|
| 9 | - * |
|
| 10 | - * @var array |
|
| 11 | - */ |
|
| 12 | - protected $attributes = []; |
|
| 7 | + /** |
|
| 8 | + * Contains the entity's attributes. |
|
| 9 | + * |
|
| 10 | + * @var array |
|
| 11 | + */ |
|
| 12 | + protected $attributes = []; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Dynamically retrieve attributes on the entity. |
|
| 16 | - * |
|
| 17 | - * @param string $key |
|
| 18 | - * |
|
| 19 | - * @return mixed |
|
| 20 | - */ |
|
| 21 | - public function __get($key) |
|
| 22 | - { |
|
| 23 | - // When using mixed mapping, we will check |
|
| 24 | - // for a class property corresponding to |
|
| 25 | - // the attribute's key first. |
|
| 26 | - // |
|
| 27 | - // Note : this may raise issues as we may grant |
|
| 28 | - // access to unwanted properties, like class dependencies. |
|
| 29 | - // |
|
| 30 | - // -> Solution would be to access the entityMap's $attributes, but we |
|
| 31 | - // have to do this in a very efficient way. |
|
| 32 | - // |
|
| 33 | - // Manager::getEntityMap(get_class($this))->hasProperty() |
|
| 34 | - // |
|
| 35 | - // We could do the casting to array / json the same way, and it would |
|
| 14 | + /** |
|
| 15 | + * Dynamically retrieve attributes on the entity. |
|
| 16 | + * |
|
| 17 | + * @param string $key |
|
| 18 | + * |
|
| 19 | + * @return mixed |
|
| 20 | + */ |
|
| 21 | + public function __get($key) |
|
| 22 | + { |
|
| 23 | + // When using mixed mapping, we will check |
|
| 24 | + // for a class property corresponding to |
|
| 25 | + // the attribute's key first. |
|
| 26 | + // |
|
| 27 | + // Note : this may raise issues as we may grant |
|
| 28 | + // access to unwanted properties, like class dependencies. |
|
| 29 | + // |
|
| 30 | + // -> Solution would be to access the entityMap's $attributes, but we |
|
| 31 | + // have to do this in a very efficient way. |
|
| 32 | + // |
|
| 33 | + // Manager::getEntityMap(get_class($this))->hasProperty() |
|
| 34 | + // |
|
| 35 | + // We could do the casting to array / json the same way, and it would |
|
| 36 | 36 | |
| 37 | - if (property_exists($this, $key)) { |
|
| 38 | - return $this->$key; |
|
| 39 | - } |
|
| 37 | + if (property_exists($this, $key)) { |
|
| 38 | + return $this->$key; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - if (array_key_exists($key, $this->attributes)) { |
|
| 42 | - return $this->attributes[$key]; |
|
| 43 | - } |
|
| 44 | - } |
|
| 41 | + if (array_key_exists($key, $this->attributes)) { |
|
| 42 | + return $this->attributes[$key]; |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Determine if an attribute exists on the entity. |
|
| 48 | - * |
|
| 49 | - * @param string $key |
|
| 50 | - * |
|
| 51 | - * @return bool |
|
| 52 | - */ |
|
| 53 | - public function __isset($key) |
|
| 54 | - { |
|
| 55 | - return array_key_exists($key, $this->attributes) || property_exists($this, $key); |
|
| 56 | - } |
|
| 46 | + /** |
|
| 47 | + * Determine if an attribute exists on the entity. |
|
| 48 | + * |
|
| 49 | + * @param string $key |
|
| 50 | + * |
|
| 51 | + * @return bool |
|
| 52 | + */ |
|
| 53 | + public function __isset($key) |
|
| 54 | + { |
|
| 55 | + return array_key_exists($key, $this->attributes) || property_exists($this, $key); |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -13,58 +13,58 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class AnalogueServiceProvider extends ServiceProvider |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Indicates if loading of the provider is deferred. |
|
| 18 | - * |
|
| 19 | - * @var bool |
|
| 20 | - */ |
|
| 21 | - protected $defer = false; |
|
| 16 | + /** |
|
| 17 | + * Indicates if loading of the provider is deferred. |
|
| 18 | + * |
|
| 19 | + * @var bool |
|
| 20 | + */ |
|
| 21 | + protected $defer = false; |
|
| 22 | 22 | |
| 23 | - public function boot() |
|
| 24 | - { |
|
| 25 | - // |
|
| 26 | - } |
|
| 23 | + public function boot() |
|
| 24 | + { |
|
| 25 | + // |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Register the service provider. |
|
| 30 | - * |
|
| 31 | - * @return void |
|
| 32 | - */ |
|
| 33 | - public function register() |
|
| 34 | - { |
|
| 35 | - $this->app->singleton('analogue', function ($app) { |
|
| 36 | - $db = $app['db']; |
|
| 28 | + /** |
|
| 29 | + * Register the service provider. |
|
| 30 | + * |
|
| 31 | + * @return void |
|
| 32 | + */ |
|
| 33 | + public function register() |
|
| 34 | + { |
|
| 35 | + $this->app->singleton('analogue', function ($app) { |
|
| 36 | + $db = $app['db']; |
|
| 37 | 37 | |
| 38 | - $connectionProvider = new IlluminateConnectionProvider($db); |
|
| 38 | + $connectionProvider = new IlluminateConnectionProvider($db); |
|
| 39 | 39 | |
| 40 | - $illuminate = new IlluminateDriver($connectionProvider); |
|
| 40 | + $illuminate = new IlluminateDriver($connectionProvider); |
|
| 41 | 41 | |
| 42 | - $driverManager = new DriverManager(); |
|
| 42 | + $driverManager = new DriverManager(); |
|
| 43 | 43 | |
| 44 | - $driverManager->addDriver($illuminate); |
|
| 44 | + $driverManager->addDriver($illuminate); |
|
| 45 | 45 | |
| 46 | - $event = $app->make('events'); |
|
| 46 | + $event = $app->make('events'); |
|
| 47 | 47 | |
| 48 | - $manager = new Manager($driverManager, $event); |
|
| 48 | + $manager = new Manager($driverManager, $event); |
|
| 49 | 49 | |
| 50 | - $manager->registerPlugin(\Analogue\ORM\Plugins\Timestamps\TimestampsPlugin::class); |
|
| 51 | - $manager->registerPlugin(\Analogue\ORM\Plugins\SoftDeletes\SoftDeletesPlugin::class); |
|
| 50 | + $manager->registerPlugin(\Analogue\ORM\Plugins\Timestamps\TimestampsPlugin::class); |
|
| 51 | + $manager->registerPlugin(\Analogue\ORM\Plugins\SoftDeletes\SoftDeletesPlugin::class); |
|
| 52 | 52 | |
| 53 | - return $manager; |
|
| 54 | - }); |
|
| 53 | + return $manager; |
|
| 54 | + }); |
|
| 55 | 55 | |
| 56 | - $this->app->bind(Manager::class, function ($app) { |
|
| 57 | - return $app->make('analogue'); |
|
| 58 | - }); |
|
| 59 | - } |
|
| 56 | + $this->app->bind(Manager::class, function ($app) { |
|
| 57 | + return $app->make('analogue'); |
|
| 58 | + }); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Get the services provided by the provider. |
|
| 63 | - * |
|
| 64 | - * @return array |
|
| 65 | - */ |
|
| 66 | - public function provides() |
|
| 67 | - { |
|
| 68 | - return ['analogue']; |
|
| 69 | - } |
|
| 61 | + /** |
|
| 62 | + * Get the services provided by the provider. |
|
| 63 | + * |
|
| 64 | + * @return array |
|
| 65 | + */ |
|
| 66 | + public function provides() |
|
| 67 | + { |
|
| 68 | + return ['analogue']; |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -4,17 +4,17 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface AnaloguePluginInterface |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * Boot the plugin. |
|
| 9 | - * |
|
| 10 | - * @return void |
|
| 11 | - */ |
|
| 12 | - public function register(); |
|
| 7 | + /** |
|
| 8 | + * Boot the plugin. |
|
| 9 | + * |
|
| 10 | + * @return void |
|
| 11 | + */ |
|
| 12 | + public function register(); |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Get custom events provided by the plugin. |
|
| 16 | - * |
|
| 17 | - * @return array |
|
| 18 | - */ |
|
| 19 | - public function getCustomEvents(); |
|
| 14 | + /** |
|
| 15 | + * Get custom events provided by the plugin. |
|
| 16 | + * |
|
| 17 | + * @return array |
|
| 18 | + */ |
|
| 19 | + public function getCustomEvents(); |
|
| 20 | 20 | } |