add event for rendering header & footer
This commit is contained in:
parent
91ff0fd2a7
commit
05edc193ae
30
app/Events/RenderingFooter.php
Normal file
30
app/Events/RenderingFooter.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
class RenderingFooter extends Event
|
||||||
|
{
|
||||||
|
public $contents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(array &$contents)
|
||||||
|
{
|
||||||
|
// pass array by reference
|
||||||
|
$this->contents = &$contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addContent($content)
|
||||||
|
{
|
||||||
|
if ($content) {
|
||||||
|
if (!is_string($content)) {
|
||||||
|
throw new \Exception("Can not add non-string content", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->contents[] = $content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
31
app/Events/RenderingHeader.php
Normal file
31
app/Events/RenderingHeader.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
class RenderingHeader extends Event
|
||||||
|
{
|
||||||
|
public $contents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(array &$contents)
|
||||||
|
{
|
||||||
|
// pass array by reference
|
||||||
|
$this->contents = &$contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addContent($content)
|
||||||
|
{
|
||||||
|
if ($content) {
|
||||||
|
if (!is_string($content)) {
|
||||||
|
throw new \Exception("Can not add non-string content", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->contents[] = $content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -109,6 +109,12 @@ if (! function_exists('bs_footer')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<script>'.Option::get("custom_js").'</script>';
|
echo '<script>'.Option::get("custom_js").'</script>';
|
||||||
|
|
||||||
|
$extra_contents = [];
|
||||||
|
|
||||||
|
Event::fire(new App\Events\RenderingFooter($extra_contents));
|
||||||
|
|
||||||
|
echo implode(PHP_EOL, $extra_contents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,6 +136,12 @@ if (! function_exists('bs_header')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<style>'.Option::get("custom_css").'</style>';
|
echo '<style>'.Option::get("custom_css").'</style>';
|
||||||
|
|
||||||
|
$extra_contents = [];
|
||||||
|
|
||||||
|
Event::fire(new App\Events\RenderingHeader($extra_contents));
|
||||||
|
|
||||||
|
echo implode(PHP_EOL, $extra_contents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user