本文整理汇总了PHP中Nette\Application\UI\Presenter::link方法的典型用法代码示例。如果您正苦于以下问题:PHP Presenter::link方法的具体用法?PHP Presenter::link怎么用?PHP Presenter::link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Presenter
的用法示例。
在下文中一共展示了Presenter::link方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* @param string $name
* @param Selection $selection
* @return Grid
* @throws GridNotExistsException
*/
public function create($name, Selection $selection)
{
$className = '\\App\\AdminModule\\Grid\\' . $name;
if (!class_exists($className)) {
throw new GridNotExistsException("Grid class {$className} does not exist!");
}
if ($this->presenter === NULL) {
throw new InvalidArgumentException('Presenter must be set!');
}
/** @var Grid $grid */
$grid = new $className($this->db, $selection);
$grid->setDefaultPerPage(100);
$grid->setModel($selection)->setTranslator(new FileTranslator('cs'));
$grid->addActionHref('edit', '')->setIcon('pencil');
$grid->addActionHref('hide', 'Skrýt')->setCustomRender(function ($row) {
$icon = Html::el('i');
$button = Html::el('a')->href($this->presenter->link('hide!', $row->id))->title('Skrýt');
if (isset($row->visible)) {
$icon->class('fa fa-eye');
if ($row->visible) {
$button->class('btn btn-default btn-xs btn-mini');
} else {
$button->class('btn btn-danger btn-xs btn-mini');
}
$button->setHtml($icon);
} else {
$button->style('display: none');
}
return $button;
});
$grid->addActionHref('delete', '', 'delete!')->setIcon('times')->setConfirm('Opravdu smazat?');
return $grid;
}
示例2: addLinkAttr
public function addLinkAttr(&$button, $attr_name, Link $link)
{
$href = $link->create($this->data);
if (!$link->hasUseNetteLink()) {
$button->addAttributes(array($attr_name => reset($href)));
} else {
if ($href === FALSE) {
return FALSE;
}
list($to_href, $params) = $href;
$used_component = $link->getUsedComponent();
if (!is_null($used_component)) {
if (is_string($used_component)) {
$href_attribute = $this->presenter[$used_component]->link($to_href, $params);
} elseif (is_array($used_component)) {
$component = $this->presenter;
foreach ($used_component as $component_name) {
$component = $component[$component_name];
}
$href_attribute = $component->link($to_href, $params);
} else {
throw new Grid_Exception('Link::COMPONENT must be string or array, ' . gettype($used_component) . ' given.');
}
$button->addAttributes(array($attr_name => $href_attribute));
} else {
$button->addAttributes(array($attr_name => $this->presenter->link($to_href, $params)));
}
}
return TRUE;
}
示例3: create
public function create($data)
{
if ($this->option[self::DISABLED] === TRUE) {
return FALSE;
}
if (is_null($this->presenter)) {
throw new Grid_Exception('Presenter is not set for DropDownLink.');
}
$link = $this->option[self::LINK]->create($data);
if (!$link) {
return FALSE;
}
list($to_href, $params, $name) = $link;
if ($this->option[self::LINK]->hasUseNetteLink()) {
$used_component = $this->option[self::LINK]->getUsedComponent();
if (!is_null($used_component)) {
if (is_string($used_component)) {
$href_param = $this->presenter[$used_component]->link($to_href, $params);
} elseif (is_array($used_component)) {
$component = $this->presenter;
foreach ($used_component as $component_name) {
$component = $component[$component_name];
}
$href_param = $component->link($to_href, $params);
} else {
throw new Grid_Exception('Link::COMPONENT must be string or array, ' . gettype($used_component) . ' given.');
}
} else {
$href_param = $this->presenter->link($to_href, $params);
}
} else {
$href_param = $to_href;
}
$a = Html::el('a', array('role' => 'menuitem', 'tabindex' => '-1', 'href' => $href_param));
$a->setText($this->getTranslator() ? $this->getTranslator()->translate($name) : $name);
if (!isset($this->option[self::ATTRIBUTES]['role'])) {
$this->option[self::ATTRIBUTES]['role'] = 'presentation';
}
$li = Html::el('li', $this->option[self::ATTRIBUTES]);
$li->add($a);
return $li;
}
示例4: link
/**
* Create resource link representation object
* @param string $destination
* @param array $args
* @param string $rel
* @return Link
*/
public function link($destination, $args = array(), $rel = Link::SELF)
{
$href = parent::link($destination, $args);
return new Link($href, $rel);
}
示例5: link
/**
* Generates link. If links points to @secure annotated signal handler method, additonal
* parameter preventing changing parameters will be added.
*
* @param string
* @param array|mixed $args
* @return string
*/
public function link($destination, $args = array())
{
if (!is_array($args)) {
$args = func_get_args();
array_shift($args);
}
$link = parent::link($destination, $args);
$lastRequest = $this->getPresenter()->getLastCreatedRequest();
// bad link
if ($lastRequest === NULL) {
return $link;
}
// not a signal
if (substr($destination, -1) !== '!') {
return $link;
}
// signal must lead to this presenter
if ($this->getPresenter()->getName() !== $lastRequest->getPresenterName()) {
return $link;
}
$destination = str_replace(':', '-', $destination);
if (strpos($destination, '-') !== FALSE) {
$pos = strrpos($destination, '-');
$signal = substr($destination, $pos + 1, -1);
$component = substr($destination, 0, $pos);
$component = $this->getComponent($component);
} else {
$signal = substr($destination, 0, -1);
$component = $this;
}
// only components
if (!$component instanceof PresenterComponent) {
return $link;
}
$method = $component->formatSignalMethod($signal);
$reflection = Method::from($component, $method);
// does not have annotation
if (!$reflection->hasAnnotation('secured')) {
return $link;
}
$origParams = $lastRequest->getParameters();
$protectedParams = array();
foreach ($reflection->getParameters() as $param) {
if ($param->isOptional()) {
continue;
}
$protectedParams[$param->name] = $origParams[$component->getParameterId($param->name)];
}
$uniqueId = $this->getUniqueId();
if (empty($uniqueId)) {
$paramName = $component->getParameterId('__sec');
} else {
$paramName = substr($component->getParameterId('__sec'), strlen($uniqueId) + 1);
}
$args[$paramName] = $this->createSecureHash($protectedParams);
return parent::link($destination, $args);
}