Giter Club home page Giter Club logo

zend-navigation's Introduction

zend-navigation's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zend-navigation's Issues

Check For Blockquotes In Docs

Check the document for bad blockquoutes

TLDR; Check blockquotes are formatted correctly using > and check headings in blockquotes are using ###

Blockquotes are donated by a single greater than character and then a space. Make sure all the blockquotes in every doc file are correctly formatted. Headings in blockquotes should use ### and not bold.

Any paragraph spacing in blockquotes should be marked using a single greater than, then a space.

Failed test with all latest components at version 2.x

From Fedora CI
https://apps.fedoraproject.org/koschei/package/php-zendframework-zend-navigation

After upgrade of zend-mvc to 2.7.3 and zend-view-2.6.4

PHPUnit 5.2.10 by Sebastian Bergmann and contributors.
...............................................................  63 / 179 ( 35%)
............................................................... 126 / 179 ( 70%)
.................................................PHP Fatal error:  Call to a member function attach() on boolean in /usr/share/php/Zend/View/Helper/Navigation/AbstractHelper.php on line 959

In travis build some component are 3.x (at least zend-stdlib)

problem with github markdown parser

Hello,

following a short discussion with @froschdesign I report an issue with the github markdown parser regarding pipe symbols.

The pipe sign | in markdown has a special meaning for tables and must therefore be commented out if used otherwise.
As an example, have a look at the table in menu.md.

The final documentation doesn't show the error, but github and maybe other markdown parsers do.

Cheers,
LT.

Trouble with multiple navigations in ZF3

I've created navigation in the configuration file, according to example in Quick Star documentation. It worked with single menu, but once I've tried multiple menu approach I receive the following error:

Fatal error: Uncaught Zend\ServiceManager\Exception\ServiceNotFoundException: Unable to resolve service "ZendNavigationDefault" to a factory; are you certain you provided it during configuration?

The way I call the methof
{% for page in navigation('Zend\Navigation\Default').container %} <a href="{{ url(page.route) }}" class="navbar-item">{{ page.label }}</a> {% endfor %}

Zend Navigation with Zend Expressive - localization ?

hi, i have a little question about Zend Navigataion.
After following cookbook tutorial about setting locale without url param (https://docs.zendframework.com/zend-expressive/cookbook/setting-locale-without-routing-parameter/) i am a bit confused so maybe someone can help me here.

If i enter url like local.com/en/some-page
my locale is set to english and all urls created with UrlHelper get '/en' part prepended
but Zend Navigation is still rendering url without that '/en' part.

What should i do to make Zend Navigation prepend that '/en/' part to all created links just like UrlHelper?
ps. i am using froschdesign/zend-navigation - feature/expressive-support branch

Check Documentation Tables

Check the tables in a document

TLDR; All tables should be in the format of GHFM using | and - as horizontal and vertical separators respectively

Check all tables are in the correct format. Please don't use leading and trailing | - more information on github flavoured markdown tables can be found here.

Fatal error: 'continue' not in the 'loop' or 'switch' context in /zend-view/src/Helper/Navigation/PluginManager.php on line 62

It's originally I commented at zendframework/zend-view#45. I use latest zf2 :

"zendframework/zendframework": "^2.5"

The stacktrace is:

Fatal error: 'continue' not in the 'loop' or 'switch' context in /Users/samsonasik/www/MyProject/vendor/zendframework/zend-view/src/Helper/Navigation/PluginManager.php on line 62
Call Stack
#   Time    Memory  Function    Location
1   0.0002  368728  {main}( )   .../index.php:0
2   0.0843  4939896 Zend\Mvc\Application->run( )    .../index.php:21
3   0.0945  5351360 Zend\Mvc\Application->completeRequest( )    .../Application.php:328
4   0.0945  5351360 Zend\EventManager\EventManager->trigger( )  .../Application.php:353
5   0.0945  5351416 Zend\EventManager\EventManager->triggerListeners( ) .../EventManager.php:214
6   0.0947  5353104 call_user_func:{/Users/samsonasik/www/MyProject/vendor/zendframework/zend-eventmanager/src/EventManager.php:490} ( )    .../EventManager.php:490
7   0.0947  5353104 Zend\Mvc\View\Http\DefaultRenderingStrategy->render( )  .../EventManager.php:490
8   0.0947  5353104 Zend\View\View->render( )   .../DefaultRenderingStrategy.php:103
9   0.1215  5373872 Zend\View\Renderer\PhpRenderer->render( )   .../View.php:207
10  0.1217  5411144 include( '/Users/samsonasik/www/MyProject/module/Application/view/layout/layout.phtml' )    .../PhpRenderer.php:502
11  0.1331  5936048 Zend\View\Helper\Navigation->menu( )    .../layout.phtml:55
12  0.1331  5936104 Zend\View\Helper\Navigation->__call( )  .../layout.phtml:55
13  0.1331  5936104 Zend\View\Helper\Navigation->findHelper( )  .../Navigation.php:112
14  0.1331  5936104 Zend\View\Helper\Navigation->getPluginManager( )    .../Navigation.php:151
15  0.1331  5936104 spl_autoload_call ( )   .../Navigation.php:325
16  0.1331  5936264 Composer\Autoload\ClassLoader->loadClass( ) .../Navigation.php:325
17  0.1331  5936424 Composer\Autoload\includeFile( )    .../ClassLoader.php:301

Zend\Navigation\AbstractContainer->hasChildren() does not seem to work correctly

Hello,

After trying for a few hours to make the zend navigation work, when upgrading from ZF2(2.4) to ZF3, i think i have found a problem with method:
Zend\Navigation\AbstractContainer->hasChildren()
In the past it used to work like this (in ZF 2.4):

  • it would return true if page on which method was called had child pages;
    Now it does not work like this, but does the following:
  • it returns true if first child of current page (on which method is called) has child pages
  • this seems not ok to me, but i may be wrong;

Is this a problem or not ?

Thank you !

Zend\Navigation\Page\Mvc - IsActive Function "improvement ?"

Hello
Right now to check if a Mvc Page is active you guys check if

$this->routeMatch->getMatchedRouteName() === $this->getRoute()

and that the parameters match

 (count(array_intersect_assoc($reqParams, $pageParams)) == count($pageParams)

I was wondering if we could improve this behavior by checking first if the Page route is actually contained in the Matched Route

Lets take an example:
Router conf:

'routes' => array(
            'production' => [
                'type' => 'segment',
                'may_terminate' => true,
                'options' => [
                    'route' => '/production',
                    'defaults' => array(
                        '__NAMESPACE__' => 'Production\Controller',
                        'controller' => 'Index',
                        'action' => 'index'
                    )
                ],
                'child_routes' => [
                    'project' => [
                        'type' => 'segment',
                        'options' => [
                            'route' => '/project[/:action[/:id]]',
                            'defaults' => array(
                                'controller' => 'Project',
                                'action' => 'index'
                            )
                        ],
                    ],

This assume that the child route project is under production

so route "production/project" is a child of "production"

Navigation Conf:

 'navigation' => [
            'production' => [
                'id' => 'project',
                'label' => 'Production label',
                'route' => 'production'

The current isActive function does not work in this situation because the routes are different
The workaround it to create a child navigation under "production" but i feel like it is overkill (as i dont want to display the child page in the navigation (so i use the param visible = 0 ))

My solution would be to check that the page route is contained in the Matched route

strpos($this->routeMatch->getMatchedRouteName(), $this->getRoute().'/') === 0

In my scenario It would check if "production/" is contained in the "production/project" (at the beginning of the string)

And make the Page active

so if you are viewing the site via the "production/project" route it will make all navigation set up to use the route "production" active

Please let me know if that make sense or if I am missing something that would make this solution incorrect

Thank you

Documentation seems to be wrong ...

I found this code snippet in den documenation for the zend-navigation component (ZF3):

Docs » Reference » View Helpers » Intro

The Code snippet provided is not working for me:

<?php
// module/MyModule/Module.php

namespace MyModule;

use Zend\View\HelperPluginManager;
use Zend\Permissions\Acl\Acl;
use Zend\Permissions\Acl\Role\GenericRole;
use Zend\Permissions\Acl\Resource\GenericResource;

class Module
{
    /* ... */
    public function getViewHelperConfig()
    {
        return [
            'factories' => [
                // This will overwrite the native navigation helper
                'navigation' => function(HelperPluginManager $pm) {
                    // Setup ACL:
                    $acl = new Acl();
                    $acl->addRole(new GenericRole('member'));
                    $acl->addRole(new GenericRole('admin'));
                    $acl->addResource(new GenericResource('mvc:admin'));
                    $acl->addResource(new GenericResource('mvc:community.account'));
                    $acl->allow('member', 'mvc:community.account');
                    $acl->allow('admin', null);

                    // Get an instance of the proxy helper
                    $navigation = $pm->get('Zend\View\Helper\Navigation');

                    // Store ACL and role in the proxy helper:
                    $navigation->setAcl($acl);
                    $navigation->setRole('member');

                    // Return the new navigation helper instance
                    return $navigation;
                }
            ]
        ];
    }
    /* ... */
}

First it seems that in ZF3 the HelperPluginManager is not passed to the closure. Instead, I found out that the parent ServiceManager is passed.

If I change it to the code below, then the example is working for me:

class Module
{
    /* ... */
    public function getViewHelperConfig()
    {
        return [
            'factories' => [
                // This will overwrite the native navigation helper
                Helper\Navigation::class => function(\Zend\ServiceManager\ServiceLocatorInterface $serviceManager)
                {
                    $navigationViewHelper = new \Zend\View\Helper\Navigation();
                    $navigationViewHelper->setServiceLocator($serviceManager);

                    // Store ACL and role in the proxy helper:
                    $navigationViewHelper->setAcl($this->acl);
                    $navigationViewHelper->setRole($this->role);

                    // Return the new navigation helper instance
                    return $navigationViewHelper;
                }
            ]
        ];
    }
    /* ... */
}

Am I right? Is the documentation for ZF3 not correct?

Zend\Navigation does not work with Zend\Expressive

I want to use Zend\Navigation in a Zend\Expressive application. First of all, I installed it:

composer require zendframework/zend-navigation

Composer installed it and added the ConfigProvider to my /config/config.php file:

$configManager = new ConfigManager(
    [
        Zend\I18n\ConfigProvider::class,
        Zend\Form\ConfigProvider::class,
        Zend\InputFilter\ConfigProvider::class,
        Zend\Hydrator\ConfigProvider::class,
        Zend\Session\ConfigProvider::class,
        TravelloViewHelper\ConfigProvider::class,
        new PhpFileProvider($pattern),
    ],
    $cachedConfigFile
);

When I try to use the navigation view helper in a template, I get this error:

A plugin by the name "navigation" was not found in the plugin manager Zend\View\HelperPluginManager

So, I added the Zend\Navigation\View\ViewHelperManagerDelegatorFactory to my configuration:

return [
    'dependencies' => [
        'delegators' => [
            Zend\View\HelperPluginManager::class => [
                Zend\Navigation\View\ViewHelperManagerDelegatorFactory::class,
            ],
        ],
    ],
];

No I get this error:

Unable to resolve service "Application" to a factory; are you certain you provided it during configuration?

After some investigation the problem is located here:

https://github.com/zendframework/zend-navigation/blob/master/src/Service/AbstractNavigationFactory.php#L102

The AbstractNavigationFactory seems to have a hard dependency on the MVC application which makes it impossible to use Zend\Navigation with Zend\Expressive currently.

Are there any plans to solve this? What should be done to break up this hard dependency? I guess it would be quite complicated to run Zend\Navigation both with Zend\Mvc and Zend\Expressive, wouldn't it?

Order on n-level (n>1)

In the following example i create a navigation with two levels and then print the navigation labels with echo. As you can see i set an order for both first level pages and for two second level pages. If you look at my output you can see that only the first level pages are in right order. The second level pages arent in right order.

For every level you put in a navigation greater than level one, the order isnt changed.

Anybody of you have the same problem or can tell me what iam doing wrong? Or is this a not given functionality of this module?

Testscript

$container = new \Zend\Navigation\Navigation(
    array(
        array(
            'label' => 'ACL page 1 (guest)',
            'uri' => '#acl-guest',
            'resource' => 'nav-guest',
            'order' => 777,
            'pages' => array(
                 array(
                     'label' => 'ACL page 1.1 (foo)',
                      'uri' => '#acl-foo',
                      'resource' => 'nav-foo',
                      'order' => 666
                  ),
                  array(
                      'label' => 'ACL page 1.2 (bar)',
                       'uri' => '#acl-bar',
                       'resource' => 'nav-bar',
                  ),
                  array(
                      'label' => 'ACL page 1.3 (baz)',
                       'uri' => '#acl-baz',
                       'resource' => 'nav-baz',
                  ),
                  array(
                      'label' => 'ACL page 1.4 (bat)',
                      'uri' => '#acl-bat',
                      'resource' => 'nav-bat',
                      'order' => 111
                  ),
              ),
          ),
          array(
              'label' => 'ACL page 2 (member)',
              'uri' => '#acl-member',
              'resource' => 'nav-member',
              'order' => 555
          )
      )
  );

  foreach ($container as $page) {
      echo $page->label."<br>";
      if ($page->hasPages()) {
          foreach ($page->getPages() as $page2) {
              echo $page2->label."<br>";
          }
      }
  }
  die("ASD");

Output

ACL page 2 (member)
ACL page 1 (guest)
ACL page 1.1 (foo)
ACL page 1.2 (bar)
ACL page 1.3 (baz)
ACL page 1.4 (bat)
ASD

Improvements

  • Better support for dynamic builded navigations instead hardcoded configuration array
  • Put the different dynamic navigations factories to an own plugin manager (maybe)
  • Support to set the default active page. Example:
    Mypage - /test -> Should point to Mysubpage 1
    Mysubpage 1 - /test/page1
    Mysubpage 2 - /test/page2
  • Make the Mvc (Page) more compact and move the logic (example isActive) to the Navigation class.
  • The View Helper Navigation\Menu renderPartial method shold accept additional parameters you want to pass to the partial.

Code is not consistent (internally)

Hi,
1)
in src/Service/AbstractNavigationFactory.php
this seems to not be consistent (see: ServiceLocatorInterface / ContainerInterface)

    /**
     * Create and return a new Navigation instance (v2).
     *
     * @param ContainerInterface $container
     * @param null|string $name
     * @param null|string $requestedName
     * @return Navigation
     */
    public function createService(ServiceLocatorInterface $container, $name = null, $requestedName = null)
    {
        return $this($container, $requestedName);
    }

If i want to filter the pages with ZfcRbac (=>user rights) where should i do that? in getPages() or better use preparePages() or even somewhere else?

Thanks!

Quick Start guide wrong, twice

The quick start guide is wrong. First (small) issue, it has a very obvious syntax error https://docs.zendframework.com/zend-navigation/quick-start/. Look at the array( part in the first code block.

The second issue is worse, and it is plain wrong and its one of the weirdest parts of the navigation module in my opinion. It says to use <?= $this->navigation('default')->menu() ?>, but you will get an error then. You have to use <?= $this->navigation('navigation')->menu() ?> instead.

Check Documentation Code Blocks

Check code blocks are correct

TLDR; Check in all files that codeblocks are correct, in PSR-2 format and have PHP syntax highlighting applied.

Code blocks should be in the following format...

```php
 'ZEND-FRAMEWORK');

// No required options
$rendererOptions = array();
$renderer = Barcode::factory(
    'code39', 'image', $barcodeOptions, $rendererOptions
);

```

Note the three backticks then php in the opening fence, and the closing fence is just three backticks. It's common for the opening backticks to have no code type, or something like source.

Code should also have been automatically formatted into PSR-2 format, but sometimes these slip through the net.

Check Documentation For Other Things

Check docs for other problems

TLDR; Cast your eye over the documetation for any problems not covered in the other issues

Things slip through the net, so check the documentation for other problems that have been missed. Common other problems include

  • Bullet lists (should be single * then space at the start of line)
  • Inline code - should be marked by three backticks at start and finish
  • bookdown.json file is correctly formated and has the right escaping
  • Links between documentation using RST have been stripped
  • Any other RST has been removed correctly
  • Anything and everything not covered

If you end up fixing the same problem over and over, please ping Gary Hockin - we may be able to add bespoke issue for that problem, or fix in automated capacity

Check All Headers In Documentation

Check headers are correct

TLDR; Headers should use the #, ## etc to format different levels of headers, and not be underlines using ===== or ``-----`, or be psuedo header using bold

Check all headers on the documentation - headers should use the hash style of declaration rather then be underlined with equals or dashes. The more hashes, the more of a subheading. Eg:

  • # is equal to <h1>
  • ## is equal to <h2>
  • ### is equal to <h3>
  • #### is equal to <h4>
  • ##### is equal to <h5>

Headings should be appropriate for their level in the documentation.

Psuedo headers using bold tags ** should be replaced with appropriate level of heading tag.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.