- WIP on SQLite Adapter and migration
This commit is contained in:
1 parent
cee978ecfd
commit
9514a46ae7
14 files changed
+98
-40
No files matched your search
@@ -102,23 +102,21 @@ class RelationBuilder
|
||||
|
||||
$this->entity->eventExecute(Event\EntityRelationLoadInterface::class, $name, $this->repository);
|
||||
|
||||
$result = call_user_func([ $this->repository, $relation->function ]);
|
||||
|
||||
return count($result) === 0 ? $this->instanciateEmptyEntity($name, $relation): $result[0];
|
||||
return call_user_func([ $this->repository, $relation->function() ]) ?? $this->instanciateEmptyEntity($name, $relation);
|
||||
|
||||
case $relation->isOneToMany():
|
||||
$this->oneToMany($name, $relation);
|
||||
|
||||
$this->entity->eventExecute(Event\EntityRelationLoadInterface::class, $name, $this->repository);
|
||||
|
||||
return call_user_func([ $this->repository, $relation->function ]);
|
||||
return call_user_func([ $this->repository, $relation->function() ]);
|
||||
|
||||
case $relation->isManyToMany():
|
||||
$this->manyToMany($name, $relation, $relationRelation);
|
||||
|
||||
$this->entity->eventExecute(Event\EntityRelationLoadInterface::class, $name, $this->repository);
|
||||
|
||||
$results = call_user_func([ $this->repository, $relationRelation->function ]);
|
||||
$results = call_user_func([ $this->repository, $relationRelation->function() ]);
|
||||
|
||||
if ($relation->bridgeField ?? false) {
|
||||
$collection = $relation->bridge::entityCollection();
|
||||
@@ -152,7 +150,7 @@ class RelationBuilder
|
||||
$this->repository->open();
|
||||
|
||||
foreach($this->wheres as $condition) {
|
||||
$this->repository->where($condition->field, is_callable($condition->value) ? call_user_func_array($condition->value, [ $this->entity ]) : $condition->getValue(), $condition->operator);
|
||||
$this->repository->where($condition->field, $condition->getValue($this->entity), $condition->operator);
|
||||
}
|
||||
|
||||
$this->repository->close();
|
||||
@@ -201,7 +199,7 @@ class RelationBuilder
|
||||
$vars = [];
|
||||
$len = strlen( $name ) + 1;
|
||||
|
||||
$isRelation = ( $annotation instanceof Relation ) || ($annotation instanceof Attribute\Property\Relation);
|
||||
$isRelation = ( $annotation instanceof Relation ) || ( $annotation instanceof Attribute\Property\Relation );
|
||||
|
||||
if ( $isRelation && $annotation->isManyToMany() ) {
|
||||
$entity = $this->relationAnnotations($name, $annotation)['relationRelation']->entity;
|
||||
@@ -262,7 +260,13 @@ class RelationBuilder
|
||||
$field = $relation->key;
|
||||
|
||||
if ($relation->foreignKey) {
|
||||
$value = ! is_string($field) && is_callable($field) ? $field($this->entity) : $this->entity->$field;
|
||||
if ( $relation->generateKey ) {
|
||||
$value = call_user_func_array($relation->generateKey, [ $this->entity ]);
|
||||
}
|
||||
else {
|
||||
$value = $this->entity->$field;
|
||||
}
|
||||
|
||||
$this->repository->where( is_object($relation->foreignKey) ? $relation->foreignKey : $baseEntity::field($relation->foreignKey), $value );
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user