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
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • Control
  • Form
  • Link
  • Multiplier
  • Presenter
  • PresenterComponent

Interfaces

  • IRenderable
  • ISignalReceiver
  • IStatePersistent
  • ITemplate
  • ITemplateFactory

Exceptions

  • BadSignalException
  • InvalidLinkException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
  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\Application\UI;
  9: 
 10: use Nette;
 11: 
 12: 
 13: /**
 14:  * Lazy encapsulation of PresenterComponent::link().
 15:  * Do not instantiate directly, use PresenterComponent::lazyLink()
 16:  */
 17: class Link extends Nette\Object
 18: {
 19:     /** @var PresenterComponent */
 20:     private $component;
 21: 
 22:     /** @var string */
 23:     private $destination;
 24: 
 25:     /** @var array */
 26:     private $params;
 27: 
 28: 
 29:     /**
 30:      * Link specification.
 31:      */
 32:     public function __construct(PresenterComponent $component, $destination, array $params)
 33:     {
 34:         $this->component = $component;
 35:         $this->destination = $destination;
 36:         $this->params = $params;
 37:     }
 38: 
 39: 
 40:     /**
 41:      * Returns link destination.
 42:      * @return string
 43:      */
 44:     public function getDestination()
 45:     {
 46:         return $this->destination;
 47:     }
 48: 
 49: 
 50:     /**
 51:      * Changes link parameter.
 52:      * @param  string
 53:      * @param  mixed
 54:      * @return self
 55:      */
 56:     public function setParameter($key, $value)
 57:     {
 58:         $this->params[$key] = $value;
 59:         return $this;
 60:     }
 61: 
 62: 
 63:     /**
 64:      * Returns link parameter.
 65:      * @param  string
 66:      * @return mixed
 67:      */
 68:     public function getParameter($key)
 69:     {
 70:         return isset($this->params[$key]) ? $this->params[$key] : NULL;
 71:     }
 72: 
 73: 
 74:     /**
 75:      * Returns link parameters.
 76:      * @return array
 77:      */
 78:     public function getParameters()
 79:     {
 80:         return $this->params;
 81:     }
 82: 
 83: 
 84:     /**
 85:      * Converts link to URL.
 86:      * @return string
 87:      */
 88:     public function __toString()
 89:     {
 90:         try {
 91:             return (string) $this->component->link($this->destination, $this->params);
 92: 
 93:         } catch (\Throwable $e) {
 94:         } catch (\Exception $e) {
 95:         }
 96:         if (isset($e)) {
 97:             if (func_num_args()) {
 98:                 throw $e;
 99:             }
100:             trigger_error("Exception in " . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
101:         }
102:     }
103: 
104: }
105: 
Nette 2.3-20161221 API API documentation generated by ApiGen 2.8.0