2016-12-10 19:36:01 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Events;
|
|
|
|
|
|
|
|
class RenderingHeader extends Event
|
|
|
|
{
|
|
|
|
public $contents;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new event instance.
|
|
|
|
*
|
2018-02-16 16:25:35 +08:00
|
|
|
* @param array $contents
|
2016-12-10 19:36:01 +08:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct(array &$contents)
|
|
|
|
{
|
2018-02-16 16:25:35 +08:00
|
|
|
// Pass array by reference
|
2016-12-10 19:36:01 +08:00
|
|
|
$this->contents = &$contents;
|
|
|
|
}
|
|
|
|
|
2018-02-16 16:25:35 +08:00
|
|
|
/**
|
|
|
|
* Add content to page footer.
|
|
|
|
*
|
|
|
|
* @param string $content
|
|
|
|
* @return void
|
|
|
|
*/
|
2016-12-10 19:36:01 +08:00
|
|
|
public function addContent($content)
|
|
|
|
{
|
|
|
|
if ($content) {
|
2018-02-16 16:25:35 +08:00
|
|
|
if (! is_string($content)) {
|
2019-03-02 22:58:37 +08:00
|
|
|
throw new \Exception('Can not add non-string content', 1);
|
2016-12-10 19:36:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->contents[] = $content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|