- Work done on Ulmus which were added within the Bottin de suppléance app
This commit is contained in:
1 parent
7fb591e1f5
commit
9ad2e94d12
9 files changed
+219
-127
No files matched your search
@@ -9,10 +9,6 @@ use Closure;
|
||||
|
||||
class RelationBuilder
|
||||
{
|
||||
const SUBQUERY_FIELD_SUFFIX = "%s\$collection";
|
||||
|
||||
const JOIN_FIELD_SEPARATOR = "%s\$";
|
||||
|
||||
protected Repository $repository;
|
||||
|
||||
protected /*object|string*/ $entity;
|
||||
@@ -118,7 +114,7 @@ class RelationBuilder
|
||||
$this->repository->open();
|
||||
|
||||
foreach($this->wheres as $condition) {
|
||||
$this->repository->where($condition->field, $condition->value, $condition->operator);
|
||||
$this->repository->where($condition->field, is_callable($condition->value) ? call_user_func_array($condition->value, [ $this->entity ]) : $condition->value, $condition->operator);
|
||||
}
|
||||
|
||||
$this->repository->close();
|
||||
@@ -155,8 +151,10 @@ class RelationBuilder
|
||||
$entity = $annotation->entity ?? $this->resolver->properties[$name]['type'];
|
||||
}
|
||||
|
||||
$name = strtolower($name);
|
||||
|
||||
foreach($data ?: $this->entity->entityLoadedDataset as $key => $value) {
|
||||
if ( $key === sprintf(static::SUBQUERY_FIELD_SUFFIX, $name) ) {
|
||||
if ( $key === "{$name}\$collection" ) {
|
||||
if ($value) {
|
||||
if ( null === ( $dataset = \json_decode($value, true) ) ) {
|
||||
throw new \Exception(sprintf("JSON error '%s' from '%s'", \json_last_error_msg(), $value));
|
||||
@@ -168,7 +166,7 @@ class RelationBuilder
|
||||
return $entity::entityCollection();
|
||||
}
|
||||
}
|
||||
elseif ( substr($key, 0, $len ) === sprintf(static::JOIN_FIELD_SEPARATOR, $name) ) {
|
||||
elseif ( substr($key, 0, $len ) === "{$name}\$" ) {
|
||||
$vars[substr($key, $len)] = $value;
|
||||
}
|
||||
}
|
||||
@@ -227,6 +225,11 @@ class RelationBuilder
|
||||
|
||||
})->where( $this->entity::field($bridgeRelation->foreignKey, $relationAlias), is_string($this->entity) ? $this->entity::field($bridgeRelation->foreignKey) : $this->entity->{$bridgeRelation->foreignKey} );
|
||||
|
||||
|
||||
$this->applyWhere();
|
||||
|
||||
$this->applyOrderBy();
|
||||
|
||||
if ($selectBridgeField && $relation->bridgeField) {
|
||||
$this->repository->selectEntity($relation->bridge, $bridgeAlias, $bridgeAlias);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user