- Issue created by @arti_parmar
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 7:48am 28 June 2023 - First commit to issue fork.
- 🇮🇳India Raveen Kumar
@arti, I have reviewed your patch And YES You're correct that using dependency injection instead of "User::load" calls can be beneficial in many cases. Dependency injection promotes loose coupling and improves the testability and maintainability of code.
By using dependency injection, you can provide dependencies (such as database connections, repositories, or other services) to a class from the outside, rather than having the class create or access them directly. This makes the class more flexible, as it can work with different implementations of the dependencies without needing to modify its internal code.
Here's an example to illustrate how dependency injection can be used instead of "User::load" calls in a class:
class UserService {
private $userRepository;public function __construct(UserRepository $userRepository) {
$this->userRepository = $userRepository;
}public function getUserById($userId) {
return $this->userRepository->findById($userId);
}}
- @sonam_sharma opened merge request.
- 🇵🇹Portugal nsalves
Thanks for the feedback, all issues were fixed in the newest release
- Status changed to Fixed
over 1 year ago 8:52am 12 August 2023 Automatically closed - issue fixed for 2 weeks with no activity.