checkout messages from session container

@param MessageBag $messages
@return string
350061
protected function checkout(MessageBag $messages)
    {
        $html       = '';
        $hasError   = false;
        $hasSuccess = false;

        foreach (['error', 'info', 'success', 'warning'] as $key) {
            if ($messages->has($key)) {
                $hasError   = (!$hasError && $key == 'error');
                $hasSuccess = (!$hasSuccess && $key == 'success');

                $flashMessages = $messages->setFormat('<div class="activity-item"> <i class="fa ' . $this->mapping[$key] . '"></i> <div class="activity">:message</div>')->get($key);


                array_walk($flashMessages, function($current) use ($key, &$html) {
                    $html .= "generate('{$key}', '{$current}');\n";
                });
            }
        }
        return $html;
    }
1135392
protected function notFound($messages = null)
	{
		$data = $this->getStatusData('not-found', $messages);
		return $this->jsonResponse($data, 404);
	}
1320701
protected function _loadMessages() {
        if ($this->getNameInLayout() == 'messages') {
            foreach ($this->_messageStorageTypes as $type) {
                $storage = sprintf('%s/session', $type);
                $this->addStorageType($storage);
                $this->_loadMessagesFromStorage($storage);
            }
        } else {
            $this->_loadMessagesFromStorage('core/session');
        }
    }
1022068
private function getMessage(string $message): string
    {
        /** @var FormatterFactoryInterface $factory */
        $factory   = $this->getContainer()->get(FormatterFactoryInterface::class);
        $formatter = $factory->createFormatter(Messages::NAMESPACE_NAME);
        $result    = $formatter->formatMessage($message);

        return $result;
    }
1185780
public static function purgeMemcachedCache($modelNames = array(), $messageBag = array()) {
        if (!Zend_Registry::isRegistered('CacheFrontend')) {
            $messageBag[] = 'Memcached: No caching enabled';
            return $messageBag;
        }

        if (!Zend_Registry::get('CacheFrontend')->getOption('caching')) {
            $messageBag[] = 'Memcached: No caching enabled';
            return $messageBag;;
        }

        if ($modelNames instanceof Garp_Model_Db) {
            $modelNames = self::getTagsFromModel($modelNames);
        }

        if (empty($modelNames)) {
            $cacheFront = Zend_Registry::get('CacheFrontend');
            $cacheFront->clean(Zend_Cache::CLEANING_MODE_ALL);
            $messageBag[] = 'Memcached: Purged All';
            return $messageBag;
        }

        foreach ($modelNames as $modelName) {
            $model = new $modelName();
            self::_incrementMemcacheVersion($model);
            if (!$model->getObserver('Translatable')) {
                continue;
            }
            // Make sure cache is cleared for all languages.
            $locales = Garp_I18n::getLocales();
            foreach ($locales as $locale) {
                try {
                    $modelFactory = new Garp_I18n_ModelFactory($locale);
                    $i18nModel = $modelFactory->getModel($model);
                    self::_incrementMemcacheVersion($i18nModel);
                } catch (Garp_I18n_ModelFactory_Exception_ModelAlreadyLocalized $e) {
                    // all good in the hood  ｡^‿^｡
                }
            }
        }
        $messageBag[] = 'Memcached: Purged all given models';
        return $messageBag;
    }
948286
protected function resolveErrorKey($messages = [])
	{
		// if there is no error key defined leave messages as they were
		if(empty($this->errorKey))
		{
			return $messages;
		}

		// keys are divided on every .
		$keys = explode('.', $this->errorKey);

		// we need to reverse this array for sorting
		$keys = array_reverse($keys);

		foreach ($keys as $errorKey) {
			$messages = array($errorKey => $messages);
		}

		return $messages;
	}
670993
protected function formatMessages($messages, string $prefix): array
    {
        $result = [];

        // Convert single messages to array
        if (is_string($messages)) {
            $messages = [$messages];
        }

        // Prefix all messages
        foreach ($messages as $message) {
            $result[] = sprintf("[%s][%s] %s : %s", $this->module, $this->configType, $prefix, $message);
        }

        return $result;
    }
178014
public function analyze(JWK $jwk): MessageBag
    {
        $bag = new MessageBag();
        foreach ($this->analyzers as $analyzer) {
            $analyzer->analyze($jwk, $bag);
        }

        return $bag;
    }
655492
public function messages()
    {
        $session = AnService::get('com:sessions');
        $queue = (array) $session->get('controller.queue', array());

        $session->set('controller.queue', null);

        if (isset($queue['message'])) {
            $message = $queue['message'];
            $config = array('closable' => true);

            if (isset($message['type'])) {
                $config['type'] = $message['type'];
            }

            return $this->getTemplate()->renderHelper('ui.message', $message['message'], $config);
        }

        return '';
    }
974211
private function formMessageData(Message $message)
    {
        $data = array(
            'registration_ids' => $message->getRegistrationIds(),
        );

        $dataFields = array(
            'registration_ids' => 'getRegistrationIds',
            'collapse_key' => 'getCollapseKey',
            'data' => 'getData',
            'notification' => 'getNotification',
            'delay_while_idle' => 'getDelayWhileIdle',
            'time_to_live' => 'getTtl',
            'restricted_package_name' => 'getRestrictedPackageName',
            'dry_run' => 'getDryRun',
            'content_available' => 'getContentAvailable',
            'priority' => 'getPriority',
        );

        foreach ($dataFields as $fieldName => $getter) {
            if ($message->$getter() != null) {
                $data[$fieldName] = $message->$getter();
            }
        }

        return $data;
    }
1251307
public function message($name, $message = null)
    {
        if (func_num_args() === 2) {
            return $this->_messages[$name] = $message;
        }
        $checker = $this->_classes['checker'];
        return isset($this->_messages[$name]) ? $this->_messages[$name] : $checker::message($name);
    }
362683
private function getMessages(MessageCatalogueInterface $catalogue, string $domain, array $keys)
    {
        $current = $catalogue;
        $previous = [];
        $messages = [];

        while ($current !== null) {
            $all = $current->all($domain);

            if (count($keys) === 0 || in_array('*', $keys)) {
                $currentMessages = array_diff_key($all, $previous);
            } else {
                $currentMessages = [];

                foreach ($keys as $key) {
                    if (substr($key, -1) === '*') {
                        $currentMessages += $this->findWildcardMessages($key, $all, $previous);
                    } else if (!array_key_exists($key, $previous) && array_key_exists($key, $all)) {
                        $currentMessages[$key] = $all[$key];
                    }
                }
            }

            $messages[$current->getLocale()] = $previous = $currentMessages;
            $current = $current->getFallbackCatalogue();
        }

        return $messages;
    }
279246
public static function fromMessage(Message $msg)
    {
        $workerStatus = array();
        while ($msg->peek() !== null) {
            $id = $msg->shift();
            $actionCount = (int) $msg->shift();
            $actionList = array();
            for ($i = 0; $i < $actionCount; $i++) {
                $actionList[] = $msg->shift();
            }

            $workerStatus[$id] = array(
                'id'          => $id,
                'actionList'  => $actionList,
                'current'     => $msg->shift(),
                'ready'       => (bool) $msg->shift(),
                'valid'       => (bool) $msg->shift(),
            );
        }

        return new self($workerStatus);
    }
1194801
protected function getMessagesFromContainer()
    {
        $container = $this->getContainer();

        $namespaces = array();
        foreach ($container as $namespace => $messages) {
            if (isset($this->messages[$namespace])) {
                $this->messages[$namespace] = array_merge($this->messages[$namespace], $messages);
            } else {
                $this->messages[$namespace] = $messages;
            }
            $namespaces[] = $namespace;
        }

        foreach ($namespaces as $namespace) {
            unset($container->{$namespace});
        }
    }
553754
private function addIndentationToMessages($messages)
    {
        if (is_array($messages)) {
            array_walk(
                $messages,
                function ($message) {
                    return $this->indentation . $message;
                }
            );
            return $messages;
        } else {
            $messages = $this->indentation . $messages;
            return $messages;
        }
    }
1091170
public function getMessages($preserveMessages = false) {
        if ($this->hasMessages()) {
            $messages = self::$_store->messages;
            if (!$preserveMessages) {
                $this->clearMessages();
            }
            return $messages;
        }
        return array();
    }
451604
protected function success($messages = null)
	{
		$data = $this->getStatusData('success', $messages);
		return $this->jsonResponse($data, 200);
	}