I would like to provide a way to replace these static helpers that started to showing up in this package.
For example UserHelper:getBy("email", "example@example.com) is reaching to other class and doing some magic. What if someone would like to replace it with simple
public static function getBy(string $field, string $value): ?object
{
return \MyApplication\Eloquent\User::query()->where($field, $value)->first();
}
or maybe something more complex?
We could create a small service container for contexts and connect it to configuratinon file. So, for example, instead of using UserHelper:getBy("email", "example@example.com), we could use ContextHelper::get(UserHelper::class)->getBy("email", "example@example.com) or even ContextHelper::get("user")->getBy("email", "example@example.com)
And then, config file could have an array of options than could be changed by end user:
I would like to provide a way to replace these static helpers that started to showing up in this package.
For example
UserHelper:getBy("email", "example@example.com)
is reaching to other class and doing some magic. What if someone would like to replace it with simpleor maybe something more complex?
We could create a small service container for contexts and connect it to configuratinon file. So, for example, instead of using
UserHelper:getBy("email", "example@example.com)
, we could useContextHelper::get(UserHelper::class)->getBy("email", "example@example.com)
or evenContextHelper::get("user")->getBy("email", "example@example.com)
And then, config file could have an array of options than could be changed by end user:
Service provider should be empty-config-proof.