Implement dependency injection logic and replace for the respective variables
This issue aims to refactor the existing codebase to modern best practices by replacing direct calls to \Drupal:: static methods with dependency injection. Direct calls to \Drupal:: are considered deprecated and can lead to tight coupling and difficulties in testing and maintainability. By utilizing dependency injection, we can improve the codebase's modularity, flexibility, and testability.