Issues

ZF-7794: Navigation with Scheme classification

Issue Type: New Feature Created: 2009-09-07T13:01:09.000+0000 Last Updated: 2012-06-15T14:37:49.000+0000 Status: Resolved Fix version(s): - 1.12.0 (27/Aug/12)

Reporter: Jason Brumwell (baxter) Assignee: Frank Brückner (frosch) Tags: - Zend_Navigation

  • FixForZF1.12
  • zf-crteam-priority
  • zf-crteam-review

Related issues: Attachments: - Mvc.php.patch

Description

I'm unsure if there is already a method of achieving this but from what I could see there wasn't. I ran into a position where I needed to ensure two things:

a. make sure the link to checkout was always an https link b. ensure other links on the site were http protocal so that the user didn't get trapped in the https

Checking Zend_Navigation I didn't see a way to acheive this, this is the alterations I made to make it work:

Zend/Navigation/Page/Mvc.php

<pre class="highlight">
/**
     * Scheme to use when assembling URL
     *
     * @see getHref()
     * @var string
     */
    protected $_scheme;

/**
     * View helper for assembling URLs with schemes
     *
     * @see getHref()
     * @var Zend_View_Helper_ServerUrl
     */
    protected static $_schemeHelper = null;



<pre class="highlight">
$url = self::$_urlHelper->url($params,
                                      $this->getRoute(),
                                      $this->getResetParams());

        if ($this->getScheme() != null)
        {
            if (null === self::$_schemeHelper)
            {
               self::$_schemeHelper = new Zend_View_Helper_ServerUrl();
            }
            
            $url = self::$_schemeHelper->setScheme($this->getScheme())->serverUrl($url);
        }

        return $this->_hrefCache = $url;



<pre class="highlight">
/**
     * Sets scheme to use when assembling URL
     *
     * @see getHref()
     *
     * @param  string|null $module        scheme
     * @return Zend_Navigation_Page_Mvc   fluent interface, returns self
     */
    public function setScheme($scheme)
    {
        $this->_scheme = $scheme;
        return $this;
    }

    /**
     * Returns scheme to use when assembling URL
     *
     * @see getHref()
     *
     * @return string|null  scheme or null
     */
    public function getScheme()
    {
        return $this->_scheme;
    }

If theres already a built in method of acheiving this it would be great to hear how.

Cheers,

Jay

Comments

Posted by Robin Skoglund (robinsk) on 2009-10-16T14:34:35.000+0000

You could call setScheme('http') on the ServerUrl helper and manually specify https for the page which needs it.

Posted by Frank Brückner (frosch) on 2012-03-21T20:45:07.000+0000

Patch and unit tests added.

Posted by Adam Lundrigan (adamlundrigan) on 2012-06-15T14:37:49.000+0000

Fixed in trunk (1.12.0): r24964

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts