3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\View\Helper\Service
;
12 use Zend\ServiceManager\FactoryInterface
;
13 use Zend\ServiceManager\ServiceLocatorInterface
;
14 use Zend\View\Helper\FlashMessenger
;
16 class FlashMessengerFactory
implements FactoryInterface
21 * @param ServiceLocatorInterface $serviceLocator
22 * @return FlashMessenger
24 public function createService(ServiceLocatorInterface
$serviceLocator)
26 $serviceLocator = $serviceLocator->getServiceLocator();
27 $helper = new FlashMessenger();
28 $controllerPluginManager = $serviceLocator->get('ControllerPluginManager');
29 $flashMessenger = $controllerPluginManager->get('flashmessenger');
30 $helper->setPluginFlashMessenger($flashMessenger);
31 $config = $serviceLocator->get('Config');
32 if (isset($config['view_helper_config']['flashmessenger'])) {
33 $configHelper = $config['view_helper_config']['flashmessenger'];
34 if (isset($configHelper['message_open_format'])) {
35 $helper->setMessageOpenFormat($configHelper['message_open_format']);
37 if (isset($configHelper['message_separator_string'])) {
38 $helper->setMessageSeparatorString($configHelper['message_separator_string']);
40 if (isset($configHelper['message_close_string'])) {
41 $helper->setMessageCloseString($configHelper['message_close_string']);