diff --git a/composer.json b/composer.json
index d7e273aa6..3cc4ce0f5 100644
--- a/composer.json
+++ b/composer.json
@@ -47,9 +47,7 @@
"laminas/laminas-modulemanager": "^2.17",
"laminas/laminas-mvc": "^3.8.0",
"laminas/laminas-mvc-i18n": "^1.9",
- "laminas/laminas-navigation": "^2.20.0",
"laminas/laminas-paginator": "^2.19.0",
- "laminas/laminas-permissions-acl": "^2.16",
"laminas/laminas-router": "^3.14.0",
"laminas/laminas-uri": "^2.12",
"phpunit/phpunit": "^10.5.38",
diff --git a/composer.lock b/composer.lock
index d681095f7..9786db047 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "029a5ecd0779b17346ddf5622045104e",
+ "content-hash": "ff9a3e7ccb74872abb370e04c2e897d9",
"packages": [
{
"name": "laminas/laminas-escaper",
@@ -195,6 +195,7 @@
"type": "community_bridge"
}
],
+ "abandoned": true,
"time": "2024-10-25T09:02:25+00:00"
},
{
@@ -1375,6 +1376,7 @@
"type": "community_bridge"
}
],
+ "abandoned": true,
"time": "2024-11-17T22:10:53+00:00"
},
{
@@ -1741,6 +1743,7 @@
"type": "community_bridge"
}
],
+ "abandoned": true,
"time": "2024-10-16T09:06:57+00:00"
},
{
@@ -1973,87 +1976,6 @@
],
"time": "2024-10-11T09:36:44+00:00"
},
- {
- "name": "laminas/laminas-navigation",
- "version": "2.20.0",
- "source": {
- "type": "git",
- "url": "https://github.com/laminas/laminas-navigation.git",
- "reference": "95f63e660faeb8baff538ed5f8ebde02625c8d14"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-navigation/zipball/95f63e660faeb8baff538ed5f8ebde02625c8d14",
- "reference": "95f63e660faeb8baff538ed5f8ebde02625c8d14",
- "shasum": ""
- },
- "require": {
- "laminas/laminas-stdlib": "^2.7 || ^3.0",
- "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0"
- },
- "conflict": {
- "zendframework/zend-navigation": "*"
- },
- "require-dev": {
- "laminas/laminas-coding-standard": "~3.0.1",
- "laminas/laminas-config": "^3.9.0",
- "laminas/laminas-http": "^2.19",
- "laminas/laminas-i18n": "^2.29",
- "laminas/laminas-mvc": "^3.7",
- "laminas/laminas-permissions-acl": "^2.16",
- "laminas/laminas-router": "^3.14.0",
- "laminas/laminas-servicemanager": "^3.22.1",
- "laminas/laminas-uri": "^2.12.0",
- "laminas/laminas-view": "^2.35",
- "phpunit/phpunit": "^9.6.21",
- "psalm/plugin-phpunit": "^0.19.0",
- "vimeo/psalm": "^5.26.1"
- },
- "suggest": {
- "laminas/laminas-config": "^3.7, to provide page configuration (optional, as arrays and Traversables are also allowed)",
- "laminas/laminas-permissions-acl": "^2.9, to provide ACL-based access restrictions to pages",
- "laminas/laminas-router": "^3.5, to use router-based URI generation with Mvc pages",
- "laminas/laminas-servicemanager": "^3.16, to use the navigation factories",
- "laminas/laminas-view": "^2.14, to use the navigation view helpers"
- },
- "type": "library",
- "extra": {
- "laminas": {
- "component": "Laminas\\Navigation",
- "config-provider": "Laminas\\Navigation\\ConfigProvider"
- }
- },
- "autoload": {
- "psr-4": {
- "Laminas\\Navigation\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "description": "Manage trees of pointers to web pages in order to build navigation systems",
- "homepage": "https://laminas.dev",
- "keywords": [
- "laminas",
- "navigation"
- ],
- "support": {
- "chat": "https://laminas.dev/chat",
- "docs": "https://docs.laminas.dev/laminas-navigation/",
- "forum": "https://discourse.laminas.dev",
- "issues": "https://github.com/laminas/laminas-navigation/issues",
- "rss": "https://github.com/laminas/laminas-navigation/releases.atom",
- "source": "https://github.com/laminas/laminas-navigation"
- },
- "funding": [
- {
- "url": "https://funding.communitybridge.org/projects/laminas-project",
- "type": "community_bridge"
- }
- ],
- "time": "2024-10-16T18:20:23+00:00"
- },
{
"name": "laminas/laminas-paginator",
"version": "2.19.0",
@@ -2133,70 +2055,6 @@
],
"time": "2024-10-16T13:10:19+00:00"
},
- {
- "name": "laminas/laminas-permissions-acl",
- "version": "2.16.0",
- "source": {
- "type": "git",
- "url": "https://github.com/laminas/laminas-permissions-acl.git",
- "reference": "9f85ee3b1940cd5a1c4151ca16fdb738c162480b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-permissions-acl/zipball/9f85ee3b1940cd5a1c4151ca16fdb738c162480b",
- "reference": "9f85ee3b1940cd5a1c4151ca16fdb738c162480b",
- "shasum": ""
- },
- "require": {
- "php": "~8.1.0 || ~8.2.0 || ~8.3.0"
- },
- "conflict": {
- "laminas/laminas-servicemanager": "<3.0",
- "zendframework/zend-permissions-acl": "*"
- },
- "require-dev": {
- "laminas/laminas-coding-standard": "~2.5.0",
- "laminas/laminas-servicemanager": "^3.21",
- "phpbench/phpbench": "^1.2.10",
- "phpunit/phpunit": "^10.1.3",
- "psalm/plugin-phpunit": "^0.18.4",
- "vimeo/psalm": "^5.12"
- },
- "suggest": {
- "laminas/laminas-servicemanager": "To support Laminas\\Permissions\\Acl\\Assertion\\AssertionManager plugin manager usage"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Laminas\\Permissions\\Acl\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "description": "Provides a lightweight and flexible access control list (ACL) implementation for privileges management",
- "homepage": "https://laminas.dev",
- "keywords": [
- "acl",
- "laminas"
- ],
- "support": {
- "chat": "https://laminas.dev/chat",
- "docs": "https://docs.laminas.dev/laminas-permissions-acl/",
- "forum": "https://discourse.laminas.dev",
- "issues": "https://github.com/laminas/laminas-permissions-acl/issues",
- "rss": "https://github.com/laminas/laminas-permissions-acl/releases.atom",
- "source": "https://github.com/laminas/laminas-permissions-acl"
- },
- "funding": [
- {
- "url": "https://funding.communitybridge.org/projects/laminas-project",
- "type": "community_bridge"
- }
- ],
- "time": "2023-10-18T07:50:34+00:00"
- },
{
"name": "laminas/laminas-router",
"version": "3.14.0",
diff --git a/docs/book/v3/migration/v2-to-v3.md b/docs/book/v3/migration/v2-to-v3.md
index c6eae30ec..08db43560 100644
--- a/docs/book/v3/migration/v2-to-v3.md
+++ b/docs/book/v3/migration/v2-to-v3.md
@@ -101,3 +101,12 @@ To encode data to Json for output in a view, you can call [`json_encode`](https:
If you were relying on behaviour that was previously available via `laminas-json`, for example, calling object methods `toArray` or `toJson` prior to encoding, you should make the relevant objects implement `JsonSerializable`.
You can find documentation on the `JsonSerializable` interface [on the PHP website](https://www.php.net/manual/class.jsonserializable.php).
+
+#### Navigation
+
+The deprecated navigation view helpers such as `Breadcrumbs`, and `Menu` etc have been removed and can now be found in [the `laminas-navigation` component](https://docs.laminas.dev/laminas-navigation/helpers/intro/).
+
+As such, the namespace for these helpers has changed from `Laminas\View\Navigation` to `Laminas\Navigation\View\Helper`, so if you have referenced the FQCNs of these helpers in your code, you will need to update them accordingly.
+
+At the time of writing, the `laminas-navigation` 2.x series of releases is not compatible with `laminas-view` 3.x and a major release of the `laminas-navigation` component is not available.
+If you rely on the navigation helpers, you will have to wait for a compatible release of `laminas-navigation` before you can upgrade to `laminas-view` version 3.0.
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index b881e73c4..be9b66623 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -7,11 +7,6 @@
-
-
-
-
-
@@ -447,484 +442,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- minDepth)]]>
-
-
- container]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getTextDomain()]]>
- getTextDomain()]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- last()]]>
-
-
-
-
-
-
-
-
- getTitle()]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- acl === null && static::$defaultAcl !== null]]>
- container]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- renderPartialModel($params, $container, $partial)]]>
- renderPartialModel([], $container, $partial)]]>
-
-
-
-
-
-
-
-
-
-
- getLabel()]]>
- getTextDomain()]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $meth()]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- root]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- renderPartialModel($params, $container, $partial)]]>
- renderPartialModel([], $container, $partial)]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getTextDomain()]]>
- getTextDomain()]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getTitle()]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- serverUrl]]>
-
-
-
-
-
-
-
-
-
-
-
-
- serverUrl]]>
- serverUrl]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- serverUrl)]]>
-
-
-
-
-
-
-
@@ -1882,288 +1399,6 @@
-
-
-
-
- serviceManager->get('Navigation')]]>
-
-
-
-
-
-
-
-
-
-
-
- _helper]]>
-
-
-
-
- getDependencyConfig())]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- errorHandlerMessage = $message;
- }]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- errorHandlerMessage]]>
-
-
- 'unknownresource',
- 'privilege' => 'someprivilege',
- ], false)]]>
-
-
-
-
-
-
-
- [
- 'default' => [],
- ],
- ])]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- nav2;]]>
- addPage(['label' => 'Invalid', 'uri' => 'http://w.']);]]>
- ');]]>
- _helper->render($nav);
- } catch (View\Exception\ExceptionInterface $e) {
- $expected = sprintf(
- 'Encountered an invalid URL for Sitemap XML: "%s"',
- 'http://w.'
- );
- $actual = $e->getMessage();
- static::assertEquals($expected, $actual);
- return;
- }]]>
-
-
diff --git a/psalm.xml.dist b/psalm.xml.dist
index f21b0a73b..74c3ec13c 100644
--- a/psalm.xml.dist
+++ b/psalm.xml.dist
@@ -35,14 +35,6 @@
-
-
-
-
-
-
diff --git a/src/Helper/Navigation.php b/src/Helper/Navigation.php
deleted file mode 100644
index 5331f5986..000000000
--- a/src/Helper/Navigation.php
+++ /dev/null
@@ -1,352 +0,0 @@
-setContainer($container);
- }
-
- return $this;
- }
-
- /**
- * Magic overload: Proxy to other navigation helpers or the container
- *
- * Examples of usage from a view script or layout:
- *
- * // proxy to Menu helper and render container:
- * echo $this->navigation()->menu();
- *
- * // proxy to Breadcrumbs helper and set indentation:
- * $this->navigation()->breadcrumbs()->setIndent(8);
- *
- * // proxy to container and find all pages with 'blog' route:
- * $blogPages = $this->navigation()->findAllByRoute('blog');
- *
- *
- * @param string|class-string $method helper name or method name in container
- * @param array $arguments [optional] arguments to pass
- * @throws Exception\ExceptionInterface If proxying to a helper, and the
- * helper is not an instance of the
- * interface specified in
- * {@link findHelper()}.
- * @throws ExceptionInterface If method does not exist in container.
- * @return mixed returns what the proxied call returns
- */
- public function __call($method, array $arguments = [])
- {
- // check if call should proxy to another helper
- $helper = $this->findHelper($method, false);
- if ($helper) {
- if (method_exists($helper, 'setServiceLocator') && $this->getServiceLocator()) {
- $helper->setServiceLocator($this->getServiceLocator());
- }
- return call_user_func_array($helper, $arguments);
- }
-
- // default behaviour: proxy call to container
- return parent::__call($method, $arguments);
- }
-
- /**
- * Renders helper
- *
- * @param AbstractContainer $container
- * @return string
- * @throws Exception\RuntimeException
- */
- public function render($container = null)
- {
- return $this->findHelper($this->getDefaultProxy())->render($container);
- }
-
- /**
- * Returns the helper matching $proxy
- *
- * The helper must implement the interface {@link NavigationHelper}.
- *
- * @param string|class-string $proxy helper name
- * @param bool $strict [optional] whether exceptions should be
- * thrown if something goes
- * wrong. Default is true.
- * @throws Exception\RuntimeException If $strict is true and helper cannot be found.
- * @return NavigationHelper|false helper instance
- * @psalm-return ($strict is true ? NavigationHelper : NavigationHelper|false)
- */
- public function findHelper($proxy, $strict = true)
- {
- $plugins = $this->getPluginManager();
- if (! $plugins->has($proxy)) {
- if ($strict) {
- throw new Exception\RuntimeException(sprintf(
- 'Failed to find plugin for %s',
- $proxy
- ));
- }
-
- return false;
- }
-
- $helper = $plugins->get($proxy);
- assert($helper instanceof NavigationHelper);
- $container = $this->getContainer();
- $hash = spl_object_hash($container) . spl_object_hash($helper);
-
- if (! isset($this->injected[$hash])) {
- $helper->setContainer();
- $this->inject($helper);
- $this->injected[$hash] = true;
- } else {
- if ($this->getInjectContainer()) {
- $helper->setContainer($container);
- }
- }
-
- return $helper;
- }
-
- /**
- * Injects container, ACL, and translator to the given $helper if this
- * helper is configured to do so
- *
- * @param NavigationHelper $helper helper instance
- * @return void
- */
- protected function inject(NavigationHelper $helper)
- {
- if ($this->getInjectContainer() && ! $helper->hasContainer()) {
- $helper->setContainer($this->getContainer());
- }
-
- if ($this->getInjectAcl()) {
- if (! $helper->hasAcl()) {
- $helper->setAcl($this->getAcl());
- }
- if (! $helper->hasRole()) {
- $helper->setRole($this->getRole());
- }
- }
-
- if ($this->getInjectTranslator() && ! $helper->hasTranslator()) {
- $helper->setTranslator(
- $this->getTranslator(),
- $this->getTranslatorTextDomain()
- );
- }
- }
-
- /**
- * Sets the default proxy to use in {@link render()}
- *
- * @param string $proxy default proxy
- * @return Navigation
- */
- public function setDefaultProxy($proxy)
- {
- $this->defaultProxy = (string) $proxy;
- return $this;
- }
-
- /**
- * Returns the default proxy to use in {@link render()}
- *
- * @return string
- */
- public function getDefaultProxy()
- {
- return $this->defaultProxy;
- }
-
- /**
- * Sets whether container should be injected when proxying
- *
- * @param bool $injectContainer
- * @return Navigation
- */
- public function setInjectContainer($injectContainer = true)
- {
- $this->injectContainer = (bool) $injectContainer;
- return $this;
- }
-
- /**
- * Returns whether container should be injected when proxying
- *
- * @return bool
- */
- public function getInjectContainer()
- {
- return $this->injectContainer;
- }
-
- /**
- * Sets whether ACL should be injected when proxying
- *
- * @param bool $injectAcl
- * @return Navigation
- */
- public function setInjectAcl($injectAcl = true)
- {
- $this->injectAcl = (bool) $injectAcl;
- return $this;
- }
-
- /**
- * Returns whether ACL should be injected when proxying
- *
- * @return bool
- */
- public function getInjectAcl()
- {
- return $this->injectAcl;
- }
-
- /**
- * Sets whether translator should be injected when proxying
- *
- * @param bool $injectTranslator
- * @return Navigation
- */
- public function setInjectTranslator($injectTranslator = true)
- {
- $this->injectTranslator = (bool) $injectTranslator;
- return $this;
- }
-
- /**
- * Returns whether translator should be injected when proxying
- *
- * @return bool
- */
- public function getInjectTranslator()
- {
- return $this->injectTranslator;
- }
-
- /**
- * Set manager for retrieving navigation helpers
- *
- * @return Navigation
- */
- public function setPluginManager(Navigation\PluginManager $plugins)
- {
- $renderer = $this->getView();
- if ($renderer) {
- $plugins->setRenderer($renderer);
- }
- $this->plugins = $plugins;
-
- return $this;
- }
-
- /**
- * Retrieve plugin loader for navigation helpers
- *
- * Lazy-loads an instance of Navigation\HelperLoader if none currently
- * registered.
- *
- * @return Navigation\PluginManager
- */
- public function getPluginManager()
- {
- $pluginManager = $this->plugins;
- if ($pluginManager === null) {
- $pluginManager = new Navigation\PluginManager($this->getServiceLocator());
- $this->setPluginManager($pluginManager);
- }
-
- return $pluginManager;
- }
-
- /**
- * Set the View object
- *
- * @return self
- */
- public function setView(Renderer $view)
- {
- parent::setView($view);
- if ($view && $this->plugins) {
- $this->plugins->setRenderer($view);
- }
- return $this;
- }
-}
diff --git a/src/Helper/Navigation/AbstractHelper.php b/src/Helper/Navigation/AbstractHelper.php
deleted file mode 100644
index 68451c8c3..000000000
--- a/src/Helper/Navigation/AbstractHelper.php
+++ /dev/null
@@ -1,901 +0,0 @@
-getContainer(), $method],
- $arguments
- );
- }
-
- /**
- * Magic overload: Proxy to {@link render()}.
- *
- * This method will trigger an E_USER_ERROR if rendering the helper causes
- * an exception to be thrown.
- *
- * Implements {@link HelperInterface::__toString()}.
- *
- * @return string
- */
- public function __toString()
- {
- try {
- return $this->render();
- } catch (\Exception $e) {
- $msg = $e::class . ': ' . $e->getMessage();
- trigger_error($msg, E_USER_ERROR);
- return '';
- }
- }
-
- /**
- * Finds the deepest active page in the given container
- *
- * @param AbstractContainer $container container to search
- * @param int|null $minDepth [optional] minimum depth
- * required for page to be
- * valid. Default is to use
- * {@link getMinDepth()}. A
- * null value means no minimum
- * depth required.
- * @param int|null $maxDepth [optional] maximum depth
- * a page can have to be
- * valid. Default is to use
- * {@link getMaxDepth()}. A
- * null value means no maximum
- * depth required.
- * @return array an associative array with
- * the values 'depth' and
- * 'page', or an empty array
- * if not found
- */
- public function findActive($container, $minDepth = null, $maxDepth = -1)
- {
- $this->parseContainer($container);
- if (! is_int($minDepth)) {
- $minDepth = $this->getMinDepth();
- }
- if ((! is_int($maxDepth) || $maxDepth < 0) && null !== $maxDepth) {
- $maxDepth = $this->getMaxDepth();
- }
-
- $found = null;
- $foundDepth = -1;
- $iterator = new RecursiveIteratorIterator(
- $container,
- RecursiveIteratorIterator::CHILD_FIRST
- );
-
- /** @var Navigation\Page\AbstractPage $page */
- foreach ($iterator as $page) {
- $currDepth = $iterator->getDepth();
- if ($currDepth < $minDepth || ! $this->accept($page)) {
- // page is not accepted
- continue;
- }
-
- if ($page->isActive(false) && $currDepth > $foundDepth) {
- // found an active page at a deeper level than before
- $found = $page;
- $foundDepth = $currDepth;
- }
- }
-
- if (is_int($maxDepth) && $foundDepth > $maxDepth) {
- while ($foundDepth > $maxDepth) {
- if (--$foundDepth < $minDepth) {
- $found = null;
- break;
- }
-
- $found = $found->getParent();
- if (! $found instanceof AbstractPage) {
- $found = null;
- break;
- }
- }
- }
-
- if ($found) {
- return ['page' => $found, 'depth' => $foundDepth];
- }
-
- return [];
- }
-
- /**
- * Verifies container and eventually fetches it from service locator if it is a string
- *
- * @param AbstractContainer|string|null $container
- * @return void
- * @param-out AbstractContainer $container
- * @throws Exception\InvalidArgumentException
- */
- protected function parseContainer(&$container = null)
- {
- if (null === $container) {
- return;
- }
-
- if (is_string($container)) {
- $services = $this->getServiceLocator();
- if (! $services) {
- throw new Exception\InvalidArgumentException(sprintf(
- 'Attempted to set container with alias "%s" but no ServiceLocator was set',
- $container
- ));
- }
-
- // Fallback
- if (in_array($container, ['default', 'navigation'], true)) {
- // Uses class name
- if ($services->has(Navigation\Navigation::class)) {
- $container = $services->get(Navigation\Navigation::class);
- return;
- }
-
- // Uses old service name
- if ($services->has('navigation')) {
- $container = $services->get('navigation');
- return;
- }
- }
-
- /**
- * Load the navigation container from the root service locator
- */
- $container = $services->get($container);
- return;
- }
-
- if (! $container instanceof AbstractContainer) {
- throw new Exception\InvalidArgumentException(
- 'Container must be a string alias or an instance of '
- . AbstractContainer::class
- );
- }
- }
-
- // Iterator filter methods:
-
- /**
- * Determines whether a page should be accepted when iterating
- *
- * Default listener may be 'overridden' by attaching listener to 'isAllowed'
- * method. Listener must be 'short circuited' if overriding default ACL
- * listener.
- *
- * Rules:
- * - If a page is not visible it is not accepted, unless RenderInvisible has
- * been set to true
- * - If $useAcl is true (default is true):
- * - Page is accepted if listener returns true, otherwise false
- * - If page is accepted and $recursive is true, the page
- * will not be accepted if it is the descendant of a non-accepted page
- *
- * @param AbstractPage $page page to check
- * @param bool $recursive [optional] if true, page will not be
- * accepted if it is the descendant of
- * a page that is not accepted. Default
- * is true
- * @return bool Whether page should be accepted
- */
- public function accept(AbstractPage $page, $recursive = true)
- {
- $accept = true;
-
- if (! $page->isVisible(false) && ! $this->getRenderInvisible()) {
- $accept = false;
- } elseif ($this->getUseAcl()) {
- $acl = $this->getAcl();
- $role = $this->getRole();
- $params = ['acl' => $acl, 'page' => $page, 'role' => $role];
- $accept = $this->isAllowed($params);
- }
-
- if ($accept && $recursive) {
- $parent = $page->getParent();
-
- if ($parent instanceof AbstractPage) {
- $accept = $this->accept($parent, true);
- }
- }
-
- return $accept;
- }
-
- /**
- * Determines whether a page should be allowed given certain parameters
- *
- * @param array $params
- * @return bool
- */
- protected function isAllowed($params)
- {
- $events = $this->getEventManager() ?: $this->createEventManager();
- $results = $events->trigger(__FUNCTION__, $this, $params);
- return $results->last();
- }
-
- // Util methods:
-
- /**
- * Retrieve whitespace representation of $indent
- *
- * @param int|string $indent
- * @return string
- */
- protected function getWhitespace($indent)
- {
- if (is_int($indent)) {
- $indent = str_repeat(' ', $indent);
- }
-
- return (string) $indent;
- }
-
- /**
- * Converts an associative array to a string of tag attributes.
- *
- * Overloads {@link View\Helper\AbstractHtmlElement::htmlAttribs()}.
- *
- * @param array $attribs an array where each key-value pair is converted
- * to an attribute name and value
- * @return string
- */
- protected function htmlAttribs($attribs)
- {
- // filter out null values and empty string values
- foreach ($attribs as $key => $value) {
- if ($value === null || (is_string($value) && ! strlen($value))) {
- unset($attribs[$key]);
- }
- }
-
- return parent::htmlAttribs($attribs);
- }
-
- /**
- * Returns an HTML string containing an 'a' element for the given page
- *
- * @param AbstractPage $page page to generate HTML for
- * @return string HTML string (Label )
- */
- public function htmlify(AbstractPage $page)
- {
- $label = $this->translate($page->getLabel(), $page->getTextDomain());
- $title = $this->translate($page->getTitle(), $page->getTextDomain());
-
- // get attribs for anchor element
- $attribs = [
- 'id' => $page->getId(),
- 'title' => $title,
- 'class' => $page->getClass(),
- 'href' => $page->getHref(),
- 'target' => $page->getTarget(),
- ];
-
- if ($page->isActive()) {
- $attribs['aria-current'] = 'page';
- }
-
- /** @var View\Helper\EscapeHtml $escaper */
- $escaper = $this->view->plugin('escapeHtml');
- $label = $escaper($label);
-
- return 'htmlAttribs($attribs) . '>' . $label . ' ';
- }
-
- /**
- * Translate a message (for label, title, …)
- *
- * @param string $message ID of the message to translate
- * @param string $textDomain Text domain (category name for the translations)
- * @return string Translated message
- */
- protected function translate($message, $textDomain = null)
- {
- if (! is_string($message) || empty($message)) {
- return $message;
- }
-
- if (! $this->isTranslatorEnabled() || ! $this->hasTranslator()) {
- return $message;
- }
-
- $translator = $this->getTranslator();
- assert($translator instanceof TranslatorInterface);
- $textDomain = $textDomain ?: $this->getTranslatorTextDomain();
-
- return $translator->translate($message, $textDomain);
- }
-
- /**
- * Normalize an ID
- *
- * Overrides {@link View\Helper\AbstractHtmlElement::normalizeId()}.
- *
- * @param string $value
- * @return string
- */
- protected function normalizeId($value)
- {
- $prefix = static::class;
- $prefix = strtolower(trim(substr($prefix, strrpos($prefix, '\\')), '\\'));
-
- return $prefix . '-' . $value;
- }
-
- /**
- * Sets ACL to use when iterating pages
- *
- * Implements {@link HelperInterface::setAcl()}.
- *
- * @param AclInterface $acl ACL object.
- * @return AbstractHelper
- */
- public function setAcl(?AclInterface $acl = null)
- {
- $this->acl = $acl;
- return $this;
- }
-
- /**
- * Returns ACL or null if it isn't set using {@link setAcl()} or
- * {@link setDefaultAcl()}
- *
- * Implements {@link HelperInterface::getAcl()}.
- *
- * @return AclInterface|null ACL object or null
- */
- public function getAcl()
- {
- if ($this->acl === null && static::$defaultAcl !== null) {
- return static::$defaultAcl;
- }
-
- return $this->acl;
- }
-
- /**
- * Checks if the helper has an ACL instance
- *
- * Implements {@link HelperInterface::hasAcl()}.
- *
- * @return bool
- */
- public function hasAcl()
- {
- if (
- $this->acl instanceof Acl\Acl
- || static::$defaultAcl instanceof Acl\Acl
- ) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Set the event manager.
- *
- * @return AbstractHelper
- */
- public function setEventManager(EventManagerInterface $events)
- {
- $events->setIdentifiers([
- self::class,
- static::class,
- ]);
-
- $this->events = $events;
-
- if ($events->getSharedManager()) {
- $this->setDefaultListeners();
- }
-
- return $this;
- }
-
- /**
- * Get the event manager, if present.
- *
- * Internally, the helper will lazy-load an EM instance the first time it
- * requires one, but ideally it should be injected during instantiation.
- *
- * @return null|EventManagerInterface
- */
- public function getEventManager()
- {
- return $this->events;
- }
-
- /**
- * Sets navigation container the helper operates on by default
- * Implements {@link HelperInterface::setContainer()}.
- *
- * @param string|AbstractContainer $container Default is null, meaning container will be reset.
- * @return AbstractHelper
- */
- public function setContainer($container = null)
- {
- $this->parseContainer($container);
- $this->container = $container;
-
- return $this;
- }
-
- /**
- * Returns the navigation container helper operates on by default
- * Implements {@link HelperInterface::getContainer()}.
- * If no container is set, a new container will be instantiated and
- * stored in the helper.
- *
- * @return AbstractContainer navigation container
- */
- public function getContainer()
- {
- if (null === $this->container) {
- $this->container = new Navigation\Navigation();
- }
-
- return $this->container;
- }
-
- /**
- * Checks if the helper has a container
- *
- * Implements {@link HelperInterface::hasContainer()}.
- *
- * @return bool
- */
- public function hasContainer()
- {
- return null !== $this->container;
- }
-
- /**
- * Set the indentation string for using in {@link render()}, optionally a
- * number of spaces to indent with
- *
- * @param string|int $indent
- * @return AbstractHelper
- */
- public function setIndent($indent)
- {
- $this->indent = $this->getWhitespace($indent);
- return $this;
- }
-
- /**
- * Returns indentation
- *
- * @return string
- */
- public function getIndent()
- {
- return $this->indent;
- }
-
- /**
- * Sets the maximum depth a page can have to be included when rendering
- *
- * @param int|null|numeric-string $maxDepth Default is null, which sets no maximum depth.
- * @return AbstractHelper
- */
- public function setMaxDepth($maxDepth = null)
- {
- if (null === $maxDepth || is_int($maxDepth)) {
- $this->maxDepth = $maxDepth;
- } else {
- $this->maxDepth = (int) $maxDepth;
- }
-
- return $this;
- }
-
- /**
- * Returns maximum depth a page can have to be included when rendering
- *
- * @return int|null
- */
- public function getMaxDepth()
- {
- return $this->maxDepth;
- }
-
- /**
- * Sets the minimum depth a page must have to be included when rendering
- *
- * @param int|null|numeric-string $minDepth Default is null, which sets no minimum depth.
- * @return AbstractHelper
- */
- public function setMinDepth($minDepth = null)
- {
- if (null === $minDepth || is_int($minDepth)) {
- $this->minDepth = $minDepth;
- } else {
- $this->minDepth = (int) $minDepth;
- }
-
- return $this;
- }
-
- /**
- * Returns minimum depth a page must have to be included when rendering
- *
- * @return int|null
- */
- public function getMinDepth()
- {
- if (! is_int($this->minDepth) || $this->minDepth < 0) {
- return 0;
- }
-
- return $this->minDepth;
- }
-
- /**
- * Render invisible items?
- *
- * @param bool $renderInvisible
- * @return AbstractHelper
- */
- public function setRenderInvisible($renderInvisible = true)
- {
- $this->renderInvisible = (bool) $renderInvisible;
- return $this;
- }
-
- /**
- * Return renderInvisible flag
- *
- * @return bool
- */
- public function getRenderInvisible()
- {
- return $this->renderInvisible;
- }
-
- /**
- * Sets ACL role(s) to use when iterating pages
- *
- * Implements {@link HelperInterface::setRole()}.
- *
- * @param mixed $role [optional] role to set. Expects a string, an
- * instance of type {@link Acl\Role\RoleInterface}, or null. Default
- * is null, which will set no role.
- * @return AbstractHelper
- * @throws Exception\InvalidArgumentException
- */
- public function setRole($role = null)
- {
- if (
- null === $role || is_string($role) ||
- $role instanceof Acl\Role\RoleInterface
- ) {
- $this->role = $role;
- } else {
- throw new Exception\InvalidArgumentException(sprintf(
- '$role must be a string, null, or an instance of '
- . 'Laminas\Permissions\Role\RoleInterface; %s given',
- is_object($role) ? $role::class : gettype($role)
- ));
- }
-
- return $this;
- }
-
- /**
- * Returns ACL role to use when iterating pages, or null if it isn't set
- * using {@link setRole()} or {@link setDefaultRole()}
- *
- * Implements {@link HelperInterface::getRole()}.
- *
- * @return string|Acl\Role\RoleInterface|null
- */
- public function getRole()
- {
- if ($this->role === null && static::$defaultRole !== null) {
- return static::$defaultRole;
- }
-
- return $this->role;
- }
-
- /**
- * Checks if the helper has an ACL role
- *
- * Implements {@link HelperInterface::hasRole()}.
- *
- * @return bool
- */
- public function hasRole()
- {
- if (
- $this->role instanceof Acl\Role\RoleInterface
- || is_string($this->role)
- || static::$defaultRole instanceof Acl\Role\RoleInterface
- || is_string(static::$defaultRole)
- ) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Set the service locator.
- *
- * Used internally to pull named navigation containers to render.
- *
- * @return AbstractHelper
- */
- public function setServiceLocator(ContainerInterface $serviceLocator)
- {
- $this->serviceLocator = $serviceLocator;
- return $this;
- }
-
- /**
- * Get the service locator.
- *
- * Used internally to pull named navigation containers to render.
- *
- * @return ContainerInterface|null
- */
- public function getServiceLocator()
- {
- return $this->serviceLocator;
- }
-
- /**
- * Sets whether ACL should be used
- *
- * Implements {@link HelperInterface::setUseAcl()}.
- *
- * @param bool $useAcl
- * @return AbstractHelper
- */
- public function setUseAcl($useAcl = true)
- {
- $this->useAcl = (bool) $useAcl;
- return $this;
- }
-
- /**
- * Returns whether ACL should be used
- *
- * Implements {@link HelperInterface::getUseAcl()}.
- *
- * @return bool
- */
- public function getUseAcl()
- {
- return $this->useAcl;
- }
-
- // Static methods:
-
- /**
- * Sets default ACL to use if another ACL is not explicitly set
- *
- * @param AclInterface $acl [optional] ACL object. Default is null, which
- * sets no ACL object.
- * @return void
- */
- public static function setDefaultAcl(?AclInterface $acl = null)
- {
- static::$defaultAcl = $acl;
- }
-
- /**
- * Sets default ACL role(s) to use when iterating pages if not explicitly
- * set later with {@link setRole()}
- *
- * @param mixed $role [optional] role to set. Expects null, string, or an
- * instance of {@link Acl\Role\RoleInterface}. Default is null, which
- * sets no default role.
- * @return void
- * @throws Exception\InvalidArgumentException If role is invalid.
- */
- public static function setDefaultRole($role = null)
- {
- if (
- null === $role
- || is_string($role)
- || $role instanceof Acl\Role\RoleInterface
- ) {
- static::$defaultRole = $role;
- } else {
- throw new Exception\InvalidArgumentException(sprintf(
- '$role must be null|string|Laminas\Permissions\Role\RoleInterface; received "%s"',
- is_object($role) ? $role::class : gettype($role)
- ));
- }
- }
-
- /**
- * Attaches default ACL listeners, if ACLs are in use
- *
- * @return void
- */
- protected function setDefaultListeners()
- {
- if (! $this->getUseAcl()) {
- return;
- }
-
- $events = $this->getEventManager() ?: $this->createEventManager();
-
- if (! $events->getSharedManager()) {
- return;
- }
-
- $events->getSharedManager()->attach(
- self::class,
- 'isAllowed',
- [AclListener::class, 'accept']
- );
- }
-
- /**
- * Create and return an event manager instance.
- *
- * Ensures that the returned event manager has a shared manager
- * composed.
- *
- * @return EventManager
- */
- private function createEventManager()
- {
- $r = new ReflectionClass(EventManager::class);
- if ($r->hasMethod('setSharedManager')) {
- $events = new EventManager();
- $events->setSharedManager(new SharedEventManager());
- } else {
- $events = new EventManager(new SharedEventManager());
- }
-
- $this->setEventManager($events);
- return $events;
- }
-}
diff --git a/src/Helper/Navigation/Breadcrumbs.php b/src/Helper/Navigation/Breadcrumbs.php
deleted file mode 100644
index f2a2960e4..000000000
--- a/src/Helper/Navigation/Breadcrumbs.php
+++ /dev/null
@@ -1,318 +0,0 @@
-setContainer($container);
- }
-
- return $this;
- }
-
- /**
- * Renders helper.
- *
- * Implements {@link HelperInterface::render()}.
- *
- * @param AbstractContainer $container [optional] container to render. Default is
- * to render the container registered in the helper.
- * @return string
- */
- public function render($container = null)
- {
- $partial = $this->getPartial();
- if ($partial) {
- return $this->renderPartial($container, $partial);
- }
-
- return $this->renderStraight($container);
- }
-
- /**
- * Renders breadcrumbs by chaining 'a' elements with the separator
- * registered in the helper.
- *
- * @param AbstractContainer $container [optional] container to render. Default is
- * to render the container registered in the helper.
- * @return string
- */
- public function renderStraight($container = null)
- {
- $this->parseContainer($container);
- if (null === $container) {
- $container = $this->getContainer();
- }
-
- // find deepest active
- if (! $active = $this->findActive($container)) {
- return '';
- }
-
- $active = $active['page'];
-
- // put the deepest active page last in breadcrumbs
- if ($this->getLinkLast()) {
- $html = $this->htmlify($active);
- } else {
- /** @var View\Helper\EscapeHtml $escaper */
- $escaper = $this->view->plugin('escapeHtml');
- $label = $escaper(
- $this->translate($active->getLabel(), $active->getTextDomain())
- );
- $attribs = [
- 'aria-current' => 'page',
- ];
- $html = 'htmlAttribs($attribs) . '>' . $label . ' ';
- }
-
- // walk back to root
- while ($parent = $active->getParent()) {
- if ($parent instanceof AbstractPage) {
- // prepend crumb to html
- $html = $this->htmlify($parent)
- . $this->getSeparator()
- . $html;
- }
-
- if ($parent === $container) {
- // at the root of the given container
- break;
- }
-
- $active = $parent;
- }
-
- return strlen($html) ? $this->getIndent() . $html : '';
- }
-
- /**
- * Renders the given $container by invoking the partial view helper.
- *
- * The container will simply be passed on as a model to the view script
- * as-is, and will be available in the partial script as 'container', e.g.
- * echo 'Number of pages: ', count($this->container);
.
- *
- * @param null|AbstractContainer $container [optional] container to pass to view
- * script. Default is to use the container registered in the helper.
- * @param null|string|array $partial [optional] partial view script to use.
- * Default is to use the partial registered in the helper. If an array
- * is given, the first value is used for the partial view script.
- * @return string
- * @throws Exception\RuntimeException If no partial provided.
- * @throws Exception\InvalidArgumentException If partial is invalid array.
- */
- public function renderPartial($container = null, $partial = null)
- {
- return $this->renderPartialModel([], $container, $partial);
- }
-
- /**
- * Renders the given $container by invoking the partial view helper with the given parameters as the model.
- *
- * The container will simply be passed on as a model to the view script
- * as-is, and will be available in the partial script as 'container', e.g.
- * echo 'Number of pages: ', count($this->container);
.
- *
- * Any parameters provided will be passed to the partial via the view model.
- *
- * @param null|AbstractContainer $container [optional] container to pass to view
- * script. Default is to use the container registered in the helper.
- * @param null|string|array $partial [optional] partial view script to use.
- * Default is to use the partial registered in the helper. If an array
- * is given, the first value is used for the partial view script.
- * @return string
- * @throws Exception\RuntimeException If no partial provided.
- * @throws Exception\InvalidArgumentException If partial is invalid array.
- */
- public function renderPartialWithParams(array $params = [], $container = null, $partial = null)
- {
- return $this->renderPartialModel($params, $container, $partial);
- }
-
- /**
- * Sets whether last page in breadcrumbs should be hyperlinked.
- *
- * @param bool $linkLast whether last page should be hyperlinked
- * @return Breadcrumbs
- */
- public function setLinkLast($linkLast)
- {
- $this->linkLast = (bool) $linkLast;
- return $this;
- }
-
- /**
- * Returns whether last page in breadcrumbs should be hyperlinked.
- *
- * @return bool
- */
- public function getLinkLast()
- {
- return $this->linkLast;
- }
-
- /**
- * Sets which partial view script to use for rendering menu.
- *
- * @param string|array $partial partial view script or null. If an array is
- * given, the first value is used for the partial view script.
- * @return Breadcrumbs
- */
- public function setPartial($partial)
- {
- if (null === $partial || is_string($partial) || is_array($partial)) {
- $this->partial = $partial;
- }
- return $this;
- }
-
- /**
- * Returns partial view script to use for rendering menu.
- *
- * @return string|array|null
- */
- public function getPartial()
- {
- return $this->partial;
- }
-
- /**
- * Sets breadcrumb separator.
- *
- * @param string $separator separator string
- * @return Breadcrumbs
- */
- public function setSeparator($separator)
- {
- if (is_string($separator)) {
- $this->separator = $separator;
- }
-
- return $this;
- }
-
- /**
- * Returns breadcrumb separator.
- *
- * @return string breadcrumb separator
- */
- public function getSeparator()
- {
- return $this->separator;
- }
-
- /**
- * Render a partial with the given "model".
- *
- * @param array $params
- * @param null|AbstractContainer $container
- * @param null|string|array $partial
- * @return View\Helper\Partial|string
- * @throws Exception\RuntimeException If no partial provided.
- * @throws Exception\InvalidArgumentException If partial is invalid array.
- */
- protected function renderPartialModel(array $params, $container, $partial)
- {
- $this->parseContainer($container);
- if (null === $container) {
- $container = $this->getContainer();
- }
- if (null === $partial) {
- $partial = $this->getPartial();
- }
- if (empty($partial)) {
- throw new Exception\RuntimeException(
- 'Unable to render breadcrumbs: No partial view script provided'
- );
- }
- $model = array_merge($params, ['pages' => []], ['separator' => $this->getSeparator()]);
- $active = $this->findActive($container);
- if ($active) {
- $active = $active['page'];
- $model['pages'][] = $active;
- while ($parent = $active->getParent()) {
- if (! $parent instanceof AbstractPage) {
- break;
- }
-
- $model['pages'][] = $parent;
- if ($parent === $container) {
- // break if at the root of the given container
- break;
- }
- $active = $parent;
- }
- $model['pages'] = array_reverse($model['pages']);
- }
-
- /** @var View\Helper\Partial $partialHelper */
- $partialHelper = $this->view->plugin('partial');
- if (is_array($partial)) {
- if (count($partial) !== 2) {
- throw new Exception\InvalidArgumentException(
- 'Unable to render breadcrumbs: A view partial supplied as '
- . 'an array must contain one value: the partial view script'
- );
- }
-
- return $partialHelper($partial[0], $model);
- }
-
- return $partialHelper($partial, $model);
- }
-}
diff --git a/src/Helper/Navigation/HelperInterface.php b/src/Helper/Navigation/HelperInterface.php
deleted file mode 100644
index 4abdd4317..000000000
--- a/src/Helper/Navigation/HelperInterface.php
+++ /dev/null
@@ -1,139 +0,0 @@
- elements
- */
-class Links extends AbstractHelper
-{
- /**
- * Constants used for specifying which link types to find and render
- *
- * @var int
- */
- public const RENDER_ALTERNATE = 0x0001;
- public const RENDER_STYLESHEET = 0x0002;
- public const RENDER_START = 0x0004;
- public const RENDER_NEXT = 0x0008;
- public const RENDER_PREV = 0x0010;
- public const RENDER_CONTENTS = 0x0020;
- public const RENDER_INDEX = 0x0040;
- public const RENDER_GLOSSARY = 0x0080;
- public const RENDER_COPYRIGHT = 0x0100;
- public const RENDER_CHAPTER = 0x0200;
- public const RENDER_SECTION = 0x0400;
- public const RENDER_SUBSECTION = 0x0800;
- public const RENDER_APPENDIX = 0x1000;
- public const RENDER_HELP = 0x2000;
- public const RENDER_BOOKMARK = 0x4000;
- public const RENDER_CUSTOM = 0x8000;
- public const RENDER_ALL = 0xffff;
-
- /**
- * Maps render constants to W3C link types
- *
- * @var array
- */
- protected static $RELATIONS = [ // phpcs:ignore
- self::RENDER_ALTERNATE => 'alternate',
- self::RENDER_STYLESHEET => 'stylesheet',
- self::RENDER_START => 'start',
- self::RENDER_NEXT => 'next',
- self::RENDER_PREV => 'prev',
- self::RENDER_CONTENTS => 'contents',
- self::RENDER_INDEX => 'index',
- self::RENDER_GLOSSARY => 'glossary',
- self::RENDER_COPYRIGHT => 'copyright',
- self::RENDER_CHAPTER => 'chapter',
- self::RENDER_SECTION => 'section',
- self::RENDER_SUBSECTION => 'subsection',
- self::RENDER_APPENDIX => 'appendix',
- self::RENDER_HELP => 'help',
- self::RENDER_BOOKMARK => 'bookmark',
- ];
-
- /**
- * The helper's render flag
- *
- * @see render()
- * @see setRenderFlag()
- *
- * @var int
- */
- protected $renderFlag = self::RENDER_ALL;
-
- /**
- * Root container
- *
- * Used for preventing methods to traverse above the container given to
- * the {@link render()} method.
- *
- * @see _findRoot()
- *
- * @var AbstractContainer
- */
- protected $root;
-
- /**
- * Helper entry point
- *
- * @param string|AbstractContainer $container container to operate on
- * @return Links
- */
- public function __invoke($container = null)
- {
- if (null !== $container) {
- $this->setContainer($container);
- }
-
- return $this;
- }
-
- /**
- * Magic overload: Proxy calls to {@link findRelation()} or container
- *
- * Examples of finder calls:
- *
- * // METHOD // SAME AS
- * $h->findRelNext($page); // $h->findRelation($page, 'rel', 'next')
- * $h->findRevSection($page); // $h->findRelation($page, 'rev', 'section');
- * $h->findRelFoo($page); // $h->findRelation($page, 'rel', 'foo');
- *
- *
- * @param string $method
- * @param array $arguments
- * @return mixed
- * @throws Exception\ExceptionInterface
- */
- public function __call($method, array $arguments = [])
- {
- ErrorHandler::start(E_WARNING);
- $result = preg_match('/find(Rel|Rev)(.+)/', $method, $match);
- ErrorHandler::stop();
- if ($result) {
- return $this->findRelation($arguments[0], strtolower($match[1]), strtolower($match[2]));
- }
-
- return parent::__call($method, $arguments);
- }
-
- /**
- * Renders helper
- *
- * Implements {@link HelperInterface::render()}.
- *
- * @param AbstractContainer|string|null $container [optional] container to render.
- * Default is to render the
- * container registered in the
- * helper.
- * @return string
- */
- public function render($container = null)
- {
- $this->parseContainer($container);
- if (null === $container) {
- $container = $this->getContainer();
- }
-
- $active = $this->findActive($container);
- if ($active) {
- $active = $active['page'];
- } else {
- // no active page
- return '';
- }
-
- $output = '';
- $indent = $this->getIndent();
- $this->root = $container;
-
- $result = $this->findAllRelations($active, $this->getRenderFlag());
- foreach ($result as $attrib => $types) {
- foreach ($types as $relation => $pages) {
- foreach ($pages as $page) {
- $r = $this->renderLink($page, $attrib, $relation);
- if ($r) {
- $output .= $indent . $r . PHP_EOL;
- }
- }
- }
- }
-
- $this->root = null;
-
- // return output (trim last newline by spec)
- return strlen($output) ? rtrim($output, PHP_EOL) : '';
- }
-
- /**
- * Renders the given $page as a link element, with $attrib = $relation
- *
- * @param AbstractPage $page the page to render the link for
- * @param string $attrib the attribute to use for $type,
- * either 'rel' or 'rev'
- * @param string $relation relation type, muse be one of;
- * alternate, appendix, bookmark,
- * chapter, contents, copyright,
- * glossary, help, home, index, next,
- * prev, section, start, stylesheet,
- * subsection
- * @return string
- * @throws Exception\DomainException
- */
- public function renderLink(AbstractPage $page, $attrib, $relation)
- {
- if (! in_array($attrib, ['rel', 'rev'])) {
- throw new Exception\DomainException(sprintf(
- 'Invalid relation attribute "%s", must be "rel" or "rev"',
- $attrib
- ));
- }
-
- if (! $href = $page->getHref()) {
- return '';
- }
-
- // TODO: add more attribs
- // http://www.w3.org/TR/html401/struct/links.html#h-12.2
- $attribs = [
- $attrib => $relation,
- 'href' => $href,
- 'title' => $page->getLabel(),
- ];
-
- return ' htmlAttribs($attribs)
- . $this->getClosingBracket();
- }
-
- // Finder methods:
-
- /**
- * Finds all relations (forward and reverse) for the given $page
- *
- * The form of the returned array:
- *
- *
- * // $page denotes an instance of Laminas\Navigation\Page\AbstractPage
- * $returned = array(
- * 'rel' => array(
- * 'alternate' => array($page, $page, $page),
- * 'start' => array($page),
- * 'next' => array($page),
- * 'prev' => array($page),
- * 'canonical' => array($page)
- * ),
- * 'rev' => array(
- * 'section' => array($page)
- * )
- * );
- *
- *
- * @param AbstractPage $page page to find links for
- * @param int|null $flag
- * @return array[][]
- * @psalm-return array{rel: array, rev: array}
- */
- public function findAllRelations(AbstractPage $page, $flag = null)
- {
- if (! is_int($flag)) {
- $flag = self::RENDER_ALL;
- }
-
- $result = ['rel' => [], 'rev' => []];
- $native = array_values(static::$RELATIONS);
-
- foreach (array_keys($result) as $rel) {
- $meth = 'getDefined' . ucfirst($rel);
- $types = array_merge($native, array_diff($page->$meth(), $native));
-
- foreach ($types as $type) {
- if (! $relFlag = array_search($type, static::$RELATIONS)) {
- $relFlag = self::RENDER_CUSTOM;
- }
- if (! ($flag & $relFlag)) {
- continue;
- }
-
- $found = $this->findRelation($page, $rel, $type);
- if ($found) {
- if (! is_array($found)) {
- $found = [$found];
- }
- $result[$rel][$type] = $found;
- }
- }
- }
-
- return $result;
- }
-
- /**
- * Finds relations of the given $rel=$type from $page
- *
- * This method will first look for relations in the page instance, then
- * by searching the root container if nothing was found in the page.
- *
- * @param AbstractPage $page page to find relations for
- * @param string $rel relation, "rel" or "rev"
- * @param string $type link type, e.g. 'start', 'next'
- * @return AbstractPage|array|null
- * @throws Exception\DomainException If $rel is not "rel" or "rev".
- */
- public function findRelation(AbstractPage $page, $rel, $type)
- {
- if (! in_array($rel, ['rel', 'rev'])) {
- throw new Exception\DomainException(sprintf(
- 'Invalid argument: $rel must be "rel" or "rev"; "%s" given',
- $rel
- ));
- }
-
- if (! $result = $this->findFromProperty($page, $rel, $type)) {
- $result = $this->findFromSearch($page, $rel, $type);
- }
-
- return $result;
- }
-
- /**
- * Finds relations of given $type for $page by checking if the
- * relation is specified as a property of $page
- *
- * @param AbstractPage $page page to find relations for
- * @param string $rel relation, 'rel' or 'rev'
- * @param string $type link type, e.g. 'start', 'next'
- * @return AbstractPage|array|null
- */
- protected function findFromProperty(AbstractPage $page, $rel, $type)
- {
- $method = 'get' . ucfirst($rel);
- $result = $page->$method($type);
- if ($result) {
- $result = $this->convertToPages($result);
- if ($result) {
- if (! is_array($result)) {
- $result = [$result];
- }
-
- foreach ($result as $key => $page) {
- if (! $this->accept($page)) {
- unset($result[$key]);
- }
- }
-
- return count($result) === 1 ? $result[0] : $result;
- }
- }
- }
-
- /**
- * Finds relations of given $rel=$type for $page by using the helper to
- * search for the relation in the root container
- *
- * @param AbstractPage $page page to find relations for
- * @param string $rel relation, 'rel' or 'rev'
- * @param string $type link type, e.g. 'start', 'next', etc
- * @return array|null
- */
- protected function findFromSearch(AbstractPage $page, $rel, $type)
- {
- $found = null;
-
- $method = 'search' . ucfirst($rel) . ucfirst($type);
- if (method_exists($this, $method)) {
- $found = $this->$method($page);
- }
-
- return $found;
- }
-
- // Search methods:
-
- /**
- * Searches the root container for the forward 'start' relation of the given
- * $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to the first document in a collection of documents. This link type
- * tells search engines which document is considered by the author to be the
- * starting point of the collection.
- *
- * @return AbstractPage|null
- */
- public function searchRelStart(AbstractPage $page)
- {
- $found = $this->findRoot($page);
- if (! $found instanceof AbstractPage) {
- $found->rewind();
- $found = $found->current();
- }
-
- if ($found === $page || ! $this->accept($found)) {
- $found = null;
- }
-
- return $found;
- }
-
- /**
- * Searches the root container for the forward 'next' relation of the given
- * $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to the next document in a linear sequence of documents. User
- * agents may choose to preload the "next" document, to reduce the perceived
- * load time.
- *
- * @return AbstractPage|null
- */
- public function searchRelNext(AbstractPage $page)
- {
- $found = null;
- $break = false;
- $iterator = new RecursiveIteratorIterator($this->findRoot($page), RecursiveIteratorIterator::SELF_FIRST);
- foreach ($iterator as $intermediate) {
- if ($intermediate === $page) {
- // current page; break at next accepted page
- $break = true;
- continue;
- }
-
- if ($break && $this->accept($intermediate)) {
- $found = $intermediate;
- break;
- }
- }
-
- return $found;
- }
-
- /**
- * Searches the root container for the forward 'prev' relation of the given
- * $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to the previous document in an ordered series of documents. Some
- * user agents also support the synonym "Previous".
- *
- * @return AbstractPage|null
- */
- public function searchRelPrev(AbstractPage $page)
- {
- $found = null;
- $prev = null;
- $iterator = new RecursiveIteratorIterator(
- $this->findRoot($page),
- RecursiveIteratorIterator::SELF_FIRST
- );
- foreach ($iterator as $intermediate) {
- if (! $this->accept($intermediate)) {
- continue;
- }
- if ($intermediate === $page) {
- $found = $prev;
- break;
- }
-
- $prev = $intermediate;
- }
-
- return $found;
- }
-
- /**
- * Searches the root container for forward 'chapter' relations of the given
- * $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to a document serving as a chapter in a collection of documents.
- *
- * @return AbstractPage|array|null
- */
- public function searchRelChapter(AbstractPage $page)
- {
- $found = [];
-
- // find first level of pages
- $root = $this->findRoot($page);
-
- // find start page(s)
- $start = $this->findRelation($page, 'rel', 'start');
- if (! is_array($start)) {
- $start = [$start];
- }
-
- foreach ($root as $chapter) {
- // exclude self and start page from chapters
- if (
- $chapter !== $page &&
- ! in_array($chapter, $start) &&
- $this->accept($chapter)
- ) {
- $found[] = $chapter;
- }
- }
-
- switch (count($found)) {
- case 0:
- return;
- case 1:
- return $found[0];
- default:
- return $found;
- }
- }
-
- /**
- * Searches the root container for forward 'section' relations of the given
- * $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to a document serving as a section in a collection of documents.
- *
- * @return AbstractPage|array|null
- */
- public function searchRelSection(AbstractPage $page)
- {
- $found = [];
-
- // check if given page has pages and is a chapter page
- if ($page->hasPages() && $this->findRoot($page)->hasPage($page)) {
- foreach ($page as $section) {
- if ($this->accept($section)) {
- $found[] = $section;
- }
- }
- }
-
- switch (count($found)) {
- case 0:
- return;
- case 1:
- return $found[0];
- default:
- return $found;
- }
- }
-
- /**
- * Searches the root container for forward 'subsection' relations of the
- * given $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to a document serving as a subsection in a collection of
- * documents.
- *
- * @return AbstractPage|array|null
- */
- public function searchRelSubsection(AbstractPage $page)
- {
- $found = [];
-
- if ($page->hasPages()) {
- // given page has child pages, loop chapters
- foreach ($this->findRoot($page) as $chapter) {
- // is page a section?
- if ($chapter->hasPage($page)) {
- foreach ($page as $subsection) {
- if ($this->accept($subsection)) {
- $found[] = $subsection;
- }
- }
- }
- }
- }
-
- switch (count($found)) {
- case 0:
- return;
- case 1:
- return $found[0];
- default:
- return $found;
- }
- }
-
- /**
- * Searches the root container for the reverse 'section' relation of the
- * given $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to a document serving as a section in a collection of documents.
- *
- * @return AbstractPage|null
- */
- public function searchRevSection(AbstractPage $page)
- {
- $found = null;
- $parent = $page->getParent();
- if ($parent) {
- if (
- $parent instanceof AbstractPage &&
- $this->findRoot($page)->hasPage($parent)
- ) {
- $found = $parent;
- }
- }
-
- return $found;
- }
-
- /**
- * Searches the root container for the reverse 'section' relation of the
- * given $page
- *
- * From {@link http://www.w3.org/TR/html4/types.html#type-links}:
- * Refers to a document serving as a subsection in a collection of
- * documents.
- *
- * @return AbstractPage|null
- */
- public function searchRevSubsection(AbstractPage $page)
- {
- $found = null;
- $parent = $page->getParent();
- if ($parent) {
- if ($parent instanceof AbstractPage) {
- $root = $this->findRoot($page);
- foreach ($root as $chapter) {
- if ($chapter->hasPage($parent)) {
- $found = $parent;
- break;
- }
- }
- }
- }
-
- return $found;
- }
-
- // Util methods:
-
- /**
- * Returns the root container of the given page
- *
- * When rendering a container, the render method still store the given
- * container as the root container, and unset it when done rendering. This
- * makes sure finder methods will not traverse above the container given
- * to the render method.
- *
- * @return AbstractContainer
- */
- protected function findRoot(AbstractPage $page)
- {
- if ($this->root) {
- return $this->root;
- }
-
- $root = $page;
-
- while ($parent = $page->getParent()) {
- $root = $parent;
- if ($parent instanceof AbstractPage) {
- $page = $parent;
- } else {
- break;
- }
- }
-
- return $root;
- }
-
- /**
- * Converts a $mixed value to an array of pages
- *
- * @param mixed $mixed mixed value to get page(s) from
- * @param bool $recursive whether $value should be looped
- * if it is an array or a config
- * @return AbstractPage|array|null
- */
- protected function convertToPages($mixed, $recursive = true)
- {
- if ($mixed instanceof AbstractPage) {
- // value is a page instance; return directly
- return $mixed;
- } elseif ($mixed instanceof AbstractContainer) {
- // value is a container; return pages in it
- $pages = [];
- foreach ($mixed as $page) {
- $pages[] = $page;
- }
- return $pages;
- } elseif ($mixed instanceof Traversable) {
- $mixed = ArrayUtils::iteratorToArray($mixed);
- } elseif (is_string($mixed)) {
- // value is a string; make a URI page
- return AbstractPage::factory([
- 'type' => 'uri',
- 'uri' => $mixed,
- ]);
- }
-
- if (is_array($mixed) && ! empty($mixed)) {
- if ($recursive && is_numeric(key($mixed))) {
- // first key is numeric; assume several pages
- $pages = [];
- foreach ($mixed as $value) {
- $value = $this->convertToPages($value, false);
- if ($value) {
- $pages[] = $value;
- }
- }
- return $pages;
- } else {
- // pass array to factory directly
- try {
- return AbstractPage::factory($mixed);
- } catch (\Exception $e) {
- }
- }
- }
-
- // nothing found
- }
-
- /**
- * Sets the helper's render flag
- *
- * The helper uses the bitwise '&' operator against the hex values of the
- * render constants. This means that the flag can is "bitwised" value of
- * the render constants. Examples:
- *
- * // render all links except glossary
- * $flag = Links:RENDER_ALL ^ Links:RENDER_GLOSSARY;
- * $helper->setRenderFlag($flag);
- *
- * // render only chapters and sections
- * $flag = Links:RENDER_CHAPTER | Links:RENDER_SECTION;
- * $helper->setRenderFlag($flag);
- *
- * // render only relations that are not native W3C relations
- * $helper->setRenderFlag(Links:RENDER_CUSTOM);
- *
- * // render all relations (default)
- * $helper->setRenderFlag(Links:RENDER_ALL);
- *
- *
- * Note that custom relations can also be rendered directly using the
- * {@link renderLink()} method.
- *
- * @param int $renderFlag
- * @return Links
- */
- public function setRenderFlag($renderFlag)
- {
- $this->renderFlag = (int) $renderFlag;
-
- return $this;
- }
-
- /**
- * Returns the helper's render flag
- *
- * @return int
- */
- public function getRenderFlag()
- {
- return $this->renderFlag;
- }
-}
diff --git a/src/Helper/Navigation/Listener/AclListener.php b/src/Helper/Navigation/Listener/AclListener.php
deleted file mode 100644
index 268287684..000000000
--- a/src/Helper/Navigation/Listener/AclListener.php
+++ /dev/null
@@ -1,49 +0,0 @@
-getParams();
- $acl = $params['acl'];
- $page = $params['page'];
- $role = $params['role'];
-
- if (! $acl) {
- return $accepted;
- }
-
- $resource = $page->getResource();
- $privilege = $page->getPrivilege();
-
- if ($resource || $privilege) {
- $accepted = $acl->hasResource($resource)
- && $acl->isAllowed($role, $resource, $privilege);
- }
-
- return $accepted;
- }
-}
diff --git a/src/Helper/Navigation/Menu.php b/src/Helper/Navigation/Menu.php
deleted file mode 100644
index f3744ab51..000000000
--- a/src/Helper/Navigation/Menu.php
+++ /dev/null
@@ -1,800 +0,0 @@
- element.
- *
- * @var bool
- */
- protected $addClassToListItem = false;
-
- /**
- * Whether labels should be escaped.
- *
- * @var bool
- */
- protected $escapeLabels = true;
-
- /**
- * Whether only active branch should be rendered.
- *
- * @var bool
- */
- protected $onlyActiveBranch = false;
-
- /**
- * Partial view script to use for rendering menu.
- *
- * @var string|array
- */
- protected $partial;
-
- /**
- * Whether parents should be rendered when only rendering active branch.
- *
- * @var bool
- */
- protected $renderParents = true;
-
- /**
- * CSS class to use for the ul element.
- *
- * @var string
- */
- protected $ulClass = 'navigation';
-
- /**
- * CSS class to use for the active li element.
- *
- * @var string
- */
- protected $liActiveClass = 'active';
-
- /**
- * View helper entry point.
- *
- * Retrieves helper and optionally sets container to operate on.
- *
- * @param AbstractContainer $container [optional] container to operate on
- * @return self
- */
- public function __invoke($container = null)
- {
- if (null !== $container) {
- $this->setContainer($container);
- }
-
- return $this;
- }
-
- /**
- * Renders menu.
- *
- * Implements {@link HelperInterface::render()}.
- *
- * If a partial view is registered in the helper, the menu will be rendered
- * using the given partial script. If no partial is registered, the menu
- * will be rendered as an 'ul' element by the helper's internal method.
- *
- * @see renderPartial()
- * @see renderMenu()
- *
- * @param AbstractContainer $container [optional] container to render. Default is
- * to render the container registered in the helper.
- * @return string
- */
- public function render($container = null)
- {
- $partial = $this->getPartial();
- if ($partial) {
- return $this->renderPartial($container, $partial);
- }
-
- return $this->renderMenu($container);
- }
-
- /**
- * Renders the deepest active menu within [$minDepth, $maxDepth], (called from {@link renderMenu()}).
- *
- * @param AbstractContainer $container container to render
- * @param string $ulClass CSS class for first UL
- * @param string $indent initial indentation
- * @param int|null $minDepth minimum depth
- * @param int|null $maxDepth maximum depth
- * @param bool $escapeLabels Whether or not to escape the labels
- * @param bool $addClassToListItem Whether or not page class applied to element
- * @param string $liActiveClass CSS class for active LI
- * @return string
- */
- protected function renderDeepestMenu(
- AbstractContainer $container,
- $ulClass,
- $indent,
- $minDepth,
- $maxDepth,
- $escapeLabels,
- $addClassToListItem,
- $liActiveClass
- ) {
- if (! $active = $this->findActive($container, $minDepth - 1, $maxDepth)) {
- return '';
- }
-
- // special case if active page is one below minDepth
- if ($active['depth'] < $minDepth) {
- if (! $active['page']->hasPages(! $this->renderInvisible)) {
- return '';
- }
- } elseif (! $active['page']->hasPages(! $this->renderInvisible)) {
- // found pages has no children; render siblings
- $active['page'] = $active['page']->getParent();
- } elseif (is_int($maxDepth) && $active['depth'] + 1 > $maxDepth) {
- // children are below max depth; render siblings
- $active['page'] = $active['page']->getParent();
- }
-
- $escaper = $this->view->plugin('escapeHtmlAttr');
- assert($escaper instanceof EscapeHtmlAttr);
- $ulClass = $ulClass ? ' class="' . $escaper($ulClass) . '"' : '';
- $html = $indent . '' . PHP_EOL;
-
- foreach ($active['page'] as $subPage) {
- if (! $this->accept($subPage)) {
- continue;
- }
-
- // render li tag and page
- $liClasses = [];
-
- // Is page active?
- if ($subPage->isActive(true)) {
- $liClasses[] = $liActiveClass;
- }
-
- // Add CSS class from page to
- if ($addClassToListItem && $subPage->getClass()) {
- $liClasses[] = $subPage->getClass();
- }
-
- $liClass = empty($liClasses) ? '' : ' class="' . $escaper(implode(' ', $liClasses)) . '"';
- $html .= $indent . ' ' . PHP_EOL;
- $html .= $indent . ' ' . $this->htmlify($subPage, $escapeLabels, $addClassToListItem) . PHP_EOL;
- $html .= $indent . ' ' . PHP_EOL;
- }
-
- $html .= $indent . ' ';
-
- return $html;
- }
-
- /**
- * Renders helper.
- *
- * Renders a HTML 'ul' for the given $container. If $container is not given,
- * the container registered in the helper will be used.
- *
- * Available $options:
- *
- * @param AbstractContainer $container [optional] container to create menu from.
- * Default is to use the container retrieved from {@link getContainer()}.
- * @param array $options [optional] options for controlling rendering
- * @return string
- */
- public function renderMenu($container = null, array $options = [])
- {
- $this->parseContainer($container);
- if (null === $container) {
- $container = $this->getContainer();
- }
-
- $options = $this->normalizeOptions($options);
- if ($options['onlyActiveBranch'] && ! $options['renderParents']) {
- return $this->renderDeepestMenu(
- $container,
- $options['ulClass'],
- $options['indent'],
- $options['minDepth'],
- $options['maxDepth'],
- $options['escapeLabels'],
- $options['addClassToListItem'],
- $options['liActiveClass']
- );
- }
-
- return $this->renderNormalMenu(
- $container,
- $options['ulClass'],
- $options['indent'],
- $options['minDepth'],
- $options['maxDepth'],
- $options['onlyActiveBranch'],
- $options['escapeLabels'],
- $options['addClassToListItem'],
- $options['liActiveClass']
- );
- }
-
- /**
- * Renders a normal menu (called from {@link renderMenu()}).
- *
- * @param AbstractContainer $container container to render
- * @param string $ulClass CSS class for first UL
- * @param string $indent initial indentation
- * @param int|null $minDepth minimum depth
- * @param int|null $maxDepth maximum depth
- * @param bool $onlyActive render only active branch?
- * @param bool $escapeLabels Whether or not to escape the labels
- * @param bool $addClassToListItem Whether or not page class applied to element
- * @param string $liActiveClass CSS class for active LI
- * @return string
- */
- protected function renderNormalMenu(
- AbstractContainer $container,
- $ulClass,
- $indent,
- $minDepth,
- $maxDepth,
- $onlyActive,
- $escapeLabels,
- $addClassToListItem,
- $liActiveClass
- ) {
- $html = '';
-
- // find deepest active
- $found = $this->findActive($container, $minDepth, $maxDepth);
-
- $escaper = $this->view->plugin('escapeHtmlAttr');
- assert($escaper instanceof EscapeHtmlAttr);
-
- $foundPage = null;
- $foundDepth = 0;
-
- if ($found) {
- $foundPage = $found['page'];
- $foundDepth = $found['depth'];
- }
-
- // create iterator
- $iterator = new RecursiveIteratorIterator(
- $container,
- RecursiveIteratorIterator::SELF_FIRST
- );
-
- if (is_int($maxDepth)) {
- $iterator->setMaxDepth($maxDepth);
- }
-
- // iterate container
- $prevDepth = -1;
- foreach ($iterator as $page) {
- $depth = $iterator->getDepth();
- $isActive = $page->isActive(true);
- if ($depth < $minDepth || ! $this->accept($page)) {
- // page is below minDepth or not accepted by acl/visibility
- continue;
- } elseif ($onlyActive && ! $isActive) {
- // page is not active itself, but might be in the active branch
- $accept = false;
- if ($foundPage) {
- if ($foundPage->hasPage($page)) {
- // accept if page is a direct child of the active page
- $accept = true;
- } elseif ($foundPage->getParent()->hasPage($page)) {
- // page is a sibling of the active page...
- if (
- ! $foundPage->hasPages(! $this->renderInvisible)
- || is_int($maxDepth) && $foundDepth + 1 > $maxDepth
- ) {
- // accept if active page has no children, or the
- // children are too deep to be rendered
- $accept = true;
- }
- }
- }
- if (! $accept) {
- continue;
- }
- }
-
- // make sure indentation is correct
- $depth -= $minDepth;
- $myIndent = $indent . str_repeat(' ', $depth);
- if ($depth > $prevDepth) {
- // start new ul tag
- if ($ulClass && $depth === 0) {
- $ulClass = ' class="' . $escaper($ulClass) . '"';
- } else {
- $ulClass = '';
- }
- $html .= $myIndent . '' . PHP_EOL;
- } elseif ($prevDepth > $depth) {
- // close li/ul tags until we're at current depth
- for ($i = $prevDepth; $i > $depth; $i--) {
- $ind = $indent . str_repeat(' ', $i);
- $html .= $ind . ' ' . PHP_EOL;
- $html .= $ind . '' . PHP_EOL;
- }
- // close previous li tag
- $html .= $myIndent . ' ' . PHP_EOL;
- } else {
- // close previous li tag
- $html .= $myIndent . ' ' . PHP_EOL;
- }
-
- // render li tag and page
- $liClasses = [];
-
- // Is page active?
- if ($isActive) {
- $liClasses[] = $liActiveClass;
- }
-
- // Add CSS class from page to
- if ($addClassToListItem && $page->getClass()) {
- $liClasses[] = $page->getClass();
- }
- $liClass = empty($liClasses) ? '' : ' class="' . $escaper(implode(' ', $liClasses)) . '"';
- $html .= $myIndent . ' ' . PHP_EOL
- . $myIndent . ' ' . $this->htmlify($page, $escapeLabels, $addClassToListItem) . PHP_EOL;
-
- // store as previous depth for next iteration
- $prevDepth = $depth;
- }
-
- if ($html) {
- // done iterating container; close open ul/li tags
- for ($i = $prevDepth + 1; $i > 0; $i--) {
- $myIndent = $indent . str_repeat(' ', $i - 1);
- $html .= $myIndent . ' ' . PHP_EOL
- . $myIndent . '' . PHP_EOL;
- }
- $html = rtrim($html, PHP_EOL);
- }
-
- return $html;
- }
-
- /**
- * Renders the given $container by invoking the partial view helper.
- *
- * The container will simply be passed on as a model to the view script
- * as-is, and will be available in the partial script as 'container', e.g.
- * echo 'Number of pages: ', count($this->container);
.
- *
- * @param null|AbstractContainer $container [optional] container to pass to view
- * script. Default is to use the container registered in the helper.
- * @param null|string|array $partial [optional] partial view script to use.
- * Default is to use the partial registered in the helper. If an array
- * is given, the first value is used for the partial view script.
- * @return string
- * @throws Exception\RuntimeException If no partial provided.
- * @throws Exception\InvalidArgumentException If partial is invalid array.
- */
- public function renderPartial($container = null, $partial = null)
- {
- return $this->renderPartialModel([], $container, $partial);
- }
-
- /**
- * Renders the given $container by invoking the partial view helper with the given parameters as the model.
- *
- * The container will simply be passed on as a model to the view script
- * as-is, and will be available in the partial script as 'container', e.g.
- * echo 'Number of pages: ', count($this->container);
.
- *
- * Any parameters provided will be passed to the partial via the view model.
- *
- * @param null|AbstractContainer $container [optional] container to pass to view
- * script. Default is to use the container registered in the helper.
- * @param null|string|array $partial [optional] partial view script to use.
- * Default is to use the partial registered in the helper. If an array
- * is given, the first value is used for the partial view script.
- * @return string
- * @throws Exception\RuntimeException If no partial provided.
- * @throws Exception\InvalidArgumentException If partial is invalid array.
- */
- public function renderPartialWithParams(array $params = [], $container = null, $partial = null)
- {
- return $this->renderPartialModel($params, $container, $partial);
- }
-
- /**
- * Renders the inner-most sub menu for the active page in the $container.
- *
- * This is a convenience method which is equivalent to the following call:
- *
- * renderMenu($container, array(
- * 'indent' => $indent,
- * 'ulClass' => $ulClass,
- * 'minDepth' => null,
- * 'maxDepth' => null,
- * 'onlyActiveBranch' => true,
- * 'renderParents' => false,
- * 'liActiveClass' => $liActiveClass
- * ));
- *
- *
- * @param AbstractContainer|null $container [optional] container to render.
- * Default is to render the container registered in the helper.
- * @param string $ulClass [optional] CSS class to use for UL element.
- * Default is to use the value from {@link getUlClass()}.
- * @param string|int $indent [optional] indentation as a string or number
- * of spaces. Default is to use the value retrieved from
- * {@link getIndent()}.
- * @param string $liActiveClass [optional] CSS class to use for UL
- * element. Default is to use the value from {@link getUlClass()}.
- * @return string
- */
- public function renderSubMenu(
- ?AbstractContainer $container = null,
- $ulClass = null,
- $indent = null,
- $liActiveClass = null
- ) {
- return $this->renderMenu($container, [
- 'indent' => $indent,
- 'ulClass' => $ulClass,
- 'minDepth' => null,
- 'maxDepth' => null,
- 'onlyActiveBranch' => true,
- 'renderParents' => false,
- 'escapeLabels' => true,
- 'addClassToListItem' => false,
- 'liActiveClass' => $liActiveClass,
- ]);
- }
-
- /**
- * Returns an HTML string containing an 'a' element for the given page if
- * the page's href is not empty, and a 'span' element if it is empty.
- *
- * Overrides {@link AbstractHelper::htmlify()}.
- *
- * @param AbstractPage $page page to generate HTML for
- * @param bool $escapeLabel Whether or not to escape the label
- * @param bool $addClassToListItem Whether or not to add the page class to the list item
- * @return string
- */
- public function htmlify(AbstractPage $page, $escapeLabel = true, $addClassToListItem = false)
- {
- // get attribs for element
- $attribs = [
- 'id' => $page->getId(),
- 'title' => $this->translate($page->getTitle(), $page->getTextDomain()),
- ];
-
- if ($addClassToListItem === false) {
- $attribs['class'] = $page->getClass();
- }
-
- // does page have a href?
- $href = $page->getHref();
- if ($href) {
- $element = 'a';
- $attribs['href'] = $href;
- $attribs['target'] = $page->getTarget();
- } else {
- $element = 'span';
- }
-
- if ($page->isActive()) {
- $attribs['aria-current'] = 'page';
- }
-
- $html = '<' . $element . $this->htmlAttribs($attribs) . '>';
- $label = $this->translate($page->getLabel(), $page->getTextDomain());
-
- if ($escapeLabel === true) {
- /** @var EscapeHtml $escaper */
- $escaper = $this->view->plugin('escapeHtml');
- $html .= $escaper($label);
- } else {
- $html .= $label;
- }
-
- $html .= '' . $element . '>';
- return $html;
- }
-
- /**
- * Normalizes given render options.
- *
- * @param array $options [optional] options to normalize
- * @return array
- */
- protected function normalizeOptions(array $options = [])
- {
- if (isset($options['indent'])) {
- $options['indent'] = $this->getWhitespace($options['indent']);
- } else {
- $options['indent'] = $this->getIndent();
- }
-
- if (isset($options['ulClass']) && $options['ulClass'] !== null) {
- $options['ulClass'] = (string) $options['ulClass'];
- } else {
- $options['ulClass'] = $this->getUlClass();
- }
-
- if (array_key_exists('minDepth', $options)) {
- if (null !== $options['minDepth']) {
- $options['minDepth'] = (int) $options['minDepth'];
- }
- } else {
- $options['minDepth'] = $this->getMinDepth();
- }
-
- if ($options['minDepth'] < 0 || $options['minDepth'] === null) {
- $options['minDepth'] = 0;
- }
-
- if (array_key_exists('maxDepth', $options)) {
- if (null !== $options['maxDepth']) {
- $options['maxDepth'] = (int) $options['maxDepth'];
- }
- } else {
- $options['maxDepth'] = $this->getMaxDepth();
- }
-
- if (! isset($options['onlyActiveBranch'])) {
- $options['onlyActiveBranch'] = $this->getOnlyActiveBranch();
- }
-
- if (! isset($options['escapeLabels'])) {
- $options['escapeLabels'] = $this->escapeLabels;
- }
-
- if (! isset($options['renderParents'])) {
- $options['renderParents'] = $this->getRenderParents();
- }
-
- if (! isset($options['addClassToListItem'])) {
- $options['addClassToListItem'] = $this->getAddClassToListItem();
- }
-
- if (isset($options['liActiveClass']) && $options['liActiveClass'] !== null) {
- $options['liActiveClass'] = (string) $options['liActiveClass'];
- } else {
- $options['liActiveClass'] = $this->getLiActiveClass();
- }
-
- return $options;
- }
-
- /**
- * Sets a flag indicating whether labels should be escaped.
- *
- * @param bool $flag [optional] escape labels
- * @return self
- */
- public function escapeLabels($flag = true)
- {
- $this->escapeLabels = (bool) $flag;
- return $this;
- }
-
- /**
- * Enables/disables page class applied to element.
- *
- * @param bool $flag [optional] page class applied to element Default
- * is true.
- * @return self fluent interface, returns self
- */
- public function setAddClassToListItem($flag = true)
- {
- $this->addClassToListItem = (bool) $flag;
- return $this;
- }
-
- /**
- * Returns flag indicating whether page class should be applied to element.
- *
- * By default, this value is false.
- *
- * @return bool whether parents should be rendered
- */
- public function getAddClassToListItem()
- {
- return $this->addClassToListItem;
- }
-
- /**
- * Sets a flag indicating whether only active branch should be rendered.
- *
- * @param bool $flag [optional] render only active branch.
- * @return self
- */
- public function setOnlyActiveBranch($flag = true)
- {
- $this->onlyActiveBranch = (bool) $flag;
- return $this;
- }
-
- /**
- * Returns a flag indicating whether only active branch should be rendered.
- *
- * By default, this value is false, meaning the entire menu will be
- * be rendered.
- *
- * @return bool
- */
- public function getOnlyActiveBranch()
- {
- return $this->onlyActiveBranch;
- }
-
- /**
- * Sets which partial view script to use for rendering menu.
- *
- * @param string|array $partial partial view script or null. If an array
- * is given, the first value is used for the partial view script.
- * @return self
- */
- public function setPartial($partial)
- {
- if (null === $partial || is_string($partial) || is_array($partial)) {
- $this->partial = $partial;
- }
-
- return $this;
- }
-
- /**
- * Returns partial view script to use for rendering menu.
- *
- * @return string|array|null
- */
- public function getPartial()
- {
- return $this->partial;
- }
-
- /**
- * Enables/disables rendering of parents when only rendering active branch.
- *
- * See {@link setOnlyActiveBranch()} for more information.
- *
- * @param bool $flag [optional] render parents when rendering active branch.
- * @return self
- */
- public function setRenderParents($flag = true)
- {
- $this->renderParents = (bool) $flag;
- return $this;
- }
-
- /**
- * Returns flag indicating whether parents should be rendered when rendering only the active branch.
- *
- * By default, this value is true.
- *
- * @return bool
- */
- public function getRenderParents()
- {
- return $this->renderParents;
- }
-
- /**
- * Sets CSS class to use for the first 'ul' element when rendering.
- *
- * @param string $ulClass CSS class to set
- * @return self
- */
- public function setUlClass($ulClass)
- {
- if (is_string($ulClass)) {
- $this->ulClass = $ulClass;
- }
- return $this;
- }
-
- /**
- * Returns CSS class to use for the first 'ul' element when rendering.
- *
- * @return string
- */
- public function getUlClass()
- {
- return $this->ulClass;
- }
-
- /**
- * Sets CSS class to use for the active 'li' element when rendering.
- *
- * @param string $liActiveClass CSS class to set
- * @return self
- */
- public function setLiActiveClass($liActiveClass)
- {
- if (is_string($liActiveClass)) {
- $this->liActiveClass = $liActiveClass;
- }
- return $this;
- }
-
- /**
- * Returns CSS class to use for the active 'li' element when rendering.
- *
- * @return string
- */
- public function getLiActiveClass()
- {
- return $this->liActiveClass;
- }
-
- /**
- * Render a partial with the given "model".
- *
- * @param array $params
- * @param null|AbstractContainer $container
- * @param null|string|array $partial
- * @return Partial|string
- * @throws Exception\RuntimeException If no partial provided.
- * @throws Exception\InvalidArgumentException If partial is invalid array.
- */
- protected function renderPartialModel(array $params, $container, $partial)
- {
- $this->parseContainer($container);
- if (null === $container) {
- $container = $this->getContainer();
- }
-
- if (null === $partial) {
- $partial = $this->getPartial();
- }
-
- if (empty($partial)) {
- throw new Exception\RuntimeException(
- 'Unable to render menu: No partial view script provided'
- );
- }
-
- $model = array_merge($params, ['container' => $container]);
-
- /** @var Partial $partialHelper */
- $partialHelper = $this->view->plugin('partial');
- if (is_array($partial)) {
- if (count($partial) !== 2) {
- throw new Exception\InvalidArgumentException(
- 'Unable to render menu: A view partial supplied as '
- . 'an array must contain one value: the partial view script'
- );
- }
-
- return $partialHelper($partial[0], $model);
- }
-
- return $partialHelper($partial, $model);
- }
-}
diff --git a/src/Helper/Navigation/PluginManager.php b/src/Helper/Navigation/PluginManager.php
deleted file mode 100644
index fa279984b..000000000
--- a/src/Helper/Navigation/PluginManager.php
+++ /dev/null
@@ -1,76 +0,0 @@
-
- */
-class PluginManager extends HelperPluginManager
-{
- /** {@inheritDoc} */
- protected $instanceOf = AbstractHelper::class;
-
- /**
- * Default aliases
- *
- * @var array
- */
- protected $aliases = [
- 'breadcrumbs' => Breadcrumbs::class,
- 'links' => Links::class,
- 'menu' => Menu::class,
- 'sitemap' => Sitemap::class,
- ];
-
- /**
- * Default factories
- *
- * {@inheritDoc}
- */
- protected $factories = [
- Breadcrumbs::class => InvokableFactory::class,
- Links::class => InvokableFactory::class,
- Menu::class => InvokableFactory::class,
- Sitemap::class => InvokableFactory::class,
-
- // v2 canonical FQCNs
- 'laminasviewhelpernavigationbreadcrumbs' => InvokableFactory::class,
- 'laminasviewhelpernavigationlinks' => InvokableFactory::class,
- 'laminasviewhelpernavigationmenu' => InvokableFactory::class,
- 'laminasviewhelpernavigationsitemap' => InvokableFactory::class,
- ];
-
- /**
- * @param ContainerInterface $configOrContainerInstance
- * @param array $v3config
- * @psalm-param ServiceManagerConfiguration $v3config
- */
- public function __construct($configOrContainerInstance = null, array $v3config = [])
- {
- /** @psalm-suppress MissingClosureParamType */
- $this->initializers[] = function (ContainerInterface $container, $instance): void {
- if (! $instance instanceof AbstractHelper) {
- return;
- }
-
- $instance->setServiceLocator($this->creationContext);
- };
-
- parent::__construct($configOrContainerInstance, $v3config);
- }
-}
diff --git a/src/Helper/Navigation/Sitemap.php b/src/Helper/Navigation/Sitemap.php
deleted file mode 100644
index aa0551102..000000000
--- a/src/Helper/Navigation/Sitemap.php
+++ /dev/null
@@ -1,458 +0,0 @@
- tag
- *
- * @var string
- */
- public const SITEMAP_NS = 'http://www.sitemaps.org/schemas/sitemap/0.9';
-
- /**
- * Schema URL
- *
- * @var string
- */
- public const SITEMAP_XSD = 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd';
-
- /**
- * Whether XML output should be formatted
- *
- * @var bool
- */
- protected $formatOutput = false;
-
- /**
- * Server url
- *
- * @var string
- */
- protected $serverUrl;
-
- /**
- * List of urls in the sitemap
- *
- * @var array
- */
- protected $urls = [];
-
- /**
- * Whether sitemap should be validated using Laminas\Validate\Sitemap\*
- *
- * @var bool
- */
- protected $useSitemapValidators = true;
-
- /**
- * Whether sitemap should be schema validated when generated
- *
- * @var bool
- */
- protected $useSchemaValidation = false;
-
- /**
- * Whether the XML declaration should be included in XML output
- *
- * @var bool
- */
- protected $useXmlDeclaration = true;
-
- /**
- * Helper entry point
- *
- * @param string|AbstractContainer $container container to operate on
- * @return Sitemap
- */
- public function __invoke($container = null)
- {
- if (null !== $container) {
- $this->setContainer($container);
- }
-
- return $this;
- }
-
- /**
- * Renders helper
- *
- * Implements {@link HelperInterface::render()}.
- *
- * @param AbstractContainer $container [optional] container to render. Default is
- * to render the container registered in the helper.
- * @return string
- */
- public function render($container = null)
- {
- $dom = $this->getDomSitemap($container);
- $xml = $this->getUseXmlDeclaration() ?
- $dom->saveXML() :
- $dom->saveXML($dom->documentElement);
-
- return rtrim($xml, PHP_EOL);
- }
-
- /**
- * Returns a DOMDocument containing the Sitemap XML for the given container
- *
- * @param AbstractContainer|null $container [optional] container to get
- * breadcrumbs from, defaults
- * to what is registered in the
- * helper
- * @return DOMDocument DOM representation of the
- * container
- * @throws Exception\RuntimeException If schema validation is on
- * and the sitemap is invalid
- * according to the sitemap
- * schema, or if sitemap
- * validators are used and the
- * loc element fails validation.
- */
- public function getDomSitemap(?AbstractContainer $container = null)
- {
- // Reset the urls
- $this->urls = [];
-
- if (null === $container) {
- $container = $this->getContainer();
- }
-
- $locValidator = null;
- $lastmodValidator = null;
- $changefreqValidator = null;
- $priorityValidator = null;
-
- // check if we should validate using our own validators
- if ($this->getUseSitemapValidators()) {
- // create validators
- $locValidator = new Loc();
- $lastmodValidator = new Lastmod();
- $changefreqValidator = new Changefreq();
- $priorityValidator = new Priority();
- }
-
- // create document
- $dom = new DOMDocument('1.0', 'UTF-8');
- $dom->formatOutput = $this->getFormatOutput();
-
- // ...and urlset (root) element
- $urlSet = $dom->createElementNS(self::SITEMAP_NS, 'urlset');
- $dom->appendChild($urlSet);
-
- // create iterator
- $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::SELF_FIRST);
-
- $maxDepth = $this->getMaxDepth();
- if (is_int($maxDepth)) {
- $iterator->setMaxDepth($maxDepth);
- }
- $minDepth = $this->getMinDepth();
- if (! is_int($minDepth) || $minDepth < 0) {
- $minDepth = 0;
- }
-
- // iterate container
- foreach ($iterator as $page) {
- if ($iterator->getDepth() < $minDepth || ! $this->accept($page)) {
- // page should not be included
- continue;
- }
-
- // get absolute url from page
- if (! $url = $this->url($page)) {
- // skip page if it has no url (rare case)
- // or already is in the sitemap
- continue;
- }
-
- // create url node for this page
- $urlNode = $dom->createElementNS(self::SITEMAP_NS, 'url');
- $urlSet->appendChild($urlNode);
-
- if (
- $this->getUseSitemapValidators()
- && ! $locValidator->isValid($url)
- ) {
- throw new Exception\RuntimeException(sprintf(
- 'Encountered an invalid URL for Sitemap XML: "%s"',
- $url
- ));
- }
-
- // put url in 'loc' element
- $urlNode->appendChild($dom->createElementNS(self::SITEMAP_NS, 'loc', $url));
-
- // add 'lastmod' element if a valid lastmod is set in page
- if (isset($page->lastmod)) {
- $lastmod = strtotime((string) $page->lastmod);
-
- // prevent 1970-01-01...
- if ($lastmod !== false) {
- $lastmod = date('c', $lastmod);
- }
-
- if (
- ! $this->getUseSitemapValidators()
- || $lastmodValidator->isValid($lastmod)
- ) {
- // Cast $lastmod to string in case no validation was used
- $urlNode->appendChild(
- $dom->createElementNS(self::SITEMAP_NS, 'lastmod', (string) $lastmod)
- );
- }
- }
-
- // add 'changefreq' element if a valid changefreq is set in page
- if (isset($page->changefreq)) {
- $changefreq = $page->changefreq;
- if (
- ! $this->getUseSitemapValidators() ||
- $changefreqValidator->isValid($changefreq)
- ) {
- $urlNode->appendChild(
- $dom->createElementNS(self::SITEMAP_NS, 'changefreq', $changefreq)
- );
- }
- }
-
- // add 'priority' element if a valid priority is set in page
- if (isset($page->priority)) {
- $priority = $page->priority;
- if (
- ! $this->getUseSitemapValidators() ||
- $priorityValidator->isValid($priority)
- ) {
- $urlNode->appendChild(
- $dom->createElementNS(self::SITEMAP_NS, 'priority', $priority)
- );
- }
- }
- }
-
- // validate using schema if specified
- if ($this->getUseSchemaValidation()) {
- ErrorHandler::start();
- $test = $dom->schemaValidate(self::SITEMAP_XSD);
- $error = ErrorHandler::stop();
- if (! $test) {
- throw new Exception\RuntimeException(sprintf(
- 'Sitemap is invalid according to XML Schema at "%s"',
- self::SITEMAP_XSD
- ), 0, $error);
- }
- }
-
- return $dom;
- }
-
- /**
- * Returns an escaped absolute URL for the given page
- *
- * @return null|string
- */
- public function url(AbstractPage $page)
- {
- $href = $page->getHref();
-
- if (! isset($href[0])) {
- // no href
- return '';
- } elseif ($href[0] === '/') {
- // href is relative to root; use serverUrl helper
- $url = $this->getServerUrl() . $href;
- } elseif (preg_match('/^[a-z]+:/im', (string) $href)) {
- // scheme is given in href; assume absolute URL already
- $url = (string) $href;
- } else {
- // href is relative to current document; use url helpers
- $basePathHelper = $this->getView()->plugin('basepath');
- $curDoc = $basePathHelper();
- $curDoc = '/' === $curDoc ? '' : trim($curDoc, '/');
- $url = rtrim($this->getServerUrl(), '/') . '/'
- . $curDoc
- . (empty($curDoc) ? '' : '/') . $href;
- }
-
- if (! in_array($url, $this->urls)) {
- $this->urls[] = $url;
- return $this->xmlEscape($url);
- }
-
- return null;
- }
-
- /**
- * Escapes string for XML usage
- *
- * @param string $string
- * @return string
- */
- protected function xmlEscape($string)
- {
- $escaper = $this->view->plugin('escapeHtml');
- return $escaper($string);
- }
-
- /**
- * Sets whether XML output should be formatted
- *
- * @param bool $formatOutput
- * @return Sitemap
- */
- public function setFormatOutput($formatOutput = true)
- {
- $this->formatOutput = (bool) $formatOutput;
- return $this;
- }
-
- /**
- * Returns whether XML output should be formatted
- *
- * @return bool
- */
- public function getFormatOutput()
- {
- return $this->formatOutput;
- }
-
- /**
- * Sets server url (scheme and host-related stuff without request URI)
- *
- * E.g. http://www.example.com
- *
- * @param string $serverUrl
- * @return Sitemap
- * @throws Exception\InvalidArgumentException
- */
- public function setServerUrl($serverUrl)
- {
- $uri = Uri\UriFactory::factory($serverUrl);
- $uri->setFragment('');
- $uri->setPath('');
- $uri->setQuery('');
-
- if ($uri->isValid()) {
- $this->serverUrl = $uri->toString();
- } else {
- throw new Exception\InvalidArgumentException(sprintf(
- 'Invalid server URL: "%s"',
- $serverUrl
- ));
- }
-
- return $this;
- }
-
- /**
- * Returns server URL
- *
- * @return string
- */
- public function getServerUrl()
- {
- if (! isset($this->serverUrl)) {
- $serverUrlHelper = $this->getView()->plugin('serverUrl');
- $this->serverUrl = $serverUrlHelper();
- }
-
- return $this->serverUrl;
- }
-
- /**
- * Sets whether sitemap should be validated using Laminas\Validate\Sitemap_*
- *
- * @param bool $useSitemapValidators
- * @return Sitemap
- */
- public function setUseSitemapValidators($useSitemapValidators)
- {
- $this->useSitemapValidators = (bool) $useSitemapValidators;
- return $this;
- }
-
- /**
- * Returns whether sitemap should be validated using Laminas\Validate\Sitemap_*
- *
- * @return bool
- */
- public function getUseSitemapValidators()
- {
- return $this->useSitemapValidators;
- }
-
- /**
- * Sets whether sitemap should be schema validated when generated
- *
- * @param bool $schemaValidation
- * @return Sitemap
- */
- public function setUseSchemaValidation($schemaValidation)
- {
- $this->useSchemaValidation = (bool) $schemaValidation;
- return $this;
- }
-
- /**
- * Returns true if sitemap should be schema validated when generated
- *
- * @return bool
- */
- public function getUseSchemaValidation()
- {
- return $this->useSchemaValidation;
- }
-
- /**
- * Sets whether the XML declaration should be used in output
- *
- * @param bool $useXmlDecl
- * @return Sitemap
- */
- public function setUseXmlDeclaration($useXmlDecl)
- {
- $this->useXmlDeclaration = (bool) $useXmlDecl;
- return $this;
- }
-
- /**
- * Returns whether the XML declaration should be used in output
- *
- * @return bool
- */
- public function getUseXmlDeclaration()
- {
- return $this->useXmlDeclaration;
- }
-}
diff --git a/src/Renderer/PhpRenderer.php b/src/Renderer/PhpRenderer.php
index 3021385fb..1c29e726b 100644
--- a/src/Renderer/PhpRenderer.php
+++ b/src/Renderer/PhpRenderer.php
@@ -70,7 +70,6 @@
* @method mixed|null identity()
* @method \Laminas\View\Helper\InlineScript inlineScript($mode = \Laminas\View\Helper\HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript')
* @method Model|\Laminas\View\Helper\Layout layout($template = null)
- * @method \Laminas\View\Helper\Navigation navigation($container = null)
* @method string paginationControl(\Laminas\Paginator\Paginator $paginator = null, $scrollingStyle = null, $partial = null, $params = null)
* @method string|\Laminas\View\Helper\Partial partial($name = null, $values = null)
* @method string partialLoop($name = null, $values = null)
@@ -80,10 +79,6 @@
* @method string serverUrl($requestUri = null)
* @method string url($name = null, array $params = array(), $options = array(), $reuseMatchedParams = false)
* @method \Laminas\View\Helper\ViewModel viewModel()
- * @method \Laminas\View\Helper\Navigation\Breadcrumbs breadCrumbs($container = null)
- * @method \Laminas\View\Helper\Navigation\Links links($container = null)
- * @method \Laminas\View\Helper\Navigation\Menu menu($container = null)
- * @method \Laminas\View\Helper\Navigation\Sitemap sitemap($container = null)
* @method string gravatarImage(string $emailAddress, int $imageSize = 80, array $imageAttributes = [], string $defaultImage = 'mm', string $rating = 'g')
*/
class PhpRenderer implements Renderer, TreeRendererInterface
diff --git a/test/Helper/Navigation/AbstractHelperTest.php b/test/Helper/Navigation/AbstractHelperTest.php
deleted file mode 100644
index 3d4e6ee4c..000000000
--- a/test/Helper/Navigation/AbstractHelperTest.php
+++ /dev/null
@@ -1,109 +0,0 @@
-_helper = new NavigationHelper\Breadcrumbs();
- parent::setUp();
- }
-
- protected function tearDown(): void
- {
- parent::tearDown();
-
- if ($this->_helper) {
- $this->_helper->setDefaultAcl(null);
- $this->_helper->setAcl(null);
- $this->_helper->setDefaultRole(null);
- $this->_helper->setRole(null);
- }
- }
-
- public function testHasACLChecksDefaultACL(): void
- {
- $aclContainer = $this->getAcl();
- $acl = $aclContainer['acl'];
-
- $this->assertEquals(false, $this->_helper->hasACL());
- $this->_helper->setDefaultAcl($acl);
- $this->assertEquals(true, $this->_helper->hasAcl());
- }
-
- public function testHasACLChecksMemberVariable(): void
- {
- $aclContainer = $this->getAcl();
- $acl = $aclContainer['acl'];
-
- $this->assertEquals(false, $this->_helper->hasAcl());
- $this->_helper->setAcl($acl);
- $this->assertEquals(true, $this->_helper->hasAcl());
- }
-
- public function testHasRoleChecksDefaultRole(): void
- {
- $aclContainer = $this->getAcl();
- $role = $aclContainer['role'];
-
- $this->assertEquals(false, $this->_helper->hasRole());
- $this->_helper->setDefaultRole($role);
- $this->assertEquals(true, $this->_helper->hasRole());
- }
-
- public function testHasRoleChecksMemberVariable(): void
- {
- $aclContainer = $this->getAcl();
- $role = $aclContainer['role'];
-
- $this->assertEquals(false, $this->_helper->hasRole());
- $this->_helper->setRole($role);
- $this->assertEquals(true, $this->_helper->hasRole());
- }
-
- public function testEventManagerIsNullByDefault(): void
- {
- $this->assertNull($this->_helper->getEventManager());
- }
-
- public function testFallBackForContainerNames(): void
- {
- // Register navigation service with name equal to the documentation
- $this->serviceManager->setAllowOverride(true);
- $this->serviceManager->setService(
- 'navigation',
- $this->serviceManager->get('Navigation')
- );
- $this->serviceManager->setAllowOverride(false);
-
- $this->_helper->setServiceLocator($this->serviceManager);
-
- $this->_helper->setContainer('navigation');
- $this->assertInstanceOf(
- Navigation::class,
- $this->_helper->getContainer()
- );
-
- $this->_helper->setContainer('default');
- $this->assertInstanceOf(
- Navigation::class,
- $this->_helper->getContainer()
- );
- }
-}
diff --git a/test/Helper/Navigation/AbstractTestCase.php b/test/Helper/Navigation/AbstractTestCase.php
deleted file mode 100644
index b0e7307bd..000000000
--- a/test/Helper/Navigation/AbstractTestCase.php
+++ /dev/null
@@ -1,241 +0,0 @@
-files = $cwd . '/_files';
-
- /** @var array{nav_test1: mixed[], nav_test2: mixed[], nav_test3: mixed[]} $config */
- $config = require __DIR__ . '/_files/navigation-config.php';
-
- // setup containers from config
- $this->nav1 = new Navigation($config['nav_test1']);
- $this->nav2 = new Navigation($config['nav_test2']);
- $this->nav3 = new Navigation($config['nav_test3']);
-
- // setup view
- $view = new PhpRenderer();
- $resolver = $view->resolver();
- assert($resolver instanceof TemplatePathStack);
- $resolver->addPath($cwd . '/_files/mvc/views');
-
- // inject view into test subject helper
- $this->_helper->setView($view);
-
- // set nav1 in helper as default
- $this->_helper->setContainer($this->nav1);
-
- // setup service manager
- $smConfig = [
- 'modules' => [],
- 'module_listener_options' => [
- 'config_cache_enabled' => false,
- 'cache_dir' => 'data/cache',
- 'module_paths' => [],
- 'extra_config' => [
- 'service_manager' => [
- 'factories' => [
- /**
- 'config' => * @return array[]
- 'config' => * @psalm-return array{navigation: array{default: mixed}}
- */
- 'config' => static fn(): array => [
- 'navigation' => [
- 'default' => $config['nav_test1'],
- ],
- ],
- ],
- ],
- ],
- ],
- ];
-
- $sm = $this->serviceManager = new ServiceManager();
- $sm->setAllowOverride(true);
-
- (new ServiceManagerConfig())->configureServiceManager($sm);
-
- if (! class_exists(V2RouteMatch::class) && class_exists(RouterConfigProvider::class)) {
- $routerConfig = new Config((new RouterConfigProvider())->getDependencyConfig());
- $routerConfig->configureServiceManager($sm);
- }
-
- $sm->setService('ApplicationConfig', $smConfig);
- $moduleManager = $sm->get('ModuleManager');
- self::assertInstanceOf(ModuleManager::class, $moduleManager);
- $moduleManager->loadModules();
- $application = $sm->get('Application');
- self::assertInstanceOf(Application::class, $application);
- $application->bootstrap();
- $sm->setFactory('Navigation', DefaultNavigationFactory::class);
-
- $sm->setService('nav1', $this->nav1);
- $sm->setService('nav2', $this->nav2);
-
- $sm->setAllowOverride(false);
- $application->getMvcEvent()->setRouteMatch(new RouteMatch([
- 'controller' => 'post',
- 'action' => 'view',
- 'id' => '1337',
- ]));
- }
-
- /**
- * Returns the expected contents of the given $filename
- */
- protected function getExpectedFileContents(string $filename): string
- {
- return file_get_contents($this->files . '/expected/' . $filename);
- }
-
- /**
- * @preturn array{acl: Acl, role: 'special'}
- */
- protected function getAcl(): array
- {
- $acl = new Acl();
-
- $acl->addRole(new GenericRole('guest'));
- $acl->addRole(new GenericRole('member'), 'guest');
- $acl->addRole(new GenericRole('admin'), 'member');
- $acl->addRole(new GenericRole('special'), 'member');
-
- $acl->addResource(new GenericResource('guest_foo'));
- $acl->addResource(new GenericResource('member_foo'), 'guest_foo');
- $acl->addResource(new GenericResource('admin_foo'));
- $acl->addResource(new GenericResource('special_foo'), 'member_foo');
-
- $acl->allow('guest', 'guest_foo');
- $acl->allow('member', 'member_foo');
- $acl->allow('admin', 'admin_foo');
- $acl->allow('special', 'special_foo');
- $acl->allow('special', 'admin_foo', 'read');
-
- return ['acl' => $acl, 'role' => 'special'];
- }
-
- protected function getTranslator(): Translator
- {
- $loader = new TestAsset\ArrayTranslator();
- $loader->translations = [
- 'Page 1' => 'Side 1',
- 'Page 1.1' => 'Side 1.1',
- 'Page 2' => 'Side 2',
- 'Page 2.3' => 'Side 2.3',
- 'Page 2.3.3.1' => 'Side 2.3.3.1',
- 'Home' => 'Hjem',
- 'Go home' => 'Gå hjem',
- ];
- $translator = new Translator();
- $translator->getPluginManager()->setService('default', $loader);
- $translator->addTranslationFile('default', __FILE__);
- return $translator;
- }
-
- protected function getTranslatorWithTextDomain(): Translator
- {
- $loader1 = new TestAsset\ArrayTranslator();
- $loader1->translations = [
- 'Page 1' => 'TextDomain1 1',
- 'Page 1.1' => 'TextDomain1 1.1',
- 'Page 2' => 'TextDomain1 2',
- 'Page 2.3' => 'TextDomain1 2.3',
- 'Page 2.3.3' => 'TextDomain1 2.3.3',
- 'Page 2.3.3.1' => 'TextDomain1 2.3.3.1',
- ];
-
- $loader2 = new TestAsset\ArrayTranslator();
- $loader2->translations = [
- 'Page 1' => 'TextDomain2 1',
- 'Page 1.1' => 'TextDomain2 1.1',
- 'Page 2' => 'TextDomain2 2',
- 'Page 2.3' => 'TextDomain2 2.3',
- 'Page 2.3.3' => 'TextDomain2 2.3.3',
- 'Page 2.3.3.1' => 'TextDomain2 2.3.3.1',
- ];
-
- $translator = new Translator();
- $translator->getPluginManager()->setService('default1', $loader1);
- $translator->getPluginManager()->setService('default2', $loader2);
- $translator->addTranslationFile('default1', __FILE__, 'LaminasTest_1');
- $translator->addTranslationFile('default2', __FILE__, 'LaminasTest_2');
- return $translator;
- }
-}
diff --git a/test/Helper/Navigation/BreadcrumbsTest.php b/test/Helper/Navigation/BreadcrumbsTest.php
deleted file mode 100644
index 539b5317c..000000000
--- a/test/Helper/Navigation/BreadcrumbsTest.php
+++ /dev/null
@@ -1,257 +0,0 @@
-_helper = new Breadcrumbs();
- parent::setUp();
- }
-
- public function testCanRenderStraightFromServiceAlias(): void
- {
- $this->_helper->setServiceLocator($this->serviceManager);
-
- $returned = $this->_helper->renderStraight('Navigation');
- $this->assertEquals($returned, $this->getExpectedFileContents('bc/default.html'));
- }
-
- public function testCanRenderPartialFromServiceAlias(): void
- {
- $this->_helper->setPartial('bc.phtml');
- $this->_helper->setServiceLocator($this->serviceManager);
-
- $returned = $this->_helper->renderPartial('Navigation');
- $this->assertEquals($returned, $this->getExpectedFileContents('bc/partial.html'));
- }
-
- public function testHelperEntryPointWithoutAnyParams(): void
- {
- $returned = $this->_helper->__invoke();
- $this->assertEquals($this->_helper, $returned);
- $this->assertEquals($this->nav1, $returned->getContainer());
- }
-
- public function testHelperEntryPointWithContainerParam(): void
- {
- $returned = $this->_helper->__invoke($this->nav2);
- $this->assertEquals($this->_helper, $returned);
- $this->assertEquals($this->nav2, $returned->getContainer());
- }
-
- public function testHelperEntryPointWithContainerStringParam(): void
- {
- $this->_helper->setServiceLocator($this->serviceManager);
-
- $returned = $this->_helper->__invoke('nav1');
- $this->assertEquals($this->_helper, $returned);
- $this->assertEquals($this->nav1, $returned->getContainer());
- }
-
- public function testNullOutContainer(): void
- {
- $old = $this->_helper->getContainer();
- $this->_helper->setContainer();
- $new = $this->_helper->getContainer();
-
- $this->assertNotEquals($old, $new);
- }
-
- public function testSetSeparator(): void
- {
- $this->_helper->setSeparator('foo');
-
- $expected = $this->getExpectedFileContents('bc/separator.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testSetMaxDepth(): void
- {
- $this->_helper->setMaxDepth(1);
-
- $expected = $this->getExpectedFileContents('bc/maxdepth.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testSetMinDepth(): void
- {
- $this->_helper->setMinDepth(1);
-
- $expected = '';
- $this->assertEquals($expected, $this->_helper->render($this->nav2));
- }
-
- public function testLinkLastElement(): void
- {
- $this->_helper->setLinkLast(true);
-
- $expected = $this->getExpectedFileContents('bc/linklast.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testSetIndent(): void
- {
- $this->_helper->setIndent(8);
-
- $expected = ' _helper->render(), 0, strlen($expected));
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testRenderSuppliedContainerWithoutInterfering(): void
- {
- $this->_helper->setMinDepth(0);
-
- $rendered1 = $this->getExpectedFileContents('bc/default.html');
- $rendered2 = 'Site 2 ';
-
- $expected = [
- 'registered' => $rendered1,
- 'supplied' => $rendered2,
- 'registered_again' => $rendered1,
- ];
-
- $actual = [
- 'registered' => $this->_helper->render(),
- 'supplied' => $this->_helper->render($this->nav2),
- 'registered_again' => $this->_helper->render(),
- ];
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testUseAclResourceFromPages(): void
- {
- $acl = $this->getAcl();
- $this->_helper->setAcl($acl['acl']);
- $this->_helper->setRole($acl['role']);
-
- $expected = $this->getExpectedFileContents('bc/acl.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testTranslationUsingLaminasTranslate(): void
- {
- if (! extension_loaded('intl')) {
- $this->markTestSkipped('ext/intl not enabled');
- }
-
- $this->_helper->setTranslator($this->getTranslator());
-
- $expected = $this->getExpectedFileContents('bc/translated.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testTranslationUsingLaminasTranslateAndCustomTextDomain(): void
- {
- if (! extension_loaded('intl')) {
- $this->markTestSkipped('ext/intl not enabled');
- }
-
- $this->_helper->setTranslator($this->getTranslatorWithTextDomain());
-
- $expected = $this->getExpectedFileContents('bc/textdomain.html');
- $test = $this->_helper->render($this->nav3);
-
- $this->assertEquals(trim($expected), trim($test));
- }
-
- public function testTranslationUsingLaminasTranslateAdapter(): void
- {
- if (! extension_loaded('intl')) {
- $this->markTestSkipped('ext/intl not enabled');
- }
-
- $translator = $this->getTranslator();
- $this->_helper->setTranslator($translator);
-
- $expected = $this->getExpectedFileContents('bc/translated.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testDisablingTranslation(): void
- {
- $translator = $this->getTranslator();
- $this->_helper->setTranslator($translator);
- $this->_helper->setTranslatorEnabled(false);
-
- $expected = $this->getExpectedFileContents('bc/default.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testRenderingPartial(): void
- {
- $this->_helper->setPartial('bc.phtml');
-
- $expected = $this->getExpectedFileContents('bc/partial.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testRenderingPartialWithSeparator(): void
- {
- $this->_helper->setPartial('bc_separator.phtml')->setSeparator(' / ');
-
- $expected = trim($this->getExpectedFileContents('bc/partialwithseparator.html'));
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testRenderingPartialBySpecifyingAnArrayAsPartial(): void
- {
- $this->_helper->setPartial(['bc.phtml', 'application']);
-
- $expected = $this->getExpectedFileContents('bc/partial.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testRenderingPartialShouldFailOnInvalidPartialArray(): void
- {
- $this->_helper->setPartial(['bc.phtml']);
- $this->expectException(InvalidArgumentException::class);
- $this->_helper->render();
- }
-
- public function testRenderingPartialWithParams(): void
- {
- $this->_helper->setPartial('bc_with_partial_params.phtml')->setSeparator(' / ');
- $expected = $this->getExpectedFileContents('bc/partial_with_params.html');
- $actual = $this->_helper->renderPartialWithParams(['variable' => 'test value']);
- $this->assertEquals($expected, $actual);
- }
-
- public function testLastBreadcrumbShouldBeEscaped(): void
- {
- $container = new Navigation([
- [
- 'label' => 'Live & Learn',
- 'uri' => '#',
- 'active' => true,
- ],
- ]);
-
- $expected = 'Live & Learn ';
- $actual = $this->_helper->setMinDepth(0)->render($container);
-
- $this->assertEquals($expected, $actual);
- }
-}
diff --git a/test/Helper/Navigation/LinksTest.php b/test/Helper/Navigation/LinksTest.php
deleted file mode 100644
index dad70dd94..000000000
--- a/test/Helper/Navigation/LinksTest.php
+++ /dev/null
@@ -1,732 +0,0 @@
-_helper = new Navigation\Links();
- parent::setUp();
-
- // doctype fix (someone forgot to clean up after their unit tests)
- $renderer = $this->_helper->getView();
- assert($renderer instanceof PhpRenderer);
- $helper = $renderer->plugin(Doctype::class);
- $this->doctypeHelper = $helper;
- $this->doctypeHelper->setDoctype(
- Doctype::HTML4_LOOSE
- );
-
- // disable all active pages
- foreach ($this->_helper->findAllByActive(true) as $page) {
- $page->active = false;
- }
- }
-
- public function testCanRenderFromServiceAlias(): void
- {
- $this->_helper->setServiceLocator($this->serviceManager);
-
- $returned = $this->_helper->render('Navigation');
- $this->assertEquals($returned, $this->getExpectedFileContents('links/default.html'));
- }
-
- public function testHelperEntryPointWithoutAnyParams(): void
- {
- $returned = $this->_helper->__invoke();
- $this->assertEquals($this->_helper, $returned);
- $this->assertEquals($this->nav1, $returned->getContainer());
- }
-
- public function testHelperEntryPointWithContainerParam(): void
- {
- $returned = $this->_helper->__invoke($this->nav2);
- $this->assertEquals($this->_helper, $returned);
- $this->assertEquals($this->nav2, $returned->getContainer());
- }
-
- public function testDoNotRenderIfNoPageIsActive(): void
- {
- $this->assertEquals('', $this->_helper->render());
- }
-
- public function testDetectRelationFromStringPropertyOfActivePage(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2');
- $active->addRel('example', 'http://www.example.com/');
- $found = $this->_helper->findRelation($active, 'rel', 'example');
-
- $expected = [
- 'type' => UriPage::class,
- 'href' => 'http://www.example.com/',
- 'label' => null,
- ];
-
- $actual = [
- 'type' => $found !== null ? $found::class : self::class,
- 'href' => $found->getHref(),
- 'label' => $found->getLabel(),
- ];
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testDetectRelationFromPageInstancePropertyOfActivePage(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2');
- $active->addRel('example', AbstractPage::factory([
- 'uri' => 'http://www.example.com/',
- 'label' => 'An example page',
- ]));
- $found = $this->_helper->findRelExample($active);
-
- $expected = [
- 'type' => UriPage::class,
- 'href' => 'http://www.example.com/',
- 'label' => 'An example page',
- ];
-
- $actual = [
- 'type' => $found::class,
- 'href' => $found->getHref(),
- 'label' => $found->getLabel(),
- ];
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testDetectRelationFromArrayPropertyOfActivePage(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2');
- $active->addRel('example', [
- 'uri' => 'http://www.example.com/',
- 'label' => 'An example page',
- ]);
- $found = $this->_helper->findRelExample($active);
-
- $expected = [
- 'type' => UriPage::class,
- 'href' => 'http://www.example.com/',
- 'label' => 'An example page',
- ];
-
- $actual = [
- 'type' => $found::class,
- 'href' => $found->getHref(),
- 'label' => $found->getLabel(),
- ];
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testDetectRelationFromArrayObjectInstancePropertyOfActivePage(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2');
- $active->addRel('example', new ArrayObject([
- 'uri' => 'http://www.example.com/',
- 'label' => 'An example page',
- ]));
- $found = $this->_helper->findRelExample($active);
-
- $expected = [
- 'type' => UriPage::class,
- 'href' => 'http://www.example.com/',
- 'label' => 'An example page',
- ];
-
- $actual = [
- 'type' => $found::class,
- 'href' => $found->getHref(),
- 'label' => $found->getLabel(),
- ];
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testDetectMultipleRelationsFromArrayPropertyOfActivePage(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2');
-
- $active->addRel('alternate', [
- [
- 'label' => 'foo',
- 'uri' => 'bar',
- ],
- [
- 'label' => 'baz',
- 'uri' => 'bat',
- ],
- ]);
-
- $found = $this->_helper->findRelAlternate($active);
-
- $expected = ['type' => 'array', 'count' => 2];
- $actual = ['type' => gettype($found), 'count' => count($found)];
- $this->assertEquals($expected, $actual);
- }
-
- public function testDetectMultipleRelationsFromArrayObjectPropertyOfActivePage(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2');
-
- $active->addRel('alternate', new ArrayObject([
- [
- 'label' => 'foo',
- 'uri' => 'bar',
- ],
- [
- 'label' => 'baz',
- 'uri' => 'bat',
- ],
- ]));
-
- $found = $this->_helper->findRelAlternate($active);
-
- $expected = ['type' => 'array', 'count' => 2];
- $actual = ['type' => gettype($found), 'count' => count($found)];
- $this->assertEquals($expected, $actual);
- }
-
- public function testExtractingRelationsFromPageProperties(): void
- {
- $types = [
- 'alternate',
- 'stylesheet',
- 'start',
- 'next',
- 'prev',
- 'contents',
- 'index',
- 'glossary',
- 'copyright',
- 'chapter',
- 'section',
- 'subsection',
- 'appendix',
- 'help',
- 'bookmark',
- ];
-
- $samplePage = AbstractPage::factory([
- 'label' => 'An example page',
- 'uri' => 'http://www.example.com/',
- ]);
-
- $active = $this->_helper->findOneByLabel('Page 2');
- $expected = [];
- $actual = [];
-
- foreach ($types as $type) {
- $active->addRel($type, $samplePage);
- $found = $this->_helper->findRelation($active, 'rel', $type);
-
- $expected[$type] = $samplePage->getLabel();
- $actual[$type] = $found->getLabel();
-
- $active->removeRel($type);
- }
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testFindStartPageByTraversal(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.1');
- $expected = 'Home';
- $actual = $this->_helper->findRelStart($active)->getLabel();
- $this->assertEquals($expected, $actual);
- }
-
- public function testDoNotFindStartWhenGivenPageIsTheFirstPage(): void
- {
- $active = $this->_helper->findOneByLabel('Home');
- $actual = $this->_helper->findRelStart($active);
- $this->assertNull($actual, 'Should not find any start page');
- }
-
- public function testFindNextPageByTraversalShouldFindChildPage(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2');
- $expected = 'Page 2.1';
- $actual = $this->_helper->findRelNext($active)->getLabel();
- $this->assertEquals($expected, $actual);
- }
-
- public function testFindNextPageByTraversalShouldFindSiblingPage(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.1');
- $expected = 'Page 2.2';
- $actual = $this->_helper->findRelNext($active)->getLabel();
- $this->assertEquals($expected, $actual);
- }
-
- public function testFindNextPageByTraversalShouldWrap(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.2.2');
- $expected = 'Page 2.3';
- $actual = $this->_helper->findRelNext($active)->getLabel();
- $this->assertEquals($expected, $actual);
- }
-
- public function testFindPrevPageByTraversalShouldFindParentPage(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.1');
- $expected = 'Page 2';
- $actual = $this->_helper->findRelPrev($active)->getLabel();
- $this->assertEquals($expected, $actual);
- }
-
- public function testFindPrevPageByTraversalShouldFindSiblingPage(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.2');
- $expected = 'Page 2.1';
- $actual = $this->_helper->findRelPrev($active)->getLabel();
- $this->assertEquals($expected, $actual);
- }
-
- public function testFindPrevPageByTraversalShouldWrap(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.3');
- $expected = 'Page 2.2.2';
- $actual = $this->_helper->findRelPrev($active)->getLabel();
- $this->assertEquals($expected, $actual);
- }
-
- public function testShouldFindChaptersFromFirstLevelOfPagesInContainer(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.3');
- $found = $this->_helper->findRelChapter($active);
-
- $expected = ['Page 1', 'Page 2', 'Page 3', 'Zym'];
- $actual = [];
- foreach ($found as $page) {
- $actual[] = $page->getLabel();
- }
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testFindingChaptersShouldExcludeSelfIfChapter(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2');
- $found = $this->_helper->findRelChapter($active);
-
- $expected = ['Page 1', 'Page 3', 'Zym'];
- $actual = [];
- foreach ($found as $page) {
- $actual[] = $page->getLabel();
- }
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testFindSectionsWhenActiveChapterPage(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2');
- $found = $this->_helper->findRelSection($active);
- $expected = ['Page 2.1', 'Page 2.2', 'Page 2.3'];
- $actual = [];
- foreach ($found as $page) {
- $actual[] = $page->getLabel();
- }
- $this->assertEquals($expected, $actual);
- }
-
- public function testDoNotFindSectionsWhenActivePageIsASection(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.2');
- $found = $this->_helper->findRelSection($active);
- $this->assertNull($found);
- }
-
- public function testDoNotFindSectionsWhenActivePageIsASubsection(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.2.1');
- $found = $this->_helper->findRelation($active, 'rel', 'section');
- $this->assertNull($found);
- }
-
- public function testFindSubsectionWhenActivePageIsSection(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.2');
- $found = $this->_helper->findRelSubsection($active);
-
- $expected = ['Page 2.2.1', 'Page 2.2.2'];
- $actual = [];
- foreach ($found as $page) {
- $actual[] = $page->getLabel();
- }
- $this->assertEquals($expected, $actual);
- }
-
- public function testDoNotFindSubsectionsWhenActivePageIsASubSubsection(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.2.1');
- $found = $this->_helper->findRelSubsection($active);
- $this->assertNull($found);
- }
-
- public function testDoNotFindSubsectionsWhenActivePageIsAChapter(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2');
- $found = $this->_helper->findRelSubsection($active);
- $this->assertNull($found);
- }
-
- public function testFindRevSectionWhenPageIsSection(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.2');
- $found = $this->_helper->findRevSection($active);
- $this->assertEquals('Page 2', $found->getLabel());
- }
-
- public function testFindRevSubsectionWhenPageIsSubsection(): void
- {
- $active = $this->_helper->findOneByLabel('Page 2.2.1');
- $found = $this->_helper->findRevSubsection($active);
- $this->assertEquals('Page 2.2', $found->getLabel());
- }
-
- public function testAclFiltersAwayPagesFromPageProperty(): void
- {
- $acl = new Acl\Acl();
- $acl->addRole(new Role\GenericRole('member'));
- $acl->addRole(new Role\GenericRole('admin'));
- $acl->addResource(new Resource\GenericResource('protected'));
- $acl->allow('admin', 'protected');
- $this->_helper->setAcl($acl);
- $this->_helper->setRole($acl->getRole('member'));
-
- $samplePage = AbstractPage::factory([
- 'label' => 'An example page',
- 'uri' => 'http://www.example.com/',
- 'resource' => 'protected',
- ]);
-
- $active = $this->_helper->findOneByLabel('Home');
- $expected = [
- 'alternate' => false,
- 'stylesheet' => false,
- 'start' => false,
- 'next' => 'Page 1',
- 'prev' => false,
- 'contents' => false,
- 'index' => false,
- 'glossary' => false,
- 'copyright' => false,
- 'chapter' => 'array(4)',
- 'section' => false,
- 'subsection' => false,
- 'appendix' => false,
- 'help' => false,
- 'bookmark' => false,
- ];
- $actual = [];
-
- foreach ($expected as $type => $discard) {
- $active->addRel($type, $samplePage);
-
- $found = $this->_helper->findRelation($active, 'rel', $type);
- if (null === $found) {
- $actual[$type] = false;
- } elseif (is_array($found)) {
- $actual[$type] = 'array(' . count($found) . ')';
- } else {
- $actual[$type] = $found->getLabel();
- }
- }
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testAclFiltersAwayPagesFromContainerSearch(): void
- {
- $acl = new Acl\Acl();
- $acl->addRole(new Role\GenericRole('member'));
- $acl->addRole(new Role\GenericRole('admin'));
- $acl->addResource(new Resource\GenericResource('protected'));
- $acl->allow('admin', 'protected');
- $this->_helper->setAcl($acl);
- $this->_helper->setRole($acl->getRole('member'));
-
- $this->_helper->getContainer();
- $container = $this->_helper->getContainer();
- $iterator = new RecursiveIteratorIterator(
- $container,
- RecursiveIteratorIterator::SELF_FIRST
- );
- foreach ($iterator as $page) {
- $page->resource = 'protected';
- }
- $this->_helper->setContainer($container);
-
- $this->_helper->findOneByLabel('Home');
- $search = [
- 'start' => 'Page 1',
- 'next' => 'Page 1',
- 'prev' => 'Page 1.1',
- 'chapter' => 'Home',
- 'section' => 'Page 1',
- 'subsection' => 'Page 2.2',
- ];
-
- $expected = [];
- $actual = [];
-
- foreach ($search as $type => $active) {
- $expected[$type] = false;
-
- $active = $this->_helper->findOneByLabel($active);
- $found = $this->_helper->findRelation($active, 'rel', $type);
-
- if (null === $found) {
- $actual[$type] = false;
- } elseif (is_array($found)) {
- $actual[$type] = 'array(' . count($found) . ')';
- } else {
- $actual[$type] = $found->getLabel();
- }
- }
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testFindRelationMustSpecifyRelOrRev(): void
- {
- $active = $this->_helper->findOneByLabel('Home');
- try {
- $this->_helper->findRelation($active, 'foo', 'bar');
- $this->fail('An invalid value was given, but a '
- . 'Laminas\View\Exception\InvalidArgumentException was not thrown');
- } catch (View\Exception\ExceptionInterface $e) {
- $this->assertStringContainsString('Invalid argument: $rel', $e->getMessage());
- }
- }
-
- public function testRenderLinkMustSpecifyRelOrRev(): void
- {
- $active = $this->_helper->findOneByLabel('Home');
- try {
- $this->_helper->renderLink($active, 'foo', 'bar');
- $this->fail('An invalid value was given, but a '
- . 'Laminas\View\Exception\InvalidArgumentException was not thrown');
- } catch (View\Exception\ExceptionInterface $e) {
- $this->assertStringContainsString('Invalid relation attribute', $e->getMessage());
- }
- }
-
- public function testFindAllRelations(): void
- {
- $expectedRelations = [
- 'alternate' => ['Forced page'],
- 'stylesheet' => ['Forced page'],
- 'start' => ['Forced page'],
- 'next' => ['Forced page'],
- 'prev' => ['Forced page'],
- 'contents' => ['Forced page'],
- 'index' => ['Forced page'],
- 'glossary' => ['Forced page'],
- 'copyright' => ['Forced page'],
- 'chapter' => ['Forced page'],
- 'section' => ['Forced page'],
- 'subsection' => ['Forced page'],
- 'appendix' => ['Forced page'],
- 'help' => ['Forced page'],
- 'bookmark' => ['Forced page'],
- 'canonical' => ['Forced page'],
- 'home' => ['Forced page'],
- ];
-
- // build expected result
- $expected = [
- 'rel' => $expectedRelations,
- 'rev' => $expectedRelations,
- ];
-
- // find active page and create page to use for relations
- $active = $this->_helper->findOneByLabel('Page 1');
- $forcedRelation = new UriPage([
- 'label' => 'Forced page',
- 'uri' => '#',
- ]);
-
- // add relations to active page
- foreach ($expectedRelations as $type => $discard) {
- $active->addRel($type, $forcedRelation);
- $active->addRev($type, $forcedRelation);
- }
-
- // build actual result
- $actual = $this->_helper->findAllRelations($active);
- foreach ($actual as $attrib => $relations) {
- foreach ($relations as $type => $pages) {
- foreach ($pages as $key => $page) {
- $actual[$attrib][$type][$key] = $page->getLabel();
- }
- }
- }
-
- $this->assertEquals($expected, $actual);
- }
-
- // @codingStandardsIgnoreStart
- /**
- * @return string[]
- *
- * @psalm-return array{1: 'alternate', 2: 'stylesheet', 4: 'start', 8: 'next', 16: 'prev', 32: 'contents', 64: 'index', 128: 'glossary', 512: 'chapter', 1024: 'section', 2048: 'subsection', 4096: 'appendix', 8192: 'help', 16384: 'bookmark', 32768: 'canonical'}
- */
- private function _getFlags(): array
- {
- // @codingStandardsIgnoreEnd
- return [
- Navigation\Links::RENDER_ALTERNATE => 'alternate',
- Navigation\Links::RENDER_STYLESHEET => 'stylesheet',
- Navigation\Links::RENDER_START => 'start',
- Navigation\Links::RENDER_NEXT => 'next',
- Navigation\Links::RENDER_PREV => 'prev',
- Navigation\Links::RENDER_CONTENTS => 'contents',
- Navigation\Links::RENDER_INDEX => 'index',
- Navigation\Links::RENDER_GLOSSARY => 'glossary',
- Navigation\Links::RENDER_CHAPTER => 'chapter',
- Navigation\Links::RENDER_SECTION => 'section',
- Navigation\Links::RENDER_SUBSECTION => 'subsection',
- Navigation\Links::RENDER_APPENDIX => 'appendix',
- Navigation\Links::RENDER_HELP => 'help',
- Navigation\Links::RENDER_BOOKMARK => 'bookmark',
- Navigation\Links::RENDER_CUSTOM => 'canonical',
- ];
- }
-
- public function testSingleRenderFlags(): void
- {
- $active = $this->_helper->findOneByLabel('Home');
- $active->active = true;
-
- $expected = [];
- $actual = [];
-
- // build expected and actual result
- foreach ($this->_getFlags() as $newFlag => $type) {
- // add forced relation
- $active->addRel($type, 'http://www.example.com/');
- $active->addRev($type, 'http://www.example.com/');
-
- $this->_helper->setRenderFlag($newFlag);
- $expectedOutput = ' ' . PHP_EOL
- . ' ';
- $actualOutput = $this->_helper->render();
-
- $expected[$type] = $expectedOutput;
- $actual[$type] = $actualOutput;
-
- // remove forced relation
- $active->removeRel($type);
- $active->removeRev($type);
- }
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testRenderFlagBitwiseOr(): void
- {
- $newFlag = Navigation\Links::RENDER_NEXT |
- Navigation\Links::RENDER_PREV;
- $this->_helper->setRenderFlag($newFlag);
- $active = $this->_helper->findOneByLabel('Page 1.1');
- $active->active = true;
-
- // test data
- $expected = ' '
- . PHP_EOL
- . ' ';
- $actual = $this->_helper->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testIndenting(): void
- {
- $active = $this->_helper->findOneByLabel('Page 1.1');
- $newFlag = Navigation\Links::RENDER_NEXT |
- Navigation\Links::RENDER_PREV;
- $this->_helper->setRenderFlag($newFlag);
- $this->_helper->setIndent(' ');
- $active->active = true;
-
- // build expected and actual result
- $expected = ' '
- . PHP_EOL
- . ' ';
- $actual = $this->_helper->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetMaxDepth(): void
- {
- $this->_helper->setMaxDepth(1);
- $this->_helper->findOneByLabel('Page 2.3.3')->setActive(); // level 2
- $flag = Navigation\Links::RENDER_NEXT;
-
- $expected = ' ';
- $actual = $this->_helper->setRenderFlag($flag)->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetMinDepth(): void
- {
- $this->_helper->setMinDepth(2);
- $this->_helper->findOneByLabel('Page 2.3')->setActive(); // level 1
- $flag = Navigation\Links::RENDER_NEXT;
-
- $expected = '';
- $actual = $this->_helper->setRenderFlag($flag)->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- /** @inheritDoc */
- protected function getExpectedFileContents(string $filename): string
- {
- return str_replace("\n", PHP_EOL, parent::getExpectedFileContents($filename));
- }
-}
diff --git a/test/Helper/Navigation/MenuTest.php b/test/Helper/Navigation/MenuTest.php
deleted file mode 100644
index 0d8994317..000000000
--- a/test/Helper/Navigation/MenuTest.php
+++ /dev/null
@@ -1,616 +0,0 @@
-_helper = new Menu();
- parent::setUp();
- }
-
- public function testCanRenderMenuFromServiceAlias(): void
- {
- $this->_helper->setServiceLocator($this->serviceManager);
-
- $returned = $this->_helper->renderMenu('Navigation');
- $this->assertEquals($returned, $this->getExpectedFileContents('menu/default1.html'));
- }
-
- public function testCanRenderPartialFromServiceAlias(): void
- {
- $this->_helper->setPartial('menu.phtml');
- $this->_helper->setServiceLocator($this->serviceManager);
-
- $returned = $this->_helper->renderPartial('Navigation');
- $this->assertEquals($returned, $this->getExpectedFileContents('menu/partial.html'));
- }
-
- public function testHelperEntryPointWithoutAnyParams(): void
- {
- $returned = $this->_helper->__invoke();
- $this->assertEquals($this->_helper, $returned);
- $this->assertEquals($this->nav1, $returned->getContainer());
- }
-
- public function testHelperEntryPointWithContainerParam(): void
- {
- $returned = $this->_helper->__invoke($this->nav2);
- $this->assertEquals($this->_helper, $returned);
- $this->assertEquals($this->nav2, $returned->getContainer());
- }
-
- public function testNullingOutContainerInHelper(): void
- {
- $this->_helper->setContainer();
- $this->assertEquals(0, count($this->_helper->getContainer()));
- }
-
- public function testSetIndentAndOverrideInRenderMenu(): void
- {
- $this->_helper->setIndent(8);
-
- $expected = [
- 'indent4' => $this->getExpectedFileContents('menu/indent4.html'),
- 'indent8' => $this->getExpectedFileContents('menu/indent8.html'),
- ];
-
- $renderOptions = [
- 'indent' => 4,
- ];
-
- $actual = [
- 'indent4' => rtrim($this->_helper->renderMenu(null, $renderOptions), PHP_EOL),
- 'indent8' => rtrim($this->_helper->renderMenu(), PHP_EOL),
- ];
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testRenderSuppliedContainerWithoutInterfering(): void
- {
- $rendered1 = $this->getExpectedFileContents('menu/default1.html');
- $rendered2 = $this->getExpectedFileContents('menu/default2.html');
- $expected = [
- 'registered' => $rendered1,
- 'supplied' => $rendered2,
- 'registered_again' => $rendered1,
- ];
-
- $actual = [
- 'registered' => $this->_helper->render(),
- 'supplied' => $this->_helper->render($this->nav2),
- 'registered_again' => $this->_helper->render(),
- ];
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testUseAclRoleAsString(): void
- {
- $acl = $this->getAcl();
- $this->_helper->setAcl($acl['acl']);
- $this->_helper->setRole('member');
-
- $expected = $this->getExpectedFileContents('menu/acl_string.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testFilterOutPagesBasedOnAcl(): void
- {
- $acl = $this->getAcl();
- $this->_helper->setAcl($acl['acl']);
- $this->_helper->setRole($acl['role']);
-
- $expected = $this->getExpectedFileContents('menu/acl.html');
- $actual = $this->_helper->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testDisablingAcl(): void
- {
- $acl = $this->getAcl();
- $this->_helper->setAcl($acl['acl']);
- $this->_helper->setRole($acl['role']);
- $this->_helper->setUseAcl(false);
-
- $expected = $this->getExpectedFileContents('menu/default1.html');
- $actual = $this->_helper->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testUseAnAclRoleInstanceFromAclObject(): void
- {
- $acl = $this->getAcl();
- $this->_helper->setAcl($acl['acl']);
- $this->_helper->setRole($acl['acl']->getRole('member'));
-
- $expected = $this->getExpectedFileContents('menu/acl_role_interface.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testUseConstructedAclRolesNotFromAclObject(): void
- {
- $acl = $this->getAcl();
- $this->_helper->setAcl($acl['acl']);
- $this->_helper->setRole(new GenericRole('member'));
-
- $expected = $this->getExpectedFileContents('menu/acl_role_interface.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testSetUlCssClass(): void
- {
- $this->_helper->setUlClass('My_Nav');
- $expected = $this->getExpectedFileContents('menu/css.html');
- $this->assertEquals($expected, $this->_helper->render($this->nav2));
- }
-
- public function testSetLiActiveCssClass(): void
- {
- $this->_helper->setLiActiveClass('activated');
- $expected = $this->getExpectedFileContents('menu/css2.html');
- $this->assertEquals(trim($expected), $this->_helper->render($this->nav2));
- }
-
- public function testOptionEscapeLabelsAsTrue(): void
- {
- $options = [
- 'escapeLabels' => true,
- ];
-
- $container = new Navigation($this->nav2->toArray());
- $container->addPage([
- 'label' => 'Badges 1 ',
- 'uri' => 'badges',
- ]);
-
- $expected = $this->getExpectedFileContents('menu/escapelabels_as_true.html');
- $actual = $this->_helper->renderMenu($container, $options);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOptionEscapeLabelsAsFalse(): void
- {
- $options = [
- 'escapeLabels' => false,
- ];
-
- $container = new Navigation($this->nav2->toArray());
- $container->addPage([
- 'label' => 'Badges 1 ',
- 'uri' => 'badges',
- ]);
-
- $expected = $this->getExpectedFileContents('menu/escapelabels_as_false.html');
- $actual = $this->_helper->renderMenu($container, $options);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testTranslationUsingLaminasTranslate(): void
- {
- if (! extension_loaded('intl')) {
- $this->markTestSkipped('ext/intl not enabled');
- }
-
- $translator = $this->getTranslator();
- $this->_helper->setTranslator($translator);
-
- $expected = $this->getExpectedFileContents('menu/translated.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testTranslationUsingLaminasTranslateWithTextDomain(): void
- {
- if (! extension_loaded('intl')) {
- $this->markTestSkipped('ext/intl not enabled');
- }
-
- $translator = $this->getTranslatorWithTextDomain();
- $this->_helper->setTranslator($translator);
-
- $expected = $this->getExpectedFileContents('menu/textdomain.html');
- $test = $this->_helper->render($this->nav3);
- $this->assertEquals(trim($expected), trim($test));
- }
-
- public function testTranslationUsingLaminasTranslateAdapter(): void
- {
- if (! extension_loaded('intl')) {
- $this->markTestSkipped('ext/intl not enabled');
- }
-
- $translator = $this->getTranslator();
- $this->_helper->setTranslator($translator);
-
- $expected = $this->getExpectedFileContents('menu/translated.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testDisablingTranslation(): void
- {
- $translator = $this->getTranslator();
- $this->_helper->setTranslator($translator);
- $this->_helper->setTranslatorEnabled(false);
-
- $expected = $this->getExpectedFileContents('menu/default1.html');
- $this->assertEquals($expected, $this->_helper->render());
- }
-
- public function testRenderingPartial(): void
- {
- $this->_helper->setPartial('menu.phtml');
-
- $expected = $this->getExpectedFileContents('menu/partial.html');
- $actual = $this->_helper->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testRenderingPartialBySpecifyingAnArrayAsPartial(): void
- {
- $this->_helper->setPartial(['menu.phtml', 'application']);
-
- $expected = $this->getExpectedFileContents('menu/partial.html');
- $actual = $this->_helper->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testRenderingPartialWithParams(): void
- {
- $this->_helper->setPartial(['menu_with_partial_params.phtml', 'application']);
- $expected = $this->getExpectedFileContents('menu/partial_with_params.html');
- $actual = $this->_helper->renderPartialWithParams(['variable' => 'test value']);
- $this->assertEquals($expected, $actual);
- }
-
- public function testRenderingPartialShouldFailOnInvalidPartialArray(): void
- {
- $this->_helper->setPartial(['menu.phtml']);
- $this->expectException(InvalidArgumentException::class);
- $this->_helper->render();
- }
-
- public function testSetMaxDepth(): void
- {
- $this->_helper->setMaxDepth(1);
-
- $expected = $this->getExpectedFileContents('menu/maxdepth.html');
- $actual = $this->_helper->renderMenu();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetMinDepth(): void
- {
- $this->_helper->setMinDepth(1);
-
- $expected = $this->getExpectedFileContents('menu/mindepth.html');
- $actual = $this->_helper->renderMenu();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetBothDepts(): void
- {
- $this->_helper->setMinDepth(1)->setMaxDepth(2);
-
- $expected = $this->getExpectedFileContents('menu/bothdepts.html');
- $actual = $this->_helper->renderMenu();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetOnlyActiveBranch(): void
- {
- $this->_helper->setOnlyActiveBranch(true);
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch.html');
- $actual = $this->_helper->renderMenu();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetRenderParents(): void
- {
- $this->_helper->setOnlyActiveBranch(true)->setRenderParents(false);
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_noparents.html');
- $actual = $this->_helper->renderMenu();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetOnlyActiveBranchAndMinDepth(): void
- {
- $this->_helper->setOnlyActiveBranch()->setMinDepth(1);
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_mindepth.html');
- $actual = $this->_helper->renderMenu();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOnlyActiveBranchAndMaxDepth(): void
- {
- $this->_helper->setOnlyActiveBranch()->setMaxDepth(2);
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_maxdepth.html');
- $actual = $this->_helper->renderMenu();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOnlyActiveBranchAndBothDepthsSpecified(): void
- {
- $this->_helper->setOnlyActiveBranch()->setMinDepth(1)->setMaxDepth(2);
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_bothdepts.html');
- $actual = $this->_helper->renderMenu();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOnlyActiveBranchNoParentsAndBothDepthsSpecified(): void
- {
- $this->_helper->setOnlyActiveBranch()
- ->setMinDepth(1)
- ->setMaxDepth(2)
- ->setRenderParents(false);
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_np_bd.html');
- $actual = $this->_helper->renderMenu();
-
- $this->assertEquals($expected, $actual);
- }
-
- // @codingStandardsIgnoreStart
- private function _setActive(string $label): void
- {
- // @codingStandardsIgnoreEnd
- $container = $this->_helper->getContainer();
-
- foreach ($container->findAllByActive(true) as $page) {
- $page->setActive(false);
- }
-
- if ($p = $container->findOneByLabel($label)) {
- $p->setActive(true);
- }
- }
-
- public function testOnlyActiveBranchNoParentsActiveOneBelowMinDepth(): void
- {
- $this->_setActive('Page 2');
-
- $this->_helper->setOnlyActiveBranch()
- ->setMinDepth(1)
- ->setMaxDepth(1)
- ->setRenderParents(false);
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_np_bd2.html');
- $actual = $this->_helper->renderMenu();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testRenderSubMenuShouldOverrideOptions(): void
- {
- $this->_helper->setOnlyActiveBranch(false)
- ->setMinDepth(1)
- ->setMaxDepth(2)
- ->setRenderParents(true);
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_noparents.html');
- $actual = $this->_helper->renderSubMenu();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOptionMaxDepth(): void
- {
- $options = [
- 'maxDepth' => 1,
- ];
-
- $expected = $this->getExpectedFileContents('menu/maxdepth.html');
- $actual = $this->_helper->renderMenu(null, $options);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOptionMinDepth(): void
- {
- $options = [
- 'minDepth' => 1,
- ];
-
- $expected = $this->getExpectedFileContents('menu/mindepth.html');
- $actual = $this->_helper->renderMenu(null, $options);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOptionBothDepts(): void
- {
- $options = [
- 'minDepth' => 1,
- 'maxDepth' => 2,
- ];
-
- $expected = $this->getExpectedFileContents('menu/bothdepts.html');
- $actual = $this->_helper->renderMenu(null, $options);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOptionOnlyActiveBranch(): void
- {
- $options = [
- 'onlyActiveBranch' => true,
- ];
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch.html');
- $actual = $this->_helper->renderMenu(null, $options);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOptionOnlyActiveBranchNoParents(): void
- {
- $options = [
- 'onlyActiveBranch' => true,
- 'renderParents' => false,
- ];
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_noparents.html');
- $actual = $this->_helper->renderMenu(null, $options);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOptionOnlyActiveBranchAndMinDepth(): void
- {
- $options = [
- 'minDepth' => 1,
- 'onlyActiveBranch' => true,
- ];
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_mindepth.html');
- $actual = $this->_helper->renderMenu(null, $options);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOptionOnlyActiveBranchAndMaxDepth(): void
- {
- $options = [
- 'maxDepth' => 2,
- 'onlyActiveBranch' => true,
- ];
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_maxdepth.html');
- $actual = $this->_helper->renderMenu(null, $options);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOptionOnlyActiveBranchAndBothDepthsSpecified(): void
- {
- $options = [
- 'minDepth' => 1,
- 'maxDepth' => 2,
- 'onlyActiveBranch' => true,
- ];
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_bothdepts.html');
- $actual = $this->_helper->renderMenu(null, $options);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testOptionOnlyActiveBranchNoParentsAndBothDepthsSpecified(): void
- {
- $options = [
- 'minDepth' => 2,
- 'maxDepth' => 2,
- 'onlyActiveBranch' => true,
- 'renderParents' => false,
- ];
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_np_bd.html');
- $actual = $this->_helper->renderMenu(null, $options);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testRenderingWithoutPageClassToLi(): void
- {
- $container = new Navigation($this->nav2->toArray());
- $container->addPage([
- 'label' => 'Class test',
- 'uri' => 'test',
- 'class' => 'foobar',
- ]);
-
- $expected = $this->getExpectedFileContents('menu/addclasstolistitem_as_false.html');
- $actual = $this->_helper->renderMenu($container);
-
- $this->assertEquals(trim($expected), trim($actual));
- }
-
- public function testRenderingWithPageClassToLi(): void
- {
- $options = [
- 'addClassToListItem' => true,
- ];
-
- $container = new Navigation($this->nav2->toArray());
- $container->addPage([
- 'label' => 'Class test',
- 'uri' => 'test',
- 'class' => 'foobar',
- ]);
-
- $expected = $this->getExpectedFileContents('menu/addclasstolistitem_as_true.html');
- $actual = $this->_helper->renderMenu($container, $options);
-
- $this->assertEquals(trim($expected), trim($actual));
- }
-
- public function testRenderDeepestMenuWithPageClassToLi(): void
- {
- $options = [
- 'addClassToListItem' => true,
- 'onlyActiveBranch' => true,
- 'renderParents' => false,
- ];
-
- /** @var array[] $pages */
- $pages = $this->nav2->toArray();
- $pages[1]['class'] = 'foobar';
- $container = new Navigation($pages);
-
- $expected = $this->getExpectedFileContents('menu/onlyactivebranch_addclasstolistitem.html');
- $actual = $this->_helper->renderMenu($container, $options);
-
- $this->assertEquals(trim($expected), trim($actual));
- }
-
- /** @inheritDoc */
- protected function getExpectedFileContents(string $filename): string
- {
- return str_replace("\n", PHP_EOL, parent::getExpectedFileContents($filename));
- }
-}
diff --git a/test/Helper/Navigation/NavigationTest.php b/test/Helper/Navigation/NavigationTest.php
deleted file mode 100644
index 0144a7021..000000000
--- a/test/Helper/Navigation/NavigationTest.php
+++ /dev/null
@@ -1,598 +0,0 @@
-_helper = new Navigation();
- parent::setUp();
- }
-
- public function testHelperEntryPointWithoutAnyParams(): void
- {
- $returned = $this->_helper->__invoke();
- $this->assertEquals($this->_helper, $returned);
- $this->assertEquals($this->nav1, $returned->getContainer());
- }
-
- public function testHelperEntryPointWithContainerParam(): void
- {
- $returned = $this->_helper->__invoke($this->nav2);
- $this->assertEquals($this->_helper, $returned);
- $this->assertEquals($this->nav2, $returned->getContainer());
- }
-
- public function testAcceptAclShouldReturnGracefullyWithUnknownResource(): void
- {
- // setup
- $acl = $this->getAcl();
- $this->_helper->setAcl($acl['acl']);
- $this->_helper->setRole($acl['role']);
-
- $accepted = $this->_helper->accept(
- new Page\Uri([
- 'resource' => 'unknownresource',
- 'privilege' => 'someprivilege',
- ], false)
- );
-
- $this->assertEquals($accepted, false);
- }
-
- public function testShouldProxyToMenuHelperByDefault(): void
- {
- $this->_helper->setContainer($this->nav1);
- $this->_helper->setServiceLocator(new ServiceManager());
-
- // result
- $expected = $this->getExpectedFileContents('menu/default1.html');
- $actual = $this->_helper->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testHasContainer(): void
- {
- $oldContainer = $this->_helper->getContainer();
- $this->_helper->setContainer(null);
- $this->assertFalse($this->_helper->hasContainer());
- $this->_helper->setContainer($oldContainer);
- }
-
- public function testInjectingContainer(): void
- {
- // setup
- $this->_helper->setContainer($this->nav2);
- $this->_helper->setServiceLocator(new ServiceManager());
- $expected = [
- 'menu' => $this->getExpectedFileContents('menu/default2.html'),
- 'breadcrumbs' => $this->getExpectedFileContents('bc/default.html'),
- ];
- $actual = [];
-
- // result
- $actual['menu'] = $this->_helper->render();
- $this->_helper->setContainer($this->nav1);
- $actual['breadcrumbs'] = $this->_helper->breadcrumbs()->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testDisablingContainerInjection(): void
- {
- // setup
- $this->_helper->setServiceLocator(new ServiceManager());
- $this->_helper->setInjectContainer(false);
- $this->_helper->menu()->setContainer(null);
- $this->_helper->breadcrumbs()->setContainer(null);
- $this->_helper->setContainer($this->nav2);
-
- // result
- $expected = [
- 'menu' => '',
- 'breadcrumbs' => '',
- ];
- $actual = [
- 'menu' => $this->_helper->render(),
- 'breadcrumbs' => $this->_helper->breadcrumbs()->render(),
- ];
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testMultipleNavigationsAndOneMenuDisplayedTwoTimes(): void
- {
- $this->_helper->setServiceLocator(new ServiceManager());
- $expected = $this->_helper->setContainer($this->nav1)->menu()->getContainer();
- $this->_helper->setContainer($this->nav2)->menu()->getContainer();
- $actual = $this->_helper->setContainer($this->nav1)->menu()->getContainer();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testServiceManagerIsUsedToRetrieveContainer(): void
- {
- $container = new Container();
- $serviceManager = new ServiceManager();
- $serviceManager->setService('navigation', $container);
-
- new View\HelperPluginManager($serviceManager);
-
- $this->_helper->setServiceLocator($serviceManager);
- $this->_helper->setContainer('navigation');
-
- $expected = $this->_helper->getContainer();
- $actual = $container;
- $this->assertEquals($expected, $actual);
- }
-
- public function testInjectingAcl(): void
- {
- // setup
- $acl = $this->getAcl();
- $this->_helper->setAcl($acl['acl']);
- $this->_helper->setRole($acl['role']);
- $this->_helper->setServiceLocator(new ServiceManager());
-
- $expected = $this->getExpectedFileContents('menu/acl.html');
- $actual = $this->_helper->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testDisablingAclInjection(): void
- {
- // setup
- $acl = $this->getAcl();
- $this->_helper->setAcl($acl['acl']);
- $this->_helper->setRole($acl['role']);
- $this->_helper->setInjectAcl(false);
- $this->_helper->setServiceLocator(new ServiceManager());
-
- $expected = $this->getExpectedFileContents('menu/default1.html');
- $actual = $this->_helper->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testInjectingTranslator(): void
- {
- if (! extension_loaded('intl')) {
- $this->markTestSkipped('ext/intl not enabled');
- }
-
- $this->_helper->setTranslator($this->getTranslator());
- $this->_helper->setServiceLocator(new ServiceManager());
-
- $expected = $this->getExpectedFileContents('menu/translated.html');
- $actual = $this->_helper->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testDisablingTranslatorInjection(): void
- {
- $this->_helper->setTranslator($this->getTranslator());
- $this->_helper->setInjectTranslator(false);
- $this->_helper->setServiceLocator(new ServiceManager());
-
- $expected = $this->getExpectedFileContents('menu/default1.html');
- $actual = $this->_helper->render();
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testTranslatorMethods(): void
- {
- $translatorMock = $this->createMock(Translator::class);
- $this->_helper->setTranslator($translatorMock, 'foo');
-
- $this->assertEquals($translatorMock, $this->_helper->getTranslator());
- $this->assertEquals('foo', $this->_helper->getTranslatorTextDomain());
- $this->assertTrue($this->_helper->hasTranslator());
- $this->assertTrue($this->_helper->isTranslatorEnabled());
-
- $this->_helper->setTranslatorEnabled(false);
- $this->assertFalse($this->_helper->isTranslatorEnabled());
- }
-
- public function testSpecifyingDefaultProxy(): void
- {
- $expected = [
- 'breadcrumbs' => $this->getExpectedFileContents('bc/default.html'),
- 'menu' => $this->getExpectedFileContents('menu/default1.html'),
- ];
- $actual = [];
-
- // result
- $this->_helper->setServiceLocator(new ServiceManager());
- $this->_helper->setDefaultProxy('breadcrumbs');
- $actual['breadcrumbs'] = $this->_helper->render($this->nav1);
- $this->_helper->setDefaultProxy('menu');
- $actual['menu'] = $this->_helper->render($this->nav1);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testGetAclReturnsNullIfNoAclInstance(): void
- {
- $this->assertNull($this->_helper->getAcl());
- }
-
- public function testGetAclReturnsAclInstanceSetWithSetAcl(): void
- {
- $acl = new Acl\Acl();
- $this->_helper->setAcl($acl);
- $this->assertEquals($acl, $this->_helper->getAcl());
- }
-
- public function testGetAclReturnsAclInstanceSetWithSetDefaultAcl(): void
- {
- $acl = new Acl\Acl();
- Navigation\AbstractHelper::setDefaultAcl($acl);
- $actual = $this->_helper->getAcl();
- Navigation\AbstractHelper::setDefaultAcl(null);
- $this->assertEquals($acl, $actual);
- }
-
- public function testSetDefaultAclAcceptsNull(): void
- {
- $acl = new Acl\Acl();
- Navigation\AbstractHelper::setDefaultAcl($acl);
- Navigation\AbstractHelper::setDefaultAcl(null);
- $this->assertNull($this->_helper->getAcl());
- }
-
- public function testSetDefaultAclAcceptsNoParam(): void
- {
- $acl = new Acl\Acl();
- Navigation\AbstractHelper::setDefaultAcl($acl);
- Navigation\AbstractHelper::setDefaultAcl();
- $this->assertNull($this->_helper->getAcl());
- }
-
- public function testSetRoleAcceptsString(): void
- {
- $this->_helper->setRole('member');
- $this->assertEquals('member', $this->_helper->getRole());
- }
-
- public function testSetRoleAcceptsRoleInterface(): void
- {
- $role = new Role\GenericRole('member');
- $this->_helper->setRole($role);
- $this->assertEquals($role, $this->_helper->getRole());
- }
-
- public function testSetRoleAcceptsNull(): void
- {
- $this->_helper->setRole('member')->setRole(null);
- $this->assertNull($this->_helper->getRole());
- }
-
- public function testSetRoleAcceptsNoParam(): void
- {
- $this->_helper->setRole('member')->setRole();
- $this->assertNull($this->_helper->getRole());
- }
-
- public function testSetRoleThrowsExceptionWhenGivenAnInt(): void
- {
- try {
- $this->_helper->setRole(1337);
- $this->fail('An invalid argument was given, but a '
- . 'Laminas\View\Exception\InvalidArgumentException was not thrown');
- } catch (View\Exception\ExceptionInterface $e) {
- $this->assertStringContainsString('$role must be a string', $e->getMessage());
- }
- }
-
- public function testSetRoleThrowsExceptionWhenGivenAnArbitraryObject(): void
- {
- try {
- $this->_helper->setRole(new stdClass());
- $this->fail('An invalid argument was given, but a '
- . 'Laminas\View\Exception\InvalidArgumentException was not thrown');
- } catch (View\Exception\ExceptionInterface $e) {
- $this->assertStringContainsString('$role must be a string', $e->getMessage());
- }
- }
-
- public function testSetDefaultRoleAcceptsString(): void
- {
- $expected = 'member';
- Navigation\AbstractHelper::setDefaultRole($expected);
- $actual = $this->_helper->getRole();
- Navigation\AbstractHelper::setDefaultRole(null);
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetDefaultRoleAcceptsRoleInterface(): void
- {
- $expected = new Role\GenericRole('member');
- Navigation\AbstractHelper::setDefaultRole($expected);
- $actual = $this->_helper->getRole();
- Navigation\AbstractHelper::setDefaultRole(null);
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetDefaultRoleAcceptsNull(): void
- {
- Navigation\AbstractHelper::setDefaultRole(null);
- $this->assertNull($this->_helper->getRole());
- }
-
- public function testSetDefaultRoleAcceptsNoParam(): void
- {
- Navigation\AbstractHelper::setDefaultRole();
- $this->assertNull($this->_helper->getRole());
- }
-
- public function testSetDefaultRoleThrowsExceptionWhenGivenAnInt(): void
- {
- try {
- Navigation\AbstractHelper::setDefaultRole(1337);
- $this->fail('An invalid argument was given, but a '
- . 'Laminas\View\Exception\InvalidArgumentException was not thrown');
- } catch (View\Exception\ExceptionInterface $e) {
- $this->assertStringContainsString('$role must be', $e->getMessage());
- }
- }
-
- public function testSetDefaultRoleThrowsExceptionWhenGivenAnArbitraryObject(): void
- {
- try {
- Navigation\AbstractHelper::setDefaultRole(new stdClass());
- $this->fail('An invalid argument was given, but a '
- . 'Laminas\View\Exception\InvalidArgumentException was not thrown');
- } catch (View\Exception\ExceptionInterface $e) {
- $this->assertStringContainsString('$role must be', $e->getMessage());
- }
- }
-
- public function testMagicToStringShouldNotThrowException(): void
- {
- set_error_handler(function (int $code, string $message) {
- $this->errorHandlerMessage = $message;
- });
-
- $this->_helper->menu()->setPartial([1337]);
- $this->_helper->__toString();
- restore_error_handler();
-
- $this->assertStringContainsString('array must contain', $this->errorHandlerMessage);
- }
-
- public function testPageIdShouldBeNormalized(): void
- {
- $nl = PHP_EOL;
-
- $container = new Container([
- [
- 'label' => 'Page 1',
- 'id' => 'p1',
- 'uri' => 'p1',
- ],
- [
- 'label' => 'Page 2',
- 'id' => 'p2',
- 'uri' => 'p2',
- ],
- ]);
-
- $expected = '' . $nl
- . ' ' . $nl
- . ' ' . $nl
- . ' ' . $nl
- . ' ' . $nl
- . ' ' . $nl
- . ' ' . $nl
- . ' ';
-
- $this->_helper->setServiceLocator(new ServiceManager());
- $actual = $this->_helper->render($container);
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testRenderInvisibleItem(): void
- {
- $container = new Container([
- [
- 'label' => 'Page 1',
- 'id' => 'p1',
- 'uri' => 'p1',
- ],
- [
- 'label' => 'Page 2',
- 'id' => 'p2',
- 'uri' => 'p2',
- 'visible' => false,
- ],
- ]);
-
- $this->_helper->setServiceLocator(new ServiceManager());
- $render = $this->_helper->menu()->render($container);
-
- $this->assertStringNotContainsString('p2', $render);
-
- $this->_helper->menu()->setRenderInvisible();
-
- $render = $this->_helper->menu()->render($container);
-
- $this->assertStringContainsString('p2', $render);
- }
-
- public function testMultipleNavigations(): void
- {
- $sm = new ServiceManager();
- $nav1 = new Container();
- $nav2 = new Container();
- $sm->setService('nav1', $nav1);
- $sm->setService('nav2', $nav2);
-
- $helper = new Navigation();
- $helper->setServiceLocator($sm);
-
- $menu = $helper('nav1')->menu();
- $actual = spl_object_hash($nav1);
- $expected = spl_object_hash($menu->getContainer());
- $this->assertEquals($expected, $actual);
-
- $menu = $helper('nav2')->menu();
- $actual = spl_object_hash($nav2);
- $expected = spl_object_hash($menu->getContainer());
- $this->assertEquals($expected, $actual);
- }
-
- public function testMultipleNavigationsWithDifferentHelpersAndDifferentContainers(): void
- {
- $sm = new ServiceManager();
- $nav1 = new Container();
- $nav2 = new Container();
- $sm->setService('nav1', $nav1);
- $sm->setService('nav2', $nav2);
-
- $helper = new Navigation();
- $helper->setServiceLocator($sm);
-
- $menu = $helper('nav1')->menu();
- $actual = spl_object_hash($nav1);
- $expected = spl_object_hash($menu->getContainer());
- $this->assertEquals($expected, $actual);
-
- $breadcrumbs = $helper('nav2')->breadcrumbs();
- $actual = spl_object_hash($nav2);
- $expected = spl_object_hash($breadcrumbs->getContainer());
- $this->assertEquals($expected, $actual);
-
- $links = $helper()->links();
- $expected = spl_object_hash($links->getContainer());
- $this->assertEquals($expected, $actual);
- }
-
- public function testMultipleNavigationsWithDifferentHelpersAndSameContainer(): void
- {
- $sm = new ServiceManager();
- $nav1 = new Container();
- $sm->setService('nav1', $nav1);
-
- $helper = new Navigation();
- $helper->setServiceLocator($sm);
-
- // Tests
- $menu = $helper('nav1')->menu();
- $actual = spl_object_hash($nav1);
- $expected = spl_object_hash($menu->getContainer());
- $this->assertEquals($expected, $actual);
-
- $breadcrumbs = $helper('nav1')->breadcrumbs();
- $expected = spl_object_hash($breadcrumbs->getContainer());
- $this->assertEquals($expected, $actual);
-
- $links = $helper()->links();
- $expected = spl_object_hash($links->getContainer());
- $this->assertEquals($expected, $actual);
- }
-
- public function testMultipleNavigationsWithSameHelperAndSameContainer(): void
- {
- $sm = new ServiceManager();
- $nav1 = new Container();
- $sm->setService('nav1', $nav1);
-
- $helper = new Navigation();
- $helper->setServiceLocator($sm);
-
- // Test
- $menu = $helper('nav1')->menu();
- $actual = spl_object_hash($nav1);
- $expected = spl_object_hash($menu->getContainer());
- $this->assertEquals($expected, $actual);
-
- $menu = $helper('nav1')->menu();
- $expected = spl_object_hash($menu->getContainer());
- $this->assertEquals($expected, $actual);
-
- $menu = $helper()->menu();
- $expected = spl_object_hash($menu->getContainer());
- $this->assertEquals($expected, $actual);
- }
-
- public function testSetPluginManagerAndView(): void
- {
- $pluginManager = new Navigation\PluginManager(new ServiceManager());
- $view = new PhpRenderer();
-
- $helper = new Navigation();
- $helper->setPluginManager($pluginManager);
- $helper->setView($view);
-
- $this->assertEquals($view, $pluginManager->getRenderer());
- }
-
- public function testInjectsLazyInstantiatedPluginManagerWithCurrentServiceLocator(): void
- {
- $services = $this->createMock(ContainerInterface::class);
- $helper = new Navigation();
- $helper->setServiceLocator($services);
-
- $plugins = $helper->getPluginManager();
- $this->assertInstanceOf(Navigation\PluginManager::class, $plugins);
-
- $pluginsReflection = new ReflectionObject($plugins);
- $creationContext = $pluginsReflection->getProperty('creationContext');
- $creationContextValue = $creationContext->getValue($plugins);
-
- /** Later versions of AbstractPluginManager Decorate Psr Containers */
- if ($creationContextValue instanceof PsrContainerDecorator) {
- /** @psalm-suppress InternalMethod */
- $creationContextValue = $creationContextValue->getContainer();
- }
-
- $this->assertSame($creationContextValue, $services);
- }
-
- /** @inheritDoc */
- protected function getExpectedFileContents(string $filename): string
- {
- return str_replace("\n", PHP_EOL, parent::getExpectedFileContents($filename));
- }
-}
diff --git a/test/Helper/Navigation/PluginManagerCompatibilityTest.php b/test/Helper/Navigation/PluginManagerCompatibilityTest.php
deleted file mode 100644
index a073c2565..000000000
--- a/test/Helper/Navigation/PluginManagerCompatibilityTest.php
+++ /dev/null
@@ -1,51 +0,0 @@
- [
- 'default' => [],
- ],
- ]);
-
- $services = new ServiceManager();
- $config->configureServiceManager($services);
- $helpers = new PluginManager($services);
-
- $helper = $helpers->get('breadcrumbs');
- $this->assertInstanceOf(Breadcrumbs::class, $helper);
- $this->assertSame($services, $helper->getServiceLocator());
- }
-}
diff --git a/test/Helper/Navigation/SitemapTest.php b/test/Helper/Navigation/SitemapTest.php
deleted file mode 100644
index 720c0d3ad..000000000
--- a/test/Helper/Navigation/SitemapTest.php
+++ /dev/null
@@ -1,282 +0,0 @@
- */
- private array $oldServer = [];
-
- /**
- * View helper
- *
- * @var Sitemap
- */
- protected $_helper; // phpcs:ignore
- /**
- * Stores the original set timezone
- *
- * @var non-empty-string
- */
- private string $originaltimezone;
-
- protected function setUp(): void
- {
- $this->_helper = new Sitemap();
- $this->originaltimezone = date_default_timezone_get();
- date_default_timezone_set('Europe/Berlin');
-
- if (isset($_SERVER['SERVER_NAME'])) {
- $this->oldServer['SERVER_NAME'] = $_SERVER['SERVER_NAME'];
- }
-
- if (isset($_SERVER['SERVER_PORT'])) {
- $this->oldServer['SERVER_PORT'] = $_SERVER['SERVER_PORT'];
- }
-
- if (isset($_SERVER['REQUEST_URI'])) {
- $this->oldServer['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
- }
-
- $_SERVER['SERVER_NAME'] = 'localhost';
- $_SERVER['SERVER_PORT'] = 80;
- $_SERVER['REQUEST_URI'] = '/';
-
- parent::setUp();
-
- $this->_helper->setFormatOutput(true);
- $this->_helper->getView()->plugin(BasePath::class)->setBasePath('');
- }
-
- protected function tearDown(): void
- {
- foreach ($this->oldServer as $key => $value) {
- $_SERVER[$key] = $value;
- }
- date_default_timezone_set($this->originaltimezone);
- }
-
- public function testHelperEntryPointWithoutAnyParams(): void
- {
- $returned = $this->_helper->__invoke();
- $this->assertEquals($this->_helper, $returned);
- $this->assertEquals($this->nav1, $returned->getContainer());
- }
-
- public function testHelperEntryPointWithContainerParam(): void
- {
- $returned = $this->_helper->__invoke($this->nav2);
- $this->assertEquals($this->_helper, $returned);
- $this->assertEquals($this->nav2, $returned->getContainer());
- }
-
- public function testNullingOutNavigation(): void
- {
- $this->_helper->setContainer();
- $this->assertEquals(0, count($this->_helper->getContainer()));
- }
-
- public function testRenderSuppliedContainerWithoutInterfering(): void
- {
- $rendered1 = trim($this->getExpectedFileContents('sitemap/default1.xml'));
- $rendered2 = trim($this->getExpectedFileContents('sitemap/default2.xml'));
-
- $expected = [
- 'registered' => $rendered1,
- 'supplied' => $rendered2,
- 'registered_again' => $rendered1,
- ];
- $actual = [
- 'registered' => $this->_helper->render(),
- 'supplied' => $this->_helper->render($this->nav2),
- 'registered_again' => $this->_helper->render(),
- ];
-
- $this->assertEquals($expected, $actual);
- }
-
- public function testUseAclRoles(): void
- {
- $acl = $this->getAcl();
- $this->_helper->setAcl($acl['acl']);
- $this->_helper->setRole($acl['role']);
-
- $expected = $this->getExpectedFileContents('sitemap/acl.xml');
- $this->assertEquals(trim($expected), $this->_helper->render());
- }
-
- public function testUseAclButNoRole(): void
- {
- $acl = $this->getAcl();
- $this->_helper->setAcl($acl['acl']);
- $this->_helper->setRole(null);
-
- $expected = $this->getExpectedFileContents('sitemap/acl2.xml');
- $this->assertEquals(trim($expected), $this->_helper->render());
- }
-
- public function testSettingMaxDepth(): void
- {
- $this->_helper->setMaxDepth(0);
-
- $expected = $this->getExpectedFileContents('sitemap/depth1.xml');
- $this->assertEquals(trim($expected), $this->_helper->render());
- }
-
- public function testSettingMinDepth(): void
- {
- $this->_helper->setMinDepth(1);
-
- $expected = $this->getExpectedFileContents('sitemap/depth2.xml');
- $this->assertEquals(trim($expected), $this->_helper->render());
- }
-
- public function testSettingBothDepths(): void
- {
- $this->_helper->setMinDepth(1)->setMaxDepth(2);
-
- $expected = $this->getExpectedFileContents('sitemap/depth3.xml');
- $this->assertEquals(trim($expected), $this->_helper->render());
- }
-
- public function testDropXmlDeclaration(): void
- {
- $this->_helper->setUseXmlDeclaration(false);
-
- $expected = $this->getExpectedFileContents('sitemap/nodecl.xml');
- $this->assertEquals(trim($expected), $this->_helper->render($this->nav2));
- }
-
- /**
- * @return never
- */
- public function testThrowExceptionOnInvalidLoc()
- {
- $this->markTestIncomplete('Laminas\URI changes affect this test');
- $nav = clone $this->nav2;
- $nav->addPage(['label' => 'Invalid', 'uri' => 'http://w.']);
-
- try {
- $this->_helper->render($nav);
- } catch (View\Exception\ExceptionInterface $e) {
- $expected = sprintf(
- 'Encountered an invalid URL for Sitemap XML: "%s"',
- 'http://w.'
- );
- $actual = $e->getMessage();
- static::assertEquals($expected, $actual);
- return;
- }
-
- static::fail('A Laminas\View\Exception\InvalidArgumentException was not thrown on invalid ');
- }
-
- public function testDisablingValidators(): void
- {
- $nav = clone $this->nav2;
- $nav->addPage(['label' => 'Invalid', 'uri' => 'http://w.']);
- $this->_helper->setUseSitemapValidators(false);
-
- $expected = $this->getExpectedFileContents('sitemap/invalid.xml');
- self::assertNotEmpty($expected);
-
- // using DOMDocument::saveXML() to prevent differences in libxml from invalidating test
- $expectedDom = new DOMDocument();
- $receivedDom = new DOMDocument();
- $expectedDom->loadXML($expected);
- $rendered = $this->_helper->render($nav);
- self::assertNotEmpty($rendered);
- $receivedDom->loadXML($rendered);
- $this->assertEquals($expectedDom->saveXML(), $receivedDom->saveXML());
- }
-
- /** @return array, 2:string}> */
- public static function invalidServerUrlDataProvider(): array
- {
- return [
- 'muppets' => [
- 'muppets',
- View\Exception\InvalidArgumentException::class,
- 'Invalid server URL: "muppets"',
- ],
- ];
- }
-
- /** @param class-string $expectedType */
- #[DataProvider('invalidServerUrlDataProvider')]
- public function testSetServerUrlRequiresValidUri(
- string $invalidServerUrl,
- string $expectedType,
- string $expectedMessage
- ): void {
- $this->expectException($expectedType);
- $this->expectExceptionMessage($expectedMessage);
- $this->_helper->setServerUrl($invalidServerUrl);
- }
-
- public function testSetServerUrlWithSchemeAndHost(): void
- {
- $this->_helper->setServerUrl('http://sub.example.org');
-
- $expected = $this->getExpectedFileContents('sitemap/serverurl1.xml');
- $this->assertEquals(trim($expected), $this->_helper->render());
- }
-
- public function testSetServerUrlWithSchemeAndPortAndHostAndPath(): void
- {
- $this->_helper->setServerUrl('http://sub.example.org:8080/foo/');
-
- $expected = $this->getExpectedFileContents('sitemap/serverurl2.xml');
- $this->assertEquals(trim($expected), $this->_helper->render());
- }
-
- public function testGetUserSchemaValidation(): void
- {
- $this->_helper->setUseSchemaValidation(true);
- $this->assertTrue($this->_helper->getUseSchemaValidation());
- $this->_helper->setUseSchemaValidation(false);
- $this->assertFalse($this->_helper->getUseSchemaValidation());
- }
-
- public function testUseSchemaValidation(): void
- {
- $this->markTestSkipped('Skipped because it fetches XSD from web');
-
-// $nav = clone $this->_nav2;
-// $this->_helper->setUseSitemapValidators(false);
-// $this->_helper->setUseSchemaValidation(true);
-// $nav->addPage(['label' => 'Invalid', 'uri' => 'http://w.']);
-//
-// try {
-// $this->_helper->render($nav);
-// } catch (View\Exception\ExceptionInterface $e) {
-// $expected = sprintf(
-// 'Sitemap is invalid according to XML Schema at "%s"',
-// Sitemap::SITEMAP_XSD
-// );
-// $actual = $e->getMessage();
-// $this->assertEquals($expected, $actual);
-// return;
-// }
-//
-// $this->fail('A Laminas\View\Exception\InvalidArgumentException was not thrown when using Schema validation');
- }
-}
diff --git a/test/Helper/Navigation/_files/expected/bc/acl.html b/test/Helper/Navigation/_files/expected/bc/acl.html
deleted file mode 100644
index e44ba374e..000000000
--- a/test/Helper/Navigation/_files/expected/bc/acl.html
+++ /dev/null
@@ -1 +0,0 @@
-Page 2 > Page 2.2 > Page 2.2.2
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/bc/default.html b/test/Helper/Navigation/_files/expected/bc/default.html
deleted file mode 100644
index d8601875f..000000000
--- a/test/Helper/Navigation/_files/expected/bc/default.html
+++ /dev/null
@@ -1 +0,0 @@
-Page 2 > Page 2.3 > Page 2.3.3 > Page 2.3.3.1
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/bc/linklast.html b/test/Helper/Navigation/_files/expected/bc/linklast.html
deleted file mode 100644
index b3e103a67..000000000
--- a/test/Helper/Navigation/_files/expected/bc/linklast.html
+++ /dev/null
@@ -1 +0,0 @@
-Page 2 > Page 2.3 > Page 2.3.3 > Page 2.3.3.1
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/bc/maxdepth.html b/test/Helper/Navigation/_files/expected/bc/maxdepth.html
deleted file mode 100644
index ce8e36b51..000000000
--- a/test/Helper/Navigation/_files/expected/bc/maxdepth.html
+++ /dev/null
@@ -1 +0,0 @@
-Page 2 > Page 2.3
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/bc/partial.html b/test/Helper/Navigation/_files/expected/bc/partial.html
deleted file mode 100644
index bb7f30e17..000000000
--- a/test/Helper/Navigation/_files/expected/bc/partial.html
+++ /dev/null
@@ -1 +0,0 @@
-Page 2, Page 2.3, Page 2.3.3, Page 2.3.3.1
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/bc/partial_with_params.html b/test/Helper/Navigation/_files/expected/bc/partial_with_params.html
deleted file mode 100644
index 7f33c62ea..000000000
--- a/test/Helper/Navigation/_files/expected/bc/partial_with_params.html
+++ /dev/null
@@ -1,2 +0,0 @@
-test value
-Page 2 / Page 2.3 / Page 2.3.3 / Page 2.3.3.1
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/bc/partialwithseparator.html b/test/Helper/Navigation/_files/expected/bc/partialwithseparator.html
deleted file mode 100644
index 6b2b4c380..000000000
--- a/test/Helper/Navigation/_files/expected/bc/partialwithseparator.html
+++ /dev/null
@@ -1 +0,0 @@
-Page 2 / Page 2.3 / Page 2.3.3 / Page 2.3.3.1
diff --git a/test/Helper/Navigation/_files/expected/bc/separator.html b/test/Helper/Navigation/_files/expected/bc/separator.html
deleted file mode 100644
index bcb0f5d6c..000000000
--- a/test/Helper/Navigation/_files/expected/bc/separator.html
+++ /dev/null
@@ -1 +0,0 @@
-Page 2 fooPage 2.3 fooPage 2.3.3 fooPage 2.3.3.1
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/bc/textdomain.html b/test/Helper/Navigation/_files/expected/bc/textdomain.html
deleted file mode 100644
index 5534fe6f5..000000000
--- a/test/Helper/Navigation/_files/expected/bc/textdomain.html
+++ /dev/null
@@ -1 +0,0 @@
-TextDomain1 2 > Page 2.3 > TextDomain1 2.3.3 > TextDomain2 2.3.3.1
diff --git a/test/Helper/Navigation/_files/expected/bc/translated.html b/test/Helper/Navigation/_files/expected/bc/translated.html
deleted file mode 100644
index 269228c9d..000000000
--- a/test/Helper/Navigation/_files/expected/bc/translated.html
+++ /dev/null
@@ -1 +0,0 @@
-Side 2 > Side 2.3 > Page 2.3.3 > Side 2.3.3.1
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/links/default.html b/test/Helper/Navigation/_files/expected/links/default.html
deleted file mode 100644
index f4ce1e3af..000000000
--- a/test/Helper/Navigation/_files/expected/links/default.html
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/acl.html b/test/Helper/Navigation/_files/expected/menu/acl.html
deleted file mode 100644
index 91a925491..000000000
--- a/test/Helper/Navigation/_files/expected/menu/acl.html
+++ /dev/null
@@ -1,65 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/acl_role_interface.html b/test/Helper/Navigation/_files/expected/menu/acl_role_interface.html
deleted file mode 100644
index 9d07eaa3a..000000000
--- a/test/Helper/Navigation/_files/expected/menu/acl_role_interface.html
+++ /dev/null
@@ -1,62 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/acl_string.html b/test/Helper/Navigation/_files/expected/menu/acl_string.html
deleted file mode 100644
index 9d07eaa3a..000000000
--- a/test/Helper/Navigation/_files/expected/menu/acl_string.html
+++ /dev/null
@@ -1,62 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_false.html b/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_false.html
deleted file mode 100644
index e86b0fae1..000000000
--- a/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_false.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
diff --git a/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_true.html b/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_true.html
deleted file mode 100644
index e65502839..000000000
--- a/test/Helper/Navigation/_files/expected/menu/addclasstolistitem_as_true.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
diff --git a/test/Helper/Navigation/_files/expected/menu/bothdepts.html b/test/Helper/Navigation/_files/expected/menu/bothdepts.html
deleted file mode 100644
index 4080f3e37..000000000
--- a/test/Helper/Navigation/_files/expected/menu/bothdepts.html
+++ /dev/null
@@ -1,52 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/css.html b/test/Helper/Navigation/_files/expected/menu/css.html
deleted file mode 100644
index 8de4109c6..000000000
--- a/test/Helper/Navigation/_files/expected/menu/css.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/css2.html b/test/Helper/Navigation/_files/expected/menu/css2.html
deleted file mode 100644
index f8cc4c02f..000000000
--- a/test/Helper/Navigation/_files/expected/menu/css2.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
diff --git a/test/Helper/Navigation/_files/expected/menu/default1.html b/test/Helper/Navigation/_files/expected/menu/default1.html
deleted file mode 100644
index c397849f5..000000000
--- a/test/Helper/Navigation/_files/expected/menu/default1.html
+++ /dev/null
@@ -1,81 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/default2.html b/test/Helper/Navigation/_files/expected/menu/default2.html
deleted file mode 100644
index 183f5f2ac..000000000
--- a/test/Helper/Navigation/_files/expected/menu/default2.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/escapelabels_as_false.html b/test/Helper/Navigation/_files/expected/menu/escapelabels_as_false.html
deleted file mode 100644
index 4f40aea63..000000000
--- a/test/Helper/Navigation/_files/expected/menu/escapelabels_as_false.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/escapelabels_as_true.html b/test/Helper/Navigation/_files/expected/menu/escapelabels_as_true.html
deleted file mode 100644
index d7b56b10a..000000000
--- a/test/Helper/Navigation/_files/expected/menu/escapelabels_as_true.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/indent4.html b/test/Helper/Navigation/_files/expected/menu/indent4.html
deleted file mode 100644
index 553e0731a..000000000
--- a/test/Helper/Navigation/_files/expected/menu/indent4.html
+++ /dev/null
@@ -1,81 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/indent8.html b/test/Helper/Navigation/_files/expected/menu/indent8.html
deleted file mode 100644
index 1a75d7ce5..000000000
--- a/test/Helper/Navigation/_files/expected/menu/indent8.html
+++ /dev/null
@@ -1,81 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/maxdepth.html b/test/Helper/Navigation/_files/expected/menu/maxdepth.html
deleted file mode 100644
index 1731bdacc..000000000
--- a/test/Helper/Navigation/_files/expected/menu/maxdepth.html
+++ /dev/null
@@ -1,44 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/mindepth.html b/test/Helper/Navigation/_files/expected/menu/mindepth.html
deleted file mode 100644
index 94cf81ef9..000000000
--- a/test/Helper/Navigation/_files/expected/menu/mindepth.html
+++ /dev/null
@@ -1,60 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch.html b/test/Helper/Navigation/_files/expected/menu/onlyactivebranch.html
deleted file mode 100644
index 49d988387..000000000
--- a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch.html
+++ /dev/null
@@ -1,31 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_addclasstolistitem.html b/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_addclasstolistitem.html
deleted file mode 100644
index 9514e408d..000000000
--- a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_addclasstolistitem.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
diff --git a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_bothdepts.html b/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_bothdepts.html
deleted file mode 100644
index 9b94e88fd..000000000
--- a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_bothdepts.html
+++ /dev/null
@@ -1,21 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_maxdepth.html b/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_maxdepth.html
deleted file mode 100644
index 0e181df7a..000000000
--- a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_maxdepth.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_mindepth.html b/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_mindepth.html
deleted file mode 100644
index 56c86efe6..000000000
--- a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_mindepth.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_noparents.html b/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_noparents.html
deleted file mode 100644
index b4eda0b11..000000000
--- a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_noparents.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_np_bd.html b/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_np_bd.html
deleted file mode 100644
index 4e6690b4c..000000000
--- a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_np_bd.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_np_bd2.html b/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_np_bd2.html
deleted file mode 100644
index a6ba4c07a..000000000
--- a/test/Helper/Navigation/_files/expected/menu/onlyactivebranch_np_bd2.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/partial.html b/test/Helper/Navigation/_files/expected/menu/partial.html
deleted file mode 100644
index 356c5a195..000000000
--- a/test/Helper/Navigation/_files/expected/menu/partial.html
+++ /dev/null
@@ -1,2 +0,0 @@
-Is a container: yes
-Pages: Home, Page 1, Page 2, Page 3, Zym
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/partial_with_params.html b/test/Helper/Navigation/_files/expected/menu/partial_with_params.html
deleted file mode 100644
index 9edc0b02b..000000000
--- a/test/Helper/Navigation/_files/expected/menu/partial_with_params.html
+++ /dev/null
@@ -1,3 +0,0 @@
-test value
-Is a container: yes
-Pages: Home, Page 1, Page 2, Page 3, Zym
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/menu/textdomain.html b/test/Helper/Navigation/_files/expected/menu/textdomain.html
deleted file mode 100644
index 1ef39baa1..000000000
--- a/test/Helper/Navigation/_files/expected/menu/textdomain.html
+++ /dev/null
@@ -1,48 +0,0 @@
-
diff --git a/test/Helper/Navigation/_files/expected/menu/translated.html b/test/Helper/Navigation/_files/expected/menu/translated.html
deleted file mode 100644
index b024da3bc..000000000
--- a/test/Helper/Navigation/_files/expected/menu/translated.html
+++ /dev/null
@@ -1,81 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Helper/Navigation/_files/expected/sitemap/acl.xml b/test/Helper/Navigation/_files/expected/sitemap/acl.xml
deleted file mode 100644
index 97dad8642..000000000
--- a/test/Helper/Navigation/_files/expected/sitemap/acl.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
- http://localhost/index
-
-
- http://localhost/page1
-
-
- http://localhost/page1/page1_1
-
-
- http://localhost/page2
-
-
- http://localhost/page2/page2_1
-
-
- http://localhost/page2/page2_2
-
-
- http://localhost/page2/page2_2/page2_2_1
-
-
- http://localhost/page2/page2_2/page2_2_2
-
-
- http://localhost/page2/page2_3
-
-
- http://localhost/page2/page2_3/page2_3_1
-
-
- http://localhost/page3
-
-
- http://localhost/page3/page3_1
-
-
- http://localhost/page3/page3_2
-
-
- http://localhost/page3/page3_2/page3_2_1
-
-
- http://localhost/page3/page3_2/page3_2_2
-
-
- http://localhost/page3/page3_3
-
-
- http://www.zym-project.com/
-
-
diff --git a/test/Helper/Navigation/_files/expected/sitemap/acl2.xml b/test/Helper/Navigation/_files/expected/sitemap/acl2.xml
deleted file mode 100644
index bdb75faf0..000000000
--- a/test/Helper/Navigation/_files/expected/sitemap/acl2.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
- http://localhost/index
-
-
- http://localhost/page1
-
-
- http://localhost/page1/page1_1
-
-
- http://localhost/page2
-
-
- http://localhost/page2/page2_1
-
-
- http://localhost/page2/page2_2
-
-
- http://localhost/page2/page2_2/page2_2_1
-
-
- http://localhost/page2/page2_2/page2_2_2
-
-
- http://localhost/page2/page2_3
-
-
- http://localhost/page2/page2_3/page2_3_1
-
-
- http://localhost/page3
-
-
- http://www.zym-project.com/
-
-
diff --git a/test/Helper/Navigation/_files/expected/sitemap/default1.xml b/test/Helper/Navigation/_files/expected/sitemap/default1.xml
deleted file mode 100644
index 217f269bb..000000000
--- a/test/Helper/Navigation/_files/expected/sitemap/default1.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
- http://localhost/index
-
-
- http://localhost/page1
-
-
- http://localhost/page1/page1_1
-
-
- http://localhost/page2
-
-
- http://localhost/page2/page2_1
-
-
- http://localhost/page2/page2_2
-
-
- http://localhost/page2/page2_2/page2_2_1
-
-
- http://localhost/page2/page2_2/page2_2_2
-
-
- http://localhost/page2/page2_3
-
-
- http://localhost/page2/page2_3/page2_3_1
-
-
- http://localhost/page2/page2_3/page2_3_3
-
-
- http://localhost/page2/page2_3/page2_3_3/1
-
-
- http://localhost/page2/page2_3/page2_3_3/2
-
-
- http://localhost/page3
-
-
- http://localhost/page3/page3_1
-
-
- http://localhost/page3/page3_2
-
-
- http://localhost/page3/page3_2/page3_2_1
-
-
- http://localhost/page3/page3_2/page3_2_2
-
-
- http://localhost/page3/page3_3
-
-
- http://localhost/page3/page3_3/page3_3_2
-
-
- http://www.zym-project.com/
-
-
diff --git a/test/Helper/Navigation/_files/expected/sitemap/default2.xml b/test/Helper/Navigation/_files/expected/sitemap/default2.xml
deleted file mode 100644
index e3c8d78a4..000000000
--- a/test/Helper/Navigation/_files/expected/sitemap/default2.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
- http://localhost/site1
- daily
- 0.9
-
-
- http://localhost/site2
-
-
- http://localhost/site3
-
-
diff --git a/test/Helper/Navigation/_files/expected/sitemap/depth1.xml b/test/Helper/Navigation/_files/expected/sitemap/depth1.xml
deleted file mode 100644
index 3da124d51..000000000
--- a/test/Helper/Navigation/_files/expected/sitemap/depth1.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
- http://localhost/index
-
-
- http://localhost/page1
-
-
- http://localhost/page2
-
-
- http://localhost/page3
-
-
- http://www.zym-project.com/
-
-
diff --git a/test/Helper/Navigation/_files/expected/sitemap/depth2.xml b/test/Helper/Navigation/_files/expected/sitemap/depth2.xml
deleted file mode 100644
index 4b0e9fa72..000000000
--- a/test/Helper/Navigation/_files/expected/sitemap/depth2.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
- http://localhost/page1/page1_1
-
-
- http://localhost/page2/page2_1
-
-
- http://localhost/page2/page2_2
-
-
- http://localhost/page2/page2_2/page2_2_1
-
-
- http://localhost/page2/page2_2/page2_2_2
-
-
- http://localhost/page2/page2_3
-
-
- http://localhost/page2/page2_3/page2_3_1
-
-
- http://localhost/page2/page2_3/page2_3_3
-
-
- http://localhost/page2/page2_3/page2_3_3/1
-
-
- http://localhost/page2/page2_3/page2_3_3/2
-
-
- http://localhost/page3/page3_1
-
-
- http://localhost/page3/page3_2
-
-
- http://localhost/page3/page3_2/page3_2_1
-
-
- http://localhost/page3/page3_2/page3_2_2
-
-
- http://localhost/page3/page3_3
-
-
- http://localhost/page3/page3_3/page3_3_2
-
-
diff --git a/test/Helper/Navigation/_files/expected/sitemap/depth3.xml b/test/Helper/Navigation/_files/expected/sitemap/depth3.xml
deleted file mode 100644
index 78556a088..000000000
--- a/test/Helper/Navigation/_files/expected/sitemap/depth3.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
- http://localhost/page1/page1_1
-
-
- http://localhost/page2/page2_1
-
-
- http://localhost/page2/page2_2
-
-
- http://localhost/page2/page2_2/page2_2_1
-
-
- http://localhost/page2/page2_2/page2_2_2
-
-
- http://localhost/page2/page2_3
-
-
- http://localhost/page2/page2_3/page2_3_1
-
-
- http://localhost/page2/page2_3/page2_3_3
-
-
- http://localhost/page3/page3_1
-
-
- http://localhost/page3/page3_2
-
-
- http://localhost/page3/page3_2/page3_2_1
-
-
- http://localhost/page3/page3_2/page3_2_2
-
-
- http://localhost/page3/page3_3
-
-
- http://localhost/page3/page3_3/page3_3_2
-
-
diff --git a/test/Helper/Navigation/_files/expected/sitemap/invalid.xml b/test/Helper/Navigation/_files/expected/sitemap/invalid.xml
deleted file mode 100644
index 2d2e82eed..000000000
--- a/test/Helper/Navigation/_files/expected/sitemap/invalid.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- http://localhost/site1
- daily
- 0.9
-
-
- http://localhost/site2
-
-
-
- http://localhost/site3
- often
-
-
- http://w.
-
-
diff --git a/test/Helper/Navigation/_files/expected/sitemap/nodecl.xml b/test/Helper/Navigation/_files/expected/sitemap/nodecl.xml
deleted file mode 100644
index 329eebd1d..000000000
--- a/test/Helper/Navigation/_files/expected/sitemap/nodecl.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
- http://localhost/site1
- daily
- 0.9
-
-
- http://localhost/site2
-
-
- http://localhost/site3
-
-
diff --git a/test/Helper/Navigation/_files/expected/sitemap/serverurl1.xml b/test/Helper/Navigation/_files/expected/sitemap/serverurl1.xml
deleted file mode 100644
index c10735e78..000000000
--- a/test/Helper/Navigation/_files/expected/sitemap/serverurl1.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
- http://sub.example.org/index
-
-
- http://sub.example.org/page1
-
-
- http://sub.example.org/page1/page1_1
-
-
- http://sub.example.org/page2
-
-
- http://sub.example.org/page2/page2_1
-
-
- http://sub.example.org/page2/page2_2
-
-
- http://sub.example.org/page2/page2_2/page2_2_1
-
-
- http://sub.example.org/page2/page2_2/page2_2_2
-
-
- http://sub.example.org/page2/page2_3
-
-
- http://sub.example.org/page2/page2_3/page2_3_1
-
-
- http://sub.example.org/page2/page2_3/page2_3_3
-
-
- http://sub.example.org/page2/page2_3/page2_3_3/1
-
-
- http://sub.example.org/page2/page2_3/page2_3_3/2
-
-
- http://sub.example.org/page3
-
-
- http://sub.example.org/page3/page3_1
-
-
- http://sub.example.org/page3/page3_2
-
-
- http://sub.example.org/page3/page3_2/page3_2_1
-
-
- http://sub.example.org/page3/page3_2/page3_2_2
-
-
- http://sub.example.org/page3/page3_3
-
-
- http://sub.example.org/page3/page3_3/page3_3_2
-
-
- http://www.zym-project.com/
-
-
diff --git a/test/Helper/Navigation/_files/expected/sitemap/serverurl2.xml b/test/Helper/Navigation/_files/expected/sitemap/serverurl2.xml
deleted file mode 100644
index 58a7a33ae..000000000
--- a/test/Helper/Navigation/_files/expected/sitemap/serverurl2.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
- http://sub.example.org:8080/index
-
-
- http://sub.example.org:8080/page1
-
-
- http://sub.example.org:8080/page1/page1_1
-
-
- http://sub.example.org:8080/page2
-
-
- http://sub.example.org:8080/page2/page2_1
-
-
- http://sub.example.org:8080/page2/page2_2
-
-
- http://sub.example.org:8080/page2/page2_2/page2_2_1
-
-
- http://sub.example.org:8080/page2/page2_2/page2_2_2
-
-
- http://sub.example.org:8080/page2/page2_3
-
-
- http://sub.example.org:8080/page2/page2_3/page2_3_1
-
-
- http://sub.example.org:8080/page2/page2_3/page2_3_3
-
-
- http://sub.example.org:8080/page2/page2_3/page2_3_3/1
-
-
- http://sub.example.org:8080/page2/page2_3/page2_3_3/2
-
-
- http://sub.example.org:8080/page3
-
-
- http://sub.example.org:8080/page3/page3_1
-
-
- http://sub.example.org:8080/page3/page3_2
-
-
- http://sub.example.org:8080/page3/page3_2/page3_2_1
-
-
- http://sub.example.org:8080/page3/page3_2/page3_2_2
-
-
- http://sub.example.org:8080/page3/page3_3
-
-
- http://sub.example.org:8080/page3/page3_3/page3_3_2
-
-
- http://www.zym-project.com/
-
-
diff --git a/test/Helper/Navigation/_files/mvc/views/bc.phtml b/test/Helper/Navigation/_files/mvc/views/bc.phtml
deleted file mode 100644
index 383d06aff..000000000
--- a/test/Helper/Navigation/_files/mvc/views/bc.phtml
+++ /dev/null
@@ -1,10 +0,0 @@
-getLabel();
- },
- $this->vars()->pages
- )
-);
diff --git a/test/Helper/Navigation/_files/mvc/views/bc_separator.phtml b/test/Helper/Navigation/_files/mvc/views/bc_separator.phtml
deleted file mode 100644
index 89fce118a..000000000
--- a/test/Helper/Navigation/_files/mvc/views/bc_separator.phtml
+++ /dev/null
@@ -1,10 +0,0 @@
-vars()->separator,
- array_map(
- function($a) {
- return $a->getLabel();
- },
- $this->vars()->pages
- )
-);
diff --git a/test/Helper/Navigation/_files/mvc/views/bc_with_partial_params.phtml b/test/Helper/Navigation/_files/mvc/views/bc_with_partial_params.phtml
deleted file mode 100644
index c75d92f25..000000000
--- a/test/Helper/Navigation/_files/mvc/views/bc_with_partial_params.phtml
+++ /dev/null
@@ -1,11 +0,0 @@
-variable . PHP_EOL;
-echo implode(
- $this->vars()->separator,
- array_map(
- function($a) {
- return $a->getLabel();
- },
- $this->vars()->pages
- )
-);
diff --git a/test/Helper/Navigation/_files/mvc/views/menu.phtml b/test/Helper/Navigation/_files/mvc/views/menu.phtml
deleted file mode 100644
index 7b45c3629..000000000
--- a/test/Helper/Navigation/_files/mvc/views/menu.phtml
+++ /dev/null
@@ -1,13 +0,0 @@
-vars('container') instanceof \Laminas\Navigation\AbstractContainer
- ? 'yes'
- : 'no';
-
-$pages = array();
-foreach ($this->vars('container') as $page) {
- $pages[] = $page->getLabel();
-}
-$pages = implode(', ', $pages);
-?>
-Is a container:
-Pages:
diff --git a/test/Helper/Navigation/_files/mvc/views/menu_with_partial_params.phtml b/test/Helper/Navigation/_files/mvc/views/menu_with_partial_params.phtml
deleted file mode 100644
index c75e759db..000000000
--- a/test/Helper/Navigation/_files/mvc/views/menu_with_partial_params.phtml
+++ /dev/null
@@ -1,13 +0,0 @@
-vars('container') instanceof \Laminas\Navigation\AbstractContainer
- ? 'yes'
- : 'no';
-echo $this->variable . PHP_EOL;
-$pages = array();
-foreach ($this->vars('container') as $page) {
- $pages[] = $page->getLabel();
-}
-$pages = implode(', ', $pages);
-?>
-Is a container:
-Pages:
diff --git a/test/Helper/Navigation/_files/navigation-config.php b/test/Helper/Navigation/_files/navigation-config.php
deleted file mode 100644
index fe7ff8bc3..000000000
--- a/test/Helper/Navigation/_files/navigation-config.php
+++ /dev/null
@@ -1,264 +0,0 @@
- [
- 'zym' => [
- 'label' => 'Zym',
- 'uri' => 'http://www.zym-project.com/',
- 'order' => '100',
- ],
- 'page1' => [
- 'label' => 'Page 1',
- 'uri' => 'page1',
- 'pages' => [
- 'page1_1' => [
- 'label' => 'Page 1.1',
- 'uri' => 'page1/page1_1',
- ],
- ],
- ],
- 'page2' => [
- 'label' => 'Page 2',
- 'uri' => 'page2',
- 'pages' => [
- 'page2_1' => [
- 'label' => 'Page 2.1',
- 'uri' => 'page2/page2_1',
- ],
- 'page2_2' => [
- 'label' => 'Page 2.2',
- 'uri' => 'page2/page2_2',
- 'pages' => [
- 'page2_2_1' => [
- 'label' => 'Page 2.2.1',
- 'uri' => 'page2/page2_2/page2_2_1',
- ],
- 'page2_2_2' => [
- 'label' => 'Page 2.2.2',
- 'uri' => 'page2/page2_2/page2_2_2',
- 'active' => '1',
- ],
- ],
- ],
- 'page2_3' => [
- 'label' => 'Page 2.3',
- 'uri' => 'page2/page2_3',
- 'pages' => [
- 'page2_3_1' => [
- 'label' => 'Page 2.3.1',
- 'uri' => 'page2/page2_3/page2_3_1',
- ],
- 'page2_3_2' => [
- 'label' => 'Page 2.3.2',
- 'uri' => 'page2/page2_3/page2_3_2',
- 'visible' => '0',
- 'pages' => [
- 'page2_3_2_1' => [
- 'label' => 'Page 2.3.2.1',
- 'uri' => 'page2/page2_3/page2_3_2/1',
- 'active' => '1',
- ],
- 'page2_3_2_2' => [
- 'label' => 'Page 2.3.2.2',
- 'uri' => 'page2/page2_3/page2_3_2/2',
- 'active' => '1',
- 'pages' => [
- 'page_2_3_2_2_1' => [
- 'label' => 'Ignore',
- 'uri' => '#',
- 'active' => '1',
- ],
- ],
- ],
- ],
- ],
- 'page2_3_3' => [
- 'label' => 'Page 2.3.3',
- 'uri' => 'page2/page2_3/page2_3_3',
- 'resource' => 'admin_foo',
- 'pages' => [
- 'page2_3_3_1' => [
- 'label' => 'Page 2.3.3.1',
- 'uri' => 'page2/page2_3/page2_3_3/1',
- 'active' => '1',
- ],
- 'page2_3_3_2' => [
- 'label' => 'Page 2.3.3.2',
- 'uri' => 'page2/page2_3/page2_3_3/2',
- 'resource' => 'guest_foo',
- 'active' => '1',
- ],
- ],
- ],
- ],
- ],
- ],
- ],
- 'page3' => [
- 'label' => 'Page 3',
- 'uri' => 'page3',
- 'pages' => [
- 'page3_1' => [
- 'label' => 'Page 3.1',
- 'uri' => 'page3/page3_1',
- 'resource' => 'guest_foo',
- ],
- 'page3_2' => [
- 'label' => 'Page 3.2',
- 'uri' => 'page3/page3_2',
- 'resource' => 'member_foo',
- 'pages' => [
- 'page3_2_1' => [
- 'label' => 'Page 3.2.1',
- 'uri' => 'page3/page3_2/page3_2_1',
- ],
- 'page3_2_2' => [
- 'label' => 'Page 3.2.2',
- 'uri' => 'page3/page3_2/page3_2_2',
- 'resource' => 'admin_foo',
- 'privilege' => 'read',
- ],
- ],
- ],
- 'page3_3' => [
- 'label' => 'Page 3.3',
- 'uri' => 'page3/page3_3',
- 'resource' => 'special_foo',
- 'pages' => [
- 'page3_3_1' => [
- 'label' => 'Page 3.3.1',
- 'uri' => 'page3/page3_3/page3_3_1',
- 'visible' => '0',
- ],
- 'page3_3_2' => [
- 'label' => 'Page 3.3.2',
- 'uri' => 'page3/page3_3/page3_3_2',
- 'resource' => 'admin_foo',
- ],
- ],
- ],
- ],
- ],
- 'home' => [
- 'label' => 'Home',
- 'uri' => 'index',
- 'title' => 'Go home',
- 'order' => '-100',
- ],
- ],
- 'nav_test2' => [
- 'site1' => [
- 'label' => 'Site 1',
- 'uri' => 'site1',
- 'changefreq' => 'daily',
- 'priority' => '0.9',
- ],
- 'site2' => [
- 'label' => 'Site 2',
- 'uri' => 'site2',
- 'active' => '1',
- 'lastmod' => 'earlier',
- ],
- 'site3' => [
- 'label' => 'Site 3',
- 'uri' => 'site3',
- 'changefreq' => 'often',
- ],
- ],
- 'nav_test3' => [
- 'page1' => [
- 'label' => 'Page 1',
- 'uri' => 'page1',
- 'pages' => [
- 'page1_1' => [
- 'label' => 'Page 1.1',
- 'uri' => 'page1/page1_1',
- 'textdomain' => 'LaminasTest_1',
- ],
- ],
- ],
- 'page2' => [
- 'label' => 'Page 2',
- 'uri' => 'page2',
- 'textdomain' => 'LaminasTest_1',
- 'pages' => [
- 'page2_1' => [
- 'label' => 'Page 2.1',
- 'uri' => 'page2/page2_1',
- ],
- 'page2_2' => [
- 'label' => 'Page 2.2',
- 'uri' => 'page2/page2_2',
- 'pages' => [
- 'page2_2_1' => [
- 'label' => 'Page 2.2.1',
- 'uri' => 'page2/page2_2/page2_2_1',
- ],
- 'page2_2_2' => [
- 'label' => 'Page 2.2.2',
- 'uri' => 'page2/page2_2/page2_2_2',
- 'active' => '1',
- ],
- ],
- ],
- 'page2_3' => [
- 'label' => 'Page 2.3',
- 'uri' => 'page2/page2_3',
- 'textdomain' => 'LaminasTest_No',
- 'pages' => [
- 'page2_3_1' => [
- 'label' => 'Page 2.3.1',
- 'uri' => 'page2/page2_3/page2_3_1',
- ],
- 'page2_3_2' => [
- 'label' => 'Page 2.3.2',
- 'uri' => 'page2/page2_3/page2_3_2',
- 'visible' => '0',
- 'pages' => [
- 'page2_3_2_1' => [
- 'label' => 'Page 2.3.2.1',
- 'uri' => 'page2/page2_3/page2_3_2/1',
- 'active' => '1',
- ],
- 'page2_3_2_2' => [
- 'label' => 'Page 2.3.2.2',
- 'uri' => 'page2/page2_3/page2_3_2/2',
- 'active' => '1',
- 'pages' => [
- 'page_2_3_2_2_1' => [
- 'label' => 'Ignore',
- 'uri' => '#',
- 'active' => '1',
- ],
- ],
- ],
- ],
- ],
- 'page2_3_3' => [
- 'label' => 'Page 2.3.3',
- 'uri' => 'page2/page2_3/page2_3_3',
- 'resource' => 'admin_foo',
- 'textdomain' => 'LaminasTest_1',
- 'pages' => [
- 'page2_3_3_1' => [
- 'label' => 'Page 2.3.3.1',
- 'uri' => 'page2/page2_3/page2_3_3/1',
- 'active' => '1',
- 'textdomain' => 'LaminasTest_2',
- ],
- 'page2_3_3_2' => [
- 'label' => 'Page 2.3.3.2',
- 'uri' => 'page2/page2_3/page2_3_3/2',
- 'resource' => 'guest_foo',
- 'active' => '1',
- ],
- ],
- ],
- ],
- ],
- ],
- ],
- ],
-];