Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
      • Traits
    • Reflection
    • Security
    • Tokenizer
    • Utils
  • Tracy
    • Bridges
      • Nette
  • none

Classes

  • ApplicationExtension
  • LatteExtension
  • PresenterFactoryCallback
  • RoutingExtension
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (https://nette.org)
 5:  * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette\Bridges\ApplicationDI;
 9: 
10: use Nette;
11: 
12: 
13: /**
14:  * PresenterFactory callback.
15:  * @internal
16:  */
17: class PresenterFactoryCallback
18: {
19:     /** @var Nette\DI\Container */
20:     private $container;
21: 
22:     /** @var int */
23:     private $invalidLinkMode;
24: 
25:     /** @var string|null */
26:     private $touchToRefresh;
27: 
28: 
29:     public function __construct(Nette\DI\Container $container, $invalidLinkMode, $touchToRefresh)
30:     {
31:         $this->container = $container;
32:         $this->invalidLinkMode = $invalidLinkMode;
33:         $this->touchToRefresh = $touchToRefresh;
34:     }
35: 
36: 
37:     /**
38:      * @return Nette\Application\IPresenter
39:      */
40:     public function __invoke($class)
41:     {
42:         $services = array_keys($this->container->findByTag('nette.presenter'), $class, true);
43:         if (count($services) > 1) {
44:             throw new Nette\Application\InvalidPresenterException("Multiple services of type $class found: " . implode(', ', $services) . '.');
45: 
46:         } elseif (!$services) {
47:             if ($this->touchToRefresh) {
48:                 touch($this->touchToRefresh);
49:             }
50: 
51:             $presenter = $this->container->createInstance($class);
52:             $this->container->callInjects($presenter);
53:             if ($presenter instanceof Nette\Application\UI\Presenter && $presenter->invalidLinkMode === null) {
54:                 $presenter->invalidLinkMode = $this->invalidLinkMode;
55:             }
56:             return $presenter;
57:         }
58: 
59:         return $this->container->createService($services[0]);
60:     }
61: }
62: 
Nette 2.4-20180918 API API documentation generated by ApiGen 2.8.0