Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/78' into develop
Browse files Browse the repository at this point in the history
Forward port #79
  • Loading branch information
weierophinney committed Jun 30, 2016
2 parents a66ac6a + 002d3cf commit eb4fd87
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 101 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ cache:
env:
global:
- COMPOSER_ARGS="--no-interaction --ignore-platform-reqs"
- SITE_URL: https://zendframework.github.io/zend-view
- GH_USER_NAME: "Matthew Weier O'Phinney"
- GH_USER_EMAIL: matthew@weierophinney.net
- GH_REF: github.com/zendframework/zend-view.git
- LATEST_DEPS="zendframework/zend-mvc-plugin-flashmessenger zendframework/zend-mvc-i18n zendframework/zend-mvc-console"
- SITE_URL=https://zendframework.github.io/zend-view
- GH_USER_NAME="Matthew Weier O'Phinney"
- GH_USER_EMAIL=matthew@weierophinney.net
- GH_REF=github.com/zendframework/zend-view.git
- secure: "kF7z5CxnrD/lsX9sP1+SYLKm1HdT/u1F0xovlyT9fDWrz+X4DBe8Oybzk6UX5HKXQvdhVTfAbHoWhFxFrkcRKrtaEOltk68bYFgnSOYhrK5EhZz6CHqN2j1MtT6FRfdlSOi6OECvCE3wd8nYHixxEviIZyB3L5+H39FOiu5Zi+eJT/myp6IuBO6lQfnSgqKdvuQXlfWSn9VGQJztX6ea2U89eM/TAVWEwbhLAJOsOejkvAy2lvYhIZpvSEkFm9jSp3/JOw8MFljG8UEDZUkpj+zba5/vqzM8thTTbybhAIBF7wNeMNrAeFBnrPz5KDPEQYYG8NG4we6F7GvbevvBz+ej5OJPXx/ulhMiEWKN1qEmQHZ3Gl0kG0O+TgXfqLErbCNn4MLP/K0Avar03m9bvXtaTA5Yqde0rIdspjwdxmKi0OI76UnGETMDyWuXbHkRfhs54sUEOBUdM3dz5lXhlSWPCTlQCgzkVqlgTL5b8b1u7YKpkwJAFSXMhhJBycFCNCfqAy10l2wjgvhXhLgPHle7sSwYR6SMVzkjj59P1UKc2yrxkwl/S7cqrbaeGSGjDv/QVMLtBL3OLqXwIaKy3POF2gQJhFXdrmGzDOADyCbEXVUYve5pQOmT1RdVHaHiT7AmZXEQibR1DW2zzU9eX94XpK9LKzlSzUOtYT8LNNA="

matrix:
Expand Down Expand Up @@ -78,6 +79,7 @@ before_install:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi

install:
- if [[ $DEPS == 'latest' ]]; then travis_retry composer require --dev --no-update $COMPOSER_ARGS $LATEST_DEPS ; fi
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- travis_retry composer install $COMPOSER_ARGS
Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ All notable changes to this project will be documented in this file, in reverse

- Nothing.

## 2.8.1 - TBD
## 2.8.1 - 2016-06-30

### Added

Expand All @@ -36,7 +36,9 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- Nothing.
- [#78](https://github.com/zendframework/zend-view/pull/78) and
[#79](https://github.com/zendframework/zend-view/pull/79) ensure that all
helpers work with both version 2 and version 3 of zend-mvc.

## 2.8.0 - 2016-06-21

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"zendframework/zend-json": "^2.6.1",
"zendframework/zend-log": "^2.7",
"zendframework/zend-modulemanager": "^2.7.1",
"zendframework/zend-mvc": "^2.7",
"zendframework/zend-mvc": "^2.7 || ^3.0",
"zendframework/zend-navigation": "^2.5",
"zendframework/zend-paginator": "^2.5",
"zendframework/zend-permissions-acl": "^2.6",
Expand Down
56 changes: 40 additions & 16 deletions src/Helper/FlashMessenger.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@

namespace Zend\View\Helper;

use Zend\Mvc\Controller\Plugin\FlashMessenger as PluginFlashMessenger;
use Zend\Mvc\Controller\Plugin\FlashMessenger as V2PluginFlashMessenger;
use Zend\Mvc\Plugin\FlashMessenger\FlashMessenger as PluginFlashMessenger;
use Zend\View\Exception\InvalidArgumentException;

/**
* Helper to proxy the plugin flash messenger
*
* Duck-types against Zend\I18n\Translator\TranslatorAwareInterface.
*
* @deprecated This helper will be removed in version 3.0 of this component.
* At that time, it will be available in zendframework/zend-mvc-plugin-flashmessenger.
*/
class FlashMessenger extends AbstractHelper
{
Expand All @@ -21,14 +26,16 @@ class FlashMessenger extends AbstractHelper
/**
* Default attributes for the open format tag
*
* @todo For version 3, have the keys reference the class constants in the
* FlashMessenger plugin.
* @var array
*/
protected $classMessages = [
PluginFlashMessenger::NAMESPACE_INFO => 'info',
PluginFlashMessenger::NAMESPACE_ERROR => 'error',
PluginFlashMessenger::NAMESPACE_SUCCESS => 'success',
PluginFlashMessenger::NAMESPACE_DEFAULT => 'default',
PluginFlashMessenger::NAMESPACE_WARNING => 'warning',
'info' => 'info',
'error' => 'error',
'success' => 'success',
'default' => 'default',
'warning' => 'warning',
];

/**
Expand Down Expand Up @@ -57,15 +64,15 @@ class FlashMessenger extends AbstractHelper
/**
* Flash messenger plugin
*
* @var PluginFlashMessenger
* @var V2PluginFlashMessenger|PluginFlashMessenger
*/
protected $pluginFlashMessenger;

/**
* Returns the flash messenger plugin controller
*
* @param string|null $namespace
* @return FlashMessenger|PluginFlashMessenger
* @return FlashMessenger|V2PluginFlashMessenger|PluginFlashMessenger
*/
public function __invoke($namespace = null)
{
Expand Down Expand Up @@ -98,7 +105,7 @@ public function __call($method, $argv)
* @param null|bool $autoEscape
* @return string
*/
public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = [], $autoEscape = null)
public function render($namespace = 'default', array $classes = [], $autoEscape = null)
{
$flashMessenger = $this->getPluginFlashMessenger();
$messages = $flashMessenger->getMessagesFromNamespace($namespace);
Expand All @@ -113,7 +120,7 @@ public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, arr
* @param bool|null $autoEscape
* @return string
*/
public function renderCurrent($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, array $classes = [], $autoEscape = null)
public function renderCurrent($namespace = 'default', array $classes = [], $autoEscape = null)
{
$flashMessenger = $this->getPluginFlashMessenger();
$messages = $flashMessenger->getCurrentMessagesFromNamespace($namespace);
Expand All @@ -130,7 +137,7 @@ public function renderCurrent($namespace = PluginFlashMessenger::NAMESPACE_DEFAU
* @return string
*/
protected function renderMessages(
$namespace = PluginFlashMessenger::NAMESPACE_DEFAULT,
$namespace = 'default',
array $messages = [],
array $classes = [],
$autoEscape = null
Expand All @@ -144,7 +151,7 @@ protected function renderMessages(
if (isset($this->classMessages[$namespace])) {
$classes = $this->classMessages[$namespace];
} else {
$classes = $this->classMessages[PluginFlashMessenger::NAMESPACE_DEFAULT];
$classes = $this->classMessages['default'];
}
$classes = [$classes];
}
Expand Down Expand Up @@ -282,24 +289,41 @@ public function getMessageSeparatorString()
/**
* Set the flash messenger plugin
*
* @param PluginFlashMessenger $pluginFlashMessenger
* @param V2PluginFlashMessenger|PluginFlashMessenger $pluginFlashMessenger
* @return FlashMessenger
* @throws InvalidArgumentException for an invalid $pluginFlashMessenger
*/
public function setPluginFlashMessenger(PluginFlashMessenger $pluginFlashMessenger)
public function setPluginFlashMessenger($pluginFlashMessenger)
{
if (! $pluginFlashMessenger instanceof V2PluginFlashMessenger
&& ! $pluginFlashMessenger instanceof PluginFlashMessenger
) {
throw new InvalidArgumentException(sprintf(
'%s expects either a %s or %s instance; received %s',
__METHOD__,
V2PluginFlashMessenger::class,
PluginFlashMessenger::class,
(is_object($pluginFlashMessenger) ? get_class($pluginFlashMessenger) : gettype($pluginFlashMessenger))
));
}

$this->pluginFlashMessenger = $pluginFlashMessenger;
return $this;
}

/**
* Get the flash messenger plugin
*
* @return PluginFlashMessenger
* @return V2PluginFlashMessenger|PluginFlashMessenger
*/
public function getPluginFlashMessenger()
{
if (null === $this->pluginFlashMessenger) {
$this->setPluginFlashMessenger(new PluginFlashMessenger());
$this->setPluginFlashMessenger(
class_exists(PluginFlashMessenger::class)
? new PluginFlashMessenger()
: new V2PluginFlashMessenger()
);
}

return $this->pluginFlashMessenger;
Expand Down
Loading

0 comments on commit eb4fd87

Please sign in to comment.