Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- interface IAuthenticationService
- {
- function authenticate($username, $password);
- }
- class DbAuthenticationService implements IAuthenticationService
- {
- public function authenticate($username, $password)
- {
- // prihlasit
- }
- }
- class LazyAuthenticationService implements IAuthenticationService
- {
- private $realAuthService;
- private $container;
- public function __construct(IContainer $container)
- {
- $this->container = $container;
- }
- public function authenticate($username, $password)
- {
- $this->initRealService();
- return $this->realAuthService();
- }
- private function initRealService()
- {
- if (null === $this->realAuthService) {
- $this->$realAuthService = $this->container->getService("authService");
- }
- }
- }
- class AuthPresenter extends BasePresenter
- {
- private $authService;
- function __construct(IAuthenticationService $authService)
- {
- $this->authService = $authService;
- }
- function formSubmitted()
- {
- $this->authService->authenticate();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement