getEnvelopes($filterName, $criteria); if (empty($envelopes)) { return ''; } $scripts = $this->renderScripts($envelopes); $styles = json_encode($this->getStyles($envelopes)); $options = $this->renderOptions($envelopes); $notifications = $this->renderEnvelopes($envelopes); $html = << var renderPHPNotifyNotifications = function () { {$options} {$notifications} } if ("undefined" !== typeof PHPNotify) { PHPNotify.addStyles({$styles}, renderPHPNotifyNotifications); } else { renderPHPNotifyNotifications(); } HTML; $this->storage->flush($envelopes); return $html; } /** * @param \Flasher\Prime\Envelope[] $envelopes * * @return string */ public function renderEnvelopes($envelopes) { $html = ''; foreach ($envelopes as $envelope) { $rendererStamp = $envelope->get('Flasher\Prime\Stamp\HandlerStamp'); $renderer = $this->rendererManager->make($rendererStamp->getHandler()); $html .= $renderer->render($envelope).PHP_EOL; } return $html; } /** * @param \Flasher\Prime\Envelope[] $envelopes * * @return string */ public function renderOptions($envelopes) { $html = ''; foreach ($this->getOptions($envelopes) as $option) { $html .= $option.PHP_EOL; } return $html; } /** * @param \Flasher\Prime\Envelope[] $envelopes * * @return string */ public function renderScripts($envelopes) { $html = ''; foreach ($this->getScripts($envelopes) as $file) { $html .= sprintf('', $file).PHP_EOL; } return $html; } }