Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: atk4/ui
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b531f60724ae8fbb1875c500e955fc79c6eb13be
Choose a base ref
..
head repository: atk4/ui
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 23a9ce77c1c4f2d2df8095629b252617b2990252
Choose a head ref
1 change: 1 addition & 0 deletions demos/_unit-test/scope-builder.php
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@
$form->onSubmit(function (Form $form) use ($model) {
$message = $form->model->get('qb')->toWords($model);
$view = (new View(['name' => false]))->addClass('atk-scope-builder-response');
$view->setApp($form->getApp());
$view->invokeInit();

$view->set($message);
2 changes: 2 additions & 0 deletions demos/form-control/dropdown-plus.php
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
$message = $app->encodeJson($form->model->get());

$view = new Message('Values: ');
$view->setApp($form->getApp());
$view->invokeInit();
$view->text->addParagraph($message);

@@ -108,6 +109,7 @@
$message = $app->encodeJson($form->model->get());

$view = new Message('Values: ');
$view->setApp($form->getApp());
$view->invokeInit();
$view->text->addParagraph($message);

3 changes: 2 additions & 1 deletion demos/form-control/lookup.php
Original file line number Diff line number Diff line change
@@ -48,7 +48,8 @@
]);

$form->onSubmit(function (Form $form) {
$view = new Message('Select:'); // need in behat test.
$view = new Message('Select:');
$view->setApp($form->getApp());
$view->invokeInit();
$view->text->addParagraph($form->model->ref('country1')->get(Country::hinting()->fieldName()->name) ?? 'null');
$view->text->addParagraph($form->model->ref('country2')->get(Country::hinting()->fieldName()->name) ?? 'null');
1 change: 1 addition & 0 deletions demos/form-control/tree-item-selector.php
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@
];

$view = new Message('Items: ');
$view->setApp($form->getApp());
$view->invokeInit();
$view->text->addParagraph($app->encodeJson($response));

1 change: 1 addition & 0 deletions src/UserAction/StepExecutorTrait.php
Original file line number Diff line number Diff line change
@@ -460,6 +460,7 @@ protected function jsStepSubmit(string $step)
throw $e;
} catch (\Throwable $e) {
$msg = new Message(['Error executing ' . $this->action->caption, 'type' => 'error', 'class.red' => true]);
$msg->setApp($this->getApp());
$msg->invokeInit();
$msg->text->content = $this->getApp()->renderExceptionHtml($e);

11 changes: 5 additions & 6 deletions src/View.php
Original file line number Diff line number Diff line change
@@ -211,7 +211,9 @@ public function link($url, $target = null)
*/
protected function init(): void
{
$this->getApp(); // assert has App
// almost every View needs an App to load a template, so assert App is set upfront
// TODO consider lazy loading the template
$app = $this->getApp();

$addLater = $this->_addLater;
$this->_addLater = null;
@@ -224,7 +226,6 @@ protected function init(): void

if ($this->template === null) {
if ($this->defaultTemplate !== null) {
$app = $this->issetApp() ? $this->getApp() : new App(['catchExceptions' => false, 'alwaysRun' => false]);
$this->template = $app->loadTemplate($this->defaultTemplate);
} else {
if ($this->region !== 'Content' && $this->issetOwner() && $this->getOwner()->template) {
@@ -235,7 +236,7 @@ protected function init(): void
}

if ($this->template !== null && !$this->template->issetApp()) {
$this->template->setApp($this->getApp());
$this->template->setApp($app);
}

foreach ($addLater as [$object, $region]) {
@@ -598,9 +599,7 @@ protected function renderView(): void
$this->template->trySet('_element', $this->element);
}

$app = $this->issetApp() ? $this->getApp() : new App(['catchExceptions' => false, 'alwaysRun' => false]);

if (!$app->isVoidTag($this->element)) {
if (!$this->getApp()->isVoidTag($this->element)) {
$this->template->tryDangerouslySetHtml('_element_end_html', '</' . $this->element . '>');
}