mirror of
https://github.com/getformwork/formwork.git
synced 2025-01-17 13:38:22 +01:00
Add scheme and title reference to Template
This commit is contained in:
parent
9af3f366c3
commit
eac982350e
@ -5,6 +5,7 @@ namespace Formwork\Templates;
|
||||
use Closure;
|
||||
use Formwork\App;
|
||||
use Formwork\Assets;
|
||||
use Formwork\Schemes\Scheme;
|
||||
use Formwork\Site;
|
||||
use Formwork\Utils\Constraint;
|
||||
use Formwork\Utils\FileSystem;
|
||||
@ -25,7 +26,7 @@ class Template implements Stringable
|
||||
/**
|
||||
* Create a new Template instance
|
||||
*/
|
||||
public function __construct(protected string $name, protected App $app, protected Site $site, protected ViewFactory $viewFactory)
|
||||
public function __construct(protected string $name, protected Scheme $scheme, protected App $app, protected Site $site, protected ViewFactory $viewFactory)
|
||||
{
|
||||
$this->path = $this->app->config()->get('system.templates.path');
|
||||
}
|
||||
@ -40,6 +41,16 @@ class Template implements Stringable
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function scheme(): Scheme
|
||||
{
|
||||
return $this->scheme;
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return $this->scheme->title();
|
||||
}
|
||||
|
||||
public function path(): string
|
||||
{
|
||||
return $this->path;
|
||||
|
@ -2,16 +2,20 @@
|
||||
|
||||
namespace Formwork\Templates;
|
||||
|
||||
use Formwork\Schemes\Schemes;
|
||||
use Formwork\Services\Container;
|
||||
|
||||
class TemplateFactory
|
||||
{
|
||||
public function __construct(protected Container $container)
|
||||
public function __construct(protected Container $container, protected Schemes $schemes)
|
||||
{
|
||||
}
|
||||
|
||||
public function make(string $name): Template
|
||||
{
|
||||
return $this->container->build(Template::class, compact('name'));
|
||||
return $this->container->build(Template::class, [
|
||||
'name' => $name,
|
||||
'scheme' => $this->schemes->get('pages.' . $name),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user