Strongly recommend use Kappa/ThemesManager.
If you use Modules
structure Kappa/ThemesManager is more effective if not that is still better. Forgot on this package it was just attempt. Is deprecated and will not be more developed.
Keeper of app themes.
ldrahnik/theme-keeper requires PHP 5.4 or higher.
Install theme keeper to your project using Composer:
$ composer require ldrahnik/theme-keeper
Register extension in config file
extensions:
themes: ThemeKeeper\DI\ThemeKeeperExtension
themes:
default:
themeDir: %themesDir%/<themeName>
assetsDir: <themeDir>/assets
views:
controls: <themeDir>/controls/<name>/<view>
presenters: <themeDir>/presenters/<name>/<view>
layouts: <themeDir>/@<view>
/**
* @var \ThemeKeeper\ThemeKeeper
* @inject
*/
private $themes;
public function __construct(ThemeKeeper\ThemeKeeper $themes)
{
$this->themes = $themes;
}
public function render()
{
$this->template->setFile($this->themes->getView($this->name, 'controls'));
$this->template->render();
// you can cast getView without getTheme('default') because default name is automatically default
// theme for short use as that, if is not set up name 'default', is choosen first theme in order
}
Is able to set up path via these patterns (don't count patterns through view-keeper - substitution is done successively)
<themeName>
<assetsDir>
<themeDir>
- Template-keeper uses View-keeper but view-keeper as extension have still good use, for example Mail templates are the same for entire app.
- Crossing from small app with view-keeper to something bigger is not hard because is possible to let code as it's, just use another service.