Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
parkerj committed Sep 10, 2023
2 parents d5b0417 + 59eb313 commit 39db9c7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 34 deletions.
18 changes: 8 additions & 10 deletions Http/BaseController.php
Expand Up @@ -9,27 +9,25 @@
use Psr\Http\Message\ServerRequestInterface;
use Qubus\Routing\Controller\Controller;
use Qubus\Routing\Router;
use Qubus\View\Native\NativeLoader;
use Qubus\View\Renderer;

use function Codefy\Framework\Helpers\app;
use function Codefy\Framework\Helpers\config;

class BaseController extends Controller implements RoutingController
{
protected ServerRequestInterface $request;
protected ResponseInterface $response;
protected Router $router;
protected Renderer $view;

public function __construct(
?ServerRequestInterface $request = null,
?ResponseInterface $response = null,
?Router $router = null,
?Renderer $view = null
protected ?ServerRequestInterface $request = null,
protected ?ResponseInterface $response = null,
protected ?Router $router = null,
protected ?Renderer $view = null,

) {
$this->setRequest($request ?? app(name: ServerRequestInterface::class));
$this->response = $response ?? app(name: ResponseInterface::class);
$this->router = $router ?? app(name: 'router');
$this->setView($view ?? app(name: 'view'));
$this->setView($view ?? new NativeLoader(config('view.path')));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Scheduler/BaseTask.php
Expand Up @@ -30,9 +30,9 @@ abstract class BaseTask extends BaseProcessor implements Task

protected TaskId $pid;

protected array $options;
protected array $options = [];

protected bool $truthy;
protected bool $truthy = false;

protected string|null $timeZone = null;

Expand Down
21 changes: 9 additions & 12 deletions View/FenomView.php
Expand Up @@ -7,31 +7,28 @@
use Fenom;
use Fenom\Error\CompileException;
use Fenom\Provider;
use Qubus\Config\ConfigContainer;
use Qubus\Exception\Exception;
use Qubus\View\Renderer;

use function Codefy\Framework\Helpers\config;

final class FenomView implements Renderer
{
private Fenom $view;
private Fenom $fenom;

/**
* @throws Exception
*/
public function __construct(ConfigContainer $config)
public function __construct()
{
$this->view = (new Fenom(
provider: new Provider(template_dir: $config->getConfigKey('view.path'))
$this->fenom = (new Fenom(
provider: new Provider(template_dir: config(key: 'view.path'))
))->setCompileDir(
dir: $config->getConfigKey('view.cache')
)->setOptions(options: $config->getConfigKey('view.options'));
dir: config(key: 'view.cache')
)->setOptions(options: config(key: 'view.options'));
}

/**
* @throws CompileException
*/
public function render(array|string $template, array $data = []): string|array
{
return $this->view->display(template: $template, vars: $data);
return $this->fenom->display(template: $template, vars: $data);
}
}
14 changes: 5 additions & 9 deletions View/FoilView.php
Expand Up @@ -5,26 +5,22 @@
namespace Codefy\Framework\View;

use Foil\Engine;
use Qubus\Config\ConfigContainer;
use Qubus\Exception\Exception;
use Qubus\View\Renderer;

use function Codefy\Framework\Helpers\config;
use function Foil\engine;

final class FoilView implements Renderer
{
private Engine $view;
private Engine $engine;

/**
* @throws Exception
*/
public function __construct(ConfigContainer $config)
public function __construct()
{
$this->view = engine($config->getConfigKey('view.options'));
$this->engine = engine(config(key: 'view.options'));
}

public function render(array|string $template, array $data = []): string|array
{
return $this->view->render(template: $template, data: $data);
return $this->engine->render(template: $template, data: $data);
}
}
2 changes: 1 addition & 1 deletion composer.json
@@ -1,7 +1,7 @@
{
"name": "codefyphp/codefy",
"type": "library",
"description": "CodefyPHP Framework.",
"description": "PHP framework for Domain Driven Development, CQRS, and Event Sourcing.",
"keywords": ["codefy","codefyphp","codefy-php","routing","application","container","framework","php-framework"],
"license": "MIT",
"authors": [
Expand Down

0 comments on commit 39db9c7

Please sign in to comment.