Loading app/Common.php +32 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ declare(strict_types=1); use App\Libraries\View; use ViewThemes\Theme; /** * The goal of this file is to allow developers a location where they can overwrite core procedural functions and * replace them with their own. This file is loaded during the bootstrap process and is called during the frameworks Loading @@ -12,3 +15,32 @@ declare(strict_types=1); * * @link: https://codeigniter4.github.io/CodeIgniter4/ */ if (! function_exists('view')) { /** * Grabs the current RendererInterface-compatible class and tells it to render the specified view. Simply provides a * convenience method that can be used in Controllers, libraries, and routed closures. * * NOTE: Does not provide any escaping of the data, so that must all be handled manually by the developer. * * @param array<string, mixed> $data * @param array<string, mixed> $options Unused - reserved for third-party extensions. */ function view(string $name, array $data = [], array $options = []): string { $path = Theme::path(); /** @var CodeIgniter\View\View $renderer */ $renderer = single_service('renderer', $path); $saveData = config(View::class)->saveData; if (array_key_exists('saveData', $options)) { $saveData = (bool) $options['saveData']; unset($options['saveData']); } return $renderer->setData($data, 'raw') ->render($name, $options, $saveData); } } app/Config/Autoload.php +2 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ class Autoload extends AutoloadConfig 'Modules\Fediverse' => ROOTPATH . 'modules/Fediverse/', 'Config' => APPPATH . 'Config/', 'ViewComponents' => APPPATH . 'Libraries/ViewComponents/', 'ViewThemes' => APPPATH . 'Libraries/ViewThemes/', 'Themes' => ROOTPATH . 'themes', ]; /** Loading app/Config/ViewComponents.php +6 −8 Original line number Diff line number Diff line Loading @@ -9,14 +9,12 @@ use ViewComponents\Config\ViewComponents as ViewComponentsConfig; class ViewComponents extends ViewComponentsConfig { /** * @var array<string, string> * @var string[] */ public array $lookupModules = [ APP_NAMESPACE => APPPATH, 'Modules\Admin' => ROOTPATH . 'modules/Admin/', 'Modules\Auth' => ROOTPATH . 'modules/Auth/', 'Modules\Analytics' => ROOTPATH . 'modules/Analytics/', 'Modules\Install' => ROOTPATH . 'modules/Install/', 'Modules\Fediverse' => ROOTPATH . 'modules/Fediverse/', public array $lookupPaths = [ ROOTPATH . 'themes/cp_app/', ROOTPATH . 'themes/cp_admin/', ROOTPATH . 'themes/cp_auth/', ROOTPATH . 'themes/cp_install/', ]; } app/Controllers/BaseController.php +5 −8 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use CodeIgniter\Controller; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; use ViewThemes\Theme; /** * Class BaseController Loading @@ -19,14 +20,6 @@ use Psr\Log\LoggerInterface; */ class BaseController extends Controller { /** * An array of helpers to be loaded automatically upon class instantiation. These helpers will be available to all * other controllers that extend BaseController. * * @var string[] */ protected $helpers = ['auth', 'svg', 'components', 'misc']; /** * Constructor. */ Loading @@ -35,7 +28,11 @@ class BaseController extends Controller ResponseInterface $response, LoggerInterface $logger ): void { $this->helpers = array_merge($this->helpers, ['auth', 'svg', 'components', 'misc']); // Do Not Edit This Line parent::initController($request, $response, $logger); Theme::setTheme('app'); } } app/Controllers/HomeController.php +1 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ class HomeController extends BaseController $data = [ 'podcasts' => $allPodcasts, ]; return view('home', $data); } } Loading
app/Common.php +32 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ declare(strict_types=1); use App\Libraries\View; use ViewThemes\Theme; /** * The goal of this file is to allow developers a location where they can overwrite core procedural functions and * replace them with their own. This file is loaded during the bootstrap process and is called during the frameworks Loading @@ -12,3 +15,32 @@ declare(strict_types=1); * * @link: https://codeigniter4.github.io/CodeIgniter4/ */ if (! function_exists('view')) { /** * Grabs the current RendererInterface-compatible class and tells it to render the specified view. Simply provides a * convenience method that can be used in Controllers, libraries, and routed closures. * * NOTE: Does not provide any escaping of the data, so that must all be handled manually by the developer. * * @param array<string, mixed> $data * @param array<string, mixed> $options Unused - reserved for third-party extensions. */ function view(string $name, array $data = [], array $options = []): string { $path = Theme::path(); /** @var CodeIgniter\View\View $renderer */ $renderer = single_service('renderer', $path); $saveData = config(View::class)->saveData; if (array_key_exists('saveData', $options)) { $saveData = (bool) $options['saveData']; unset($options['saveData']); } return $renderer->setData($data, 'raw') ->render($name, $options, $saveData); } }
app/Config/Autoload.php +2 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,8 @@ class Autoload extends AutoloadConfig 'Modules\Fediverse' => ROOTPATH . 'modules/Fediverse/', 'Config' => APPPATH . 'Config/', 'ViewComponents' => APPPATH . 'Libraries/ViewComponents/', 'ViewThemes' => APPPATH . 'Libraries/ViewThemes/', 'Themes' => ROOTPATH . 'themes', ]; /** Loading
app/Config/ViewComponents.php +6 −8 Original line number Diff line number Diff line Loading @@ -9,14 +9,12 @@ use ViewComponents\Config\ViewComponents as ViewComponentsConfig; class ViewComponents extends ViewComponentsConfig { /** * @var array<string, string> * @var string[] */ public array $lookupModules = [ APP_NAMESPACE => APPPATH, 'Modules\Admin' => ROOTPATH . 'modules/Admin/', 'Modules\Auth' => ROOTPATH . 'modules/Auth/', 'Modules\Analytics' => ROOTPATH . 'modules/Analytics/', 'Modules\Install' => ROOTPATH . 'modules/Install/', 'Modules\Fediverse' => ROOTPATH . 'modules/Fediverse/', public array $lookupPaths = [ ROOTPATH . 'themes/cp_app/', ROOTPATH . 'themes/cp_admin/', ROOTPATH . 'themes/cp_auth/', ROOTPATH . 'themes/cp_install/', ]; }
app/Controllers/BaseController.php +5 −8 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use CodeIgniter\Controller; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; use ViewThemes\Theme; /** * Class BaseController Loading @@ -19,14 +20,6 @@ use Psr\Log\LoggerInterface; */ class BaseController extends Controller { /** * An array of helpers to be loaded automatically upon class instantiation. These helpers will be available to all * other controllers that extend BaseController. * * @var string[] */ protected $helpers = ['auth', 'svg', 'components', 'misc']; /** * Constructor. */ Loading @@ -35,7 +28,11 @@ class BaseController extends Controller ResponseInterface $response, LoggerInterface $logger ): void { $this->helpers = array_merge($this->helpers, ['auth', 'svg', 'components', 'misc']); // Do Not Edit This Line parent::initController($request, $response, $logger); Theme::setTheme('app'); } }
app/Controllers/HomeController.php +1 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ class HomeController extends BaseController $data = [ 'podcasts' => $allPodcasts, ]; return view('home', $data); } }