Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Scope class for filtering/where impl. for Model #660

Merged
merged 57 commits into from
Jul 23, 2020
Merged
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
e1e0ae7
[feature] introduce basic model scope functionality
georgehristov Jul 21, 2020
c7e2c85
[fix] remove Model::$conditions property
georgehristov Jul 22, 2020
55e527b
[fix] code comments
georgehristov Jul 22, 2020
b25b01e
[update] require strictly correct junction value
georgehristov Jul 22, 2020
64ac1ca
[fix] use assertSame in tests
georgehristov Jul 22, 2020
e57df59
[update] remove unnecessary code
georgehristov Jul 22, 2020
0e0a040
[update] use limit as param name
georgehristov Jul 22, 2020
aae0f5d
[update] shorter way to ensure AND junction in Scope
georgehristov Jul 22, 2020
a233b34
[update] use str_contains
georgehristov Jul 22, 2020
6ff4b73
[fix] change more assertEquals to assertSame
georgehristov Jul 22, 2020
e3783e8
[update] flexibility for bool only when 1 argument
georgehristov Jul 22, 2020
371d2fa
[update] revert commented out code
georgehristov Jul 22, 2020
e0fd02c
[update] set getModel return type
georgehristov Jul 22, 2020
faef583
[update] use str_contains
georgehristov Jul 22, 2020
88ab0f6
[update] remove ! and ? special symbols
georgehristov Jul 23, 2020
845ca31
[update] introduce multi-level reference condition testing
georgehristov Jul 23, 2020
f7f0d13
[update] remove unnecessary check
georgehristov Jul 23, 2020
08be267
[fix] code comments
georgehristov Jul 23, 2020
f5051e6
[update] improve CS
georgehristov Jul 23, 2020
9c497a5
[update] use spread operator in condition merging
georgehristov Jul 23, 2020
a1c17c1
[update] introduce return type for simplify
georgehristov Jul 23, 2020
b9895f7
[update] introduce test for empty IN array
georgehristov Jul 23, 2020
72286a1
[fix] CS fixer
georgehristov Jul 23, 2020
01b9052
[update] remove unnecessary check
georgehristov Jul 23, 2020
c395540
[update] simplify CompoundCondition::clear
georgehristov Jul 23, 2020
99ec94e
[update] trigger onModelChange only if not same model
georgehristov Jul 23, 2020
a5760b7
[update] initQueryConditions returns void
georgehristov Jul 23, 2020
2438abc
[update] include repeating model reference testing
georgehristov Jul 23, 2020
c3849a9
[update] toArrat to toQueryArgumentsArray
georgehristov Jul 23, 2020
463e82a
[update] isEmpty method
georgehristov Jul 23, 2020
acc19e1
[update] use single quotes
georgehristov Jul 23, 2020
0c2cd3e
[fix] operator to words falls back to actual operator value
georgehristov Jul 23, 2020
8f25544
[fix] array persistence query
georgehristov Jul 23, 2020
e62780c
[update] add complex test for referenced records
mvorisek Jul 23, 2020
3662dc8
[fix] remove ? and ! special symbols in toWords
georgehristov Jul 23, 2020
b8b579d
[update] optional model as argument on toWords
georgehristov Jul 23, 2020
95d93df
[fix] operatorToWords
georgehristov Jul 23, 2020
5643d6c
[update] rename toQueryArgumentsArray to toQueryArguments
georgehristov Jul 23, 2020
f8e3e4f
[fix] CS Fixer
georgehristov Jul 23, 2020
9b3d02c
[fix] typo
georgehristov Jul 23, 2020
5f3b779
typo
DarkSide666 Jul 23, 2020
caf4c39
typo
DarkSide666 Jul 23, 2020
719d59e
add complex but always true condition
mvorisek Jul 23, 2020
accfa6c
make onChangeModel protected
mvorisek Jul 23, 2020
b28e39a
[update] separate exception info
georgehristov Jul 23, 2020
3aa7820
[fix] condition with NULL value
georgehristov Jul 23, 2020
47ca200
no need to clone in BasicCondition::toQueryArguments()
mvorisek Jul 23, 2020
08c5191
fix toWords() doc
mvorisek Jul 23, 2020
f22c8a7
remove on() (expensive model clone)
mvorisek Jul 23, 2020
4464c57
[update] simplify toWords further
georgehristov Jul 23, 2020
408e104
rename mergeXx to createXx
mvorisek Jul 23, 2020
1ed5129
new self to new static
mvorisek Jul 23, 2020
8487663
[fix] test toWords
georgehristov Jul 23, 2020
8197334
fix Scope::createAnd/Or for real world usage
mvorisek Jul 23, 2020
1de2aec
make Scope constructor protected
mvorisek Jul 23, 2020
0b65f8e
fix CS
mvorisek Jul 23, 2020
954db74
[update] introduce addCondition method to CompoundCondition
georgehristov Jul 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Model/Scope/CompoundCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(array $nestedConditions = [], string $junction = sel
if (is_array($nestedCondition)) {
// array of OR nested conditions
if (count($nestedCondition) === 1 && isset($nestedCondition[0]) && is_array($nestedCondition[0])) {
$nestedCondition = new self($nestedCondition[0], self::OR);
$nestedCondition = new static($nestedCondition[0], self::OR);
} else {
$nestedCondition = new BasicCondition(...$nestedCondition);
}
Expand Down Expand Up @@ -178,14 +178,14 @@ public function toWords(Model $model = null): string
*/
public static function createAnd(...$conditions)
{
return new self($conditions, self::AND);
return new static($conditions, self::AND);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self is intentional as using Model\Scope::createAnd brings unexpected results

}

/**
* @return static
*/
public static function createOr(...$conditions)
{
return new self($conditions, self::OR);
return new static($conditions, self::OR);
}
}