LinksCollectorTrait::createLink

@param string      $label
@param string|null $href
195803
public function createLink($label, $href = null)
    {
        $link = new Link($label, $href);

        if ( ! $this->links instanceof ArrayIterator) {
            $this->links = new ArrayIterator();
        }

        $this->links->push($link);
    }
552380
public function createLink($label, $href = null)
    {
        if ( ! $this->attributes->hasAttributeClass('lead')) {
            $this->attributes->addAttributeClass('lead');
        }

        $link = new Link($label, $href);
        $link->attributes->addAttributeClass(['btn', 'btn-primary', 'btn-lg']);
        $this->childNodes->push($link);

        return $this->childNodes->last();
    }
745626
public static function menuLink($label, $url, $htmlOptions = array())
    {
        TbArray::defaultValue('role', 'menuitem', $htmlOptions);
        $linkOptions = TbArray::popValue('linkOptions', $htmlOptions, array());
        $content = self::link($label, $url, $linkOptions);
        return self::tag('li', $htmlOptions, $content);
    }
343901
public function setSource($name, $href = null)
    {
        $this->source = new Element('cite', 'source');

        if (isset($href)) {
            $this->source->childNodes->push(new Link($name, $href));
        } else {
            $this->source->textContent->push($name);
        }

        return $this;
    }
197388
public function addLink($key, $href, array $meta=[]) {
		$this->ensureLinksObject();
		$this->links->add($key, $href, $meta);
	}
732810
public function addColumnLink($key, $name, $href = null, $column = null, array $params = null)
	{
		$this->addColumnCheck($key);
		$column = $column ?: $key;
		$href = $href ?: $key;

		if ($params === null) {
			$params = [$this->primary_key];
		}

		return $this->addColumn($key, new Column\ColumnLink($this, $key, $column, $name, $href, $params));
	}
1214727
public function link($location, $label = '[link]')
    {
        if ((string) $location === '') {
            return '';
        }

        if (Html::isURL($location)) {
            $location = Html::addScheme($location);
        } elseif ($record = $this->em->getContent($location)) {
            $location = $record->link();
        }

        return sprintf('<a href="%s">%s</a>', $location, $label);
    }
895364
function createLink(link) {
        var $link = $('<a>').addClass(CSS_CLASS_PAGE_LINK),
            left = link.bbox[0],
            top = link.bbox[1],
            attr = {};

        if (browser.ie) {
            // @NOTE: IE doesn't allow override of ctrl+click on anchor tags,
            // but there is a workaround to add a child element (which triggers
            // the onclick event first)
            $('<span>')
                .appendTo($link)
                .on('click', handleClick);
        }

        $link.css({
            left: left + 'pt',
            top: top + 'pt',
            width: link.bbox[2] - left + 'pt',
            height: link.bbox[3] - top + 'pt'
        });

        if (link.uri) {
            if (/^http|^mailto/.test(link.uri)) {
                attr.href = encodeURI(link.uri);
                attr.target = '_blank';
                attr.rel = 'noreferrer'; // strip referrer for privacy
            } else {
                // don't embed this link... we don't trust the protocol
                return;
            }
        } else if (link.destination) {
            attr.href = '#page-' + link.destination.pagenum;
        }

        $link.attr(attr);
        $link.data('link', link);
        $link.appendTo($el);
    }
1120692
public function victoireLink($parameters, $label, $attr = [], $currentClass = 'active', $url = '#')
    {
        $referenceLink = UrlGeneratorInterface::ABSOLUTE_PATH;
        /** @var Widget $attachedWidget */
        $attachedWidget = isset($parameters[Link::TYPE_WIDGET]) ? $parameters[Link::TYPE_WIDGET] : null;

        if ($parameters['linkType'] == Link::TYPE_WIDGET && $attachedWidget && method_exists($attachedWidget->getWidgetMap()->getView(), 'getUrl')) {
            $viewUrl = $this->router->generate('victoire_core_page_show', ['_locale' => $attachedWidget->getWidgetMap()->getView()->getCurrentLocale(), 'url' => $attachedWidget->getWidgetMap()->getView()->getUrl()], $referenceLink);
            if ($this->request && (rtrim($this->request->getRequestUri(), '/') == rtrim($viewUrl, '/'))) {
                $attr['data-scroll'] = 'smooth';
            }
        }

        //Avoid to refresh page if not needed
        if ($this->request && ($this->request->getRequestUri() == $this->victoireLinkUrl($parameters, false))) {
            $this->addAttr('class', $currentClass, $attr);
        }

        //Build the target attribute
        if ($parameters['target'] == Link::TARGET_MODAL) {
            $attr['data-toggle'] = 'viclink-modal';
        } elseif ($parameters['target'] == '') {
            $attr['target'] = '_parent';
        } else {
            $attr['target'] = $parameters['target'];
        }

        //Add the analytics tracking code attribute
        if (isset($parameters['analyticsTrackCode'])) {
            $this->addAttr('onclick', $parameters['analyticsTrackCode'], $attr);
        }

        $url = $this->victoireLinkUrl($parameters, true, $url);
        // if modalLayout is set, we add it as GET parameter
        if ($parameters['target'] == Link::TARGET_MODAL && !empty($parameters['modalLayout'])) {
            $url .= !preg_match('/\?/', $url) ? '?' : '&';
            $url .= 'modalLayout='.$parameters['modalLayout'];
        }
        //Creates a new twig environment
        $twig = new \Twig_Environment(new \Twig_Loader_Array(['linkTemplate' => '{{ link|raw }}']));

        return $twig->render('linkTemplate', ['link' => '<a href="'.$url.'" '.$this->formatAttributes($attr).'>'.$label.'</a>']);
    }
703729
public static function link($text, $link = '#', array $attributes = array())
    {
        if (!is_null($link)) {
            $attributes['href'] = $link;
        }

        $node = new Node\Link($text);
        return $node->render($attributes);
    }
866497
protected function doActive($href, $label)
    {
        if (is_array($this->active) && array_key_exists('callback', $this->active)) {
            $this->active = $this->active['callback'];
        }

        if ($this->active) {
            // Find active path in array
            if (is_array($this->active) && count($this->active) > 0) {
                $result = array_search($href, $this->active);

                if ($result !== false) {
                    unset($this->active[$result]);

                    return 'class="active"';
                }
            }

            // Run the closure for user customizable
            elseif ($this->active instanceof Closure) {
                call_user_func_array($this->active, [$this, $href, $label]);
                $attrs = $this->renderAttr($this->optionAttr);
                $this->optionAttr = null;

                return $attrs;
            } else {
                if ($this->active == $href) {
                    $this->active = null;

                    return 'class="active"';
                }
            }
        }
    }
24327
public function createItem($label = null, $href = null)
    {
        $link = new Link($label, $href);
        $link->attributes->addAttributeClass('dropdown-item');

        $this->childNodes->push($link);

        return $this->childNodes->last();
    }
705313
public function link($href = '', $target = '_blank')
    {
        return $this->unescape()->as(function ($link) use ($href, $target) {
            $href = $href ?: $link;

            return "<a href='$href' target='{$target}'>{$link}</a>";
        });
    }
940279
public function createNode($parentKey, $key, $label, $value, $count, $selected)
    {
        /** @var $parentNode Node|null */
        $parentNode = isset($this->nodesByKey[$parentKey]) ? $this->nodesByKey[$parentKey] : null;
        $node = new Node($this, $parentNode, $key, $label, $value, $count, $selected);
        $this->nodesByKey[$key] = $node;

        if ($parentNode === null) {
            $this->addChildNode($node);
        } else {
            $parentNode->addChildNode($node);
        }

        $this->allNodes->add($node);
    }
385975
public static function buttonDropdown($label, $items, $htmlOptions = array())
    {
        $htmlOptions['items'] = $items;
        $type = TbArray::popValue('type', $htmlOptions, self::BUTTON_TYPE_LINKBUTTON);
        return self::btn($type, $label, $htmlOptions);
    }
1120347
public function link( string $target, string $link )
	{
		if( Helper::isOsWindows() )
		{
			$mode = $this->isDirectory( $target ) ? 'J' : 'H';
			exec( "mklink /{$mode} \"{$link}\" \"{$target}\"" );
		}
		else
		{
			symlink( $target, $link );
		}
	}
1074559
public static Link link(String href, String rel) {
        return link(href, rel, null, null, null);
    }