Skip to content

Commit c914e90

Browse files
authored
Remove View::content property and View::set() method (#2073)
1 parent 773c5d4 commit c914e90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+199
-152
lines changed

demos/_includes/Demo.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Atk4\Ui\Js\JsExpression;
1010
use Atk4\Ui\Js\JsFunction;
1111
use Atk4\Ui\View;
12+
use Atk4\Ui\ViewWithContent;
1213

1314
class Demo extends Columns
1415
{
@@ -66,7 +67,7 @@ public function setCodeAndCall(\Closure $fx, string $lang = 'php'): void
6667
$code = $this->extractCodeFromClosure($fx);
6768

6869
$this->highLightCode();
69-
View::addTo(View::addTo($this->left, ['element' => 'pre']), ['element' => 'code'])
70+
ViewWithContent::addTo(View::addTo($this->left, ['element' => 'pre']), ['element' => 'code'])
7071
->addClass('language-' . $lang)
7172
->set($code)
7273
->js(true)->each(new JsFunction(['i, el'], [new JsExpression('hljs.highlightElement(el)')]));

demos/_unit-test/reload.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
use Atk4\Ui\Callback;
1010
use Atk4\Ui\Js\JsReload;
1111
use Atk4\Ui\Loader;
12-
use Atk4\Ui\View;
12+
use Atk4\Ui\ViewWithContent;
1313

1414
/** @var App $app */
1515
require_once __DIR__ . '/../init-app.php';
1616

17-
$v = View::addTo($app, ['ui' => 'segment']);
17+
$v = ViewWithContent::addTo($app, ['ui' => 'segment']);
1818
$v->set('Test');
1919
$v->name = 'reload';
2020

@@ -25,5 +25,5 @@
2525
$cb->setUrlTrigger('c_reload');
2626

2727
Loader::addTo($app, ['cb' => $cb])->set(static function (Loader $p) {
28-
$v = View::addTo($p, ['ui' => 'segment'])->set('loaded');
28+
ViewWithContent::addTo($p, ['ui' => 'segment'])->set('loaded');
2929
});

demos/_unit-test/remove-observer.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Atk4\Ui\Js\JsExpression;
1212
use Atk4\Ui\JsSse;
1313
use Atk4\Ui\View;
14+
use Atk4\Ui\ViewWithContent;
1415

1516
/** @var App $app */
1617
require_once __DIR__ . '/../init-app.php';
@@ -21,7 +22,7 @@
2122
$logInput = View::addTo($app, ['element' => 'input', 'name' => 'log']);
2223
$logInput->setStyle('width', '100%');
2324

24-
$setBoxTextAndStyleFx = static function (View $view, string $text) {
25+
$setBoxTextAndStyleFx = static function (ViewWithContent $view, string $text) {
2526
$view->set($text);
2627
$view->setStyle('width', 'fit-content');
2728
$view->setStyle('padding', '5px');
@@ -30,7 +31,7 @@
3031
};
3132

3233
$addBoxFx = static function ($owner, string $name) use ($setBoxTextAndStyleFx, $logInput) {
33-
$box = View::addTo($owner);
34+
$box = ViewWithContent::addTo($owner);
3435
$setBoxTextAndStyleFx($box, $name . (int) $box->getApp()->tryGetRequestQueryParam('i'));
3536

3637
$box->js(true, new JsExpression(<<<'JS'
@@ -84,7 +85,7 @@
8485

8586
Header::addTo($app, ['API']);
8687

87-
$apiContext = View::addTo($app);
88+
$apiContext = ViewWithContent::addTo($app);
8889
$setBoxTextAndStyleFx($apiContext, 'stateContext');
8990
$apiButton = Button::addTo($app, ['Run slow API']);
9091
$apiButton->on('click', static function () use ($apiButton) {
@@ -99,7 +100,7 @@
99100

100101
Header::addTo($app, ['SSE']);
101102

102-
$sseContext = View::addTo($app);
103+
$sseContext = ViewWithContent::addTo($app);
103104
$sse = JsSse::addTo($app, ['stateContext' => $sseContext]);
104105
$setBoxTextAndStyleFx($sseContext, 'stateContext');
105106
$sseButton = Button::addTo($app, ['Run slow SSE']);

demos/_unit-test/scope-builder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Atk4\Ui\App;
1010
use Atk4\Ui\Form;
1111
use Atk4\Ui\Header;
12-
use Atk4\Ui\View;
12+
use Atk4\Ui\ViewWithContent;
1313

1414
/** @var App $app */
1515
require_once __DIR__ . '/../init-app.php';
@@ -37,7 +37,7 @@
3737

3838
$form->onSubmit(static function (Form $form) use ($model) {
3939
$message = $form->entity->get('qb')->toWords($model);
40-
$view = View::addTo($form)->addClass('atk-scope-builder-response');
40+
$view = ViewWithContent::addTo($form)->addClass('atk-scope-builder-response');
4141
$view->set($message);
4242

4343
return $view;
@@ -137,7 +137,7 @@
137137
EOF, true), \JSON_UNESCAPED_UNICODE);
138138

139139
Header::addTo($app, ['Input:']);
140-
View::addTo($app, ['element' => 'p', 'content' => $expectedInput])->addClass('atk-expected-input-result');
140+
ViewWithContent::addTo($app, ['element' => 'p', 'content' => $expectedInput])->addClass('atk-expected-input-result');
141141

142142
$expectedWord = <<<'EOF'
143143
Project Budget is greater or equal to '{$budget1000Eur}'
@@ -147,4 +147,4 @@
147147
EOF;
148148

149149
Header::addTo($app, ['Word:']);
150-
View::addTo($app, ['element' => 'p', 'content' => $expectedWord])->addClass('atk-expected-word-result');
150+
ViewWithContent::addTo($app, ['element' => 'p', 'content' => $expectedWord])->addClass('atk-expected-word-result');

demos/_unit-test/sse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
use Atk4\Ui\Js\JsExpression;
99
use Atk4\Ui\Js\JsToast;
1010
use Atk4\Ui\JsSse;
11-
use Atk4\Ui\View;
11+
use Atk4\Ui\ViewWithContent;
1212

1313
/** @var App $app */
1414
require_once __DIR__ . '/../init-app.php';
1515

16-
$v = View::addTo($app)->set('This will trigger a network request for testing SSE...');
16+
$v = ViewWithContent::addTo($app)->set('This will trigger a network request for testing SSE...');
1717

1818
$sse = JsSse::addTo($app);
1919
// URL trigger must match phpunit test in SSE provider

demos/_unit-test/virtual-page.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Atk4\Ui\Button;
99
use Atk4\Ui\Form;
1010
use Atk4\Ui\Js\JsToast;
11-
use Atk4\Ui\View;
11+
use Atk4\Ui\ViewWithContent;
1212
use Atk4\Ui\VirtualPage;
1313

1414
/** @var App $app */
@@ -19,10 +19,10 @@
1919
$vp->set(static function (VirtualPage $firstPage) {
2020
$secondVp = VirtualPage::addTo($firstPage);
2121
$secondVp->set(static function (VirtualPage $secondPage) {
22-
View::addTo($secondPage)->set('Second Level Page')->addClass('__atk-behat-test-second');
22+
ViewWithContent::addTo($secondPage)->set('Second Level Page')->addClass('__atk-behat-test-second');
2323
$thirdVp = VirtualPage::addTo($secondPage);
2424
$thirdVp->set(static function (VirtualPage $thirdPage) {
25-
View::addTo($thirdPage)->set('Third Level Page')->addClass('__atk-behat-test-third');
25+
ViewWithContent::addTo($thirdPage)->set('Third Level Page')->addClass('__atk-behat-test-third');
2626
$form = Form::addTo($thirdPage);
2727
$form->addControl('category', [Form\Control\Lookup::class, 'model' => new Category($thirdPage->getApp()->db)]);
2828
$form->onSubmit(static function (Form $form) {
@@ -34,7 +34,7 @@
3434
});
3535
Button::addTo($secondPage, ['Open Third'])->link($thirdVp->getUrl());
3636
});
37-
View::addTo($firstPage)->set('First Level Page')->addClass('__atk-behat-test-first');
37+
ViewWithContent::addTo($firstPage)->set('First Level Page')->addClass('__atk-behat-test-first');
3838
Button::addTo($firstPage, ['Open Second'])->link($secondVp->getUrl());
3939
});
4040

demos/basic/header.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Atk4\Ui\App;
88
use Atk4\Ui\Header;
99
use Atk4\Ui\View;
10+
use Atk4\Ui\ViewWithContent;
1011

1112
/** @var App $app */
1213
require_once __DIR__ . '/../init-app.php';
@@ -19,7 +20,7 @@
1920
Header::addTo($seg, ['H3 Header', 'size' => 3]);
2021
Header::addTo($seg, ['H4 Header', 'size' => 4]);
2122
Header::addTo($seg, ['H5 Header', 'size' => 5, 'class.dividing' => true]);
22-
View::addTo($seg, ['element' => 'p'])->set('This is a following paragraph of text');
23+
ViewWithContent::addTo($seg, ['element' => 'p'])->set('This is a following paragraph of text');
2324

2425
Header::addTo($seg, ['H1', 'size' => 1, 'subHeader' => 'H1 subheader']);
2526
Header::addTo($seg, ['H5', 'size' => 5, 'subHeader' => 'H5 subheader']);

demos/basic/menu.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Atk4\Ui\Header;
1111
use Atk4\Ui\Js\JsToast;
1212
use Atk4\Ui\Menu;
13-
use Atk4\Ui\View;
13+
use Atk4\Ui\ViewWithContent;
1414

1515
/** @var App $app */
1616
require_once __DIR__ . '/../init-app.php';
@@ -65,7 +65,7 @@
6565
$menu = Menu::addTo($app, ['vertical']);
6666
$i = $menu->addItem();
6767
Header::addTo($i, ['size' => 4])->set('Promotions');
68-
View::addTo($i, ['element' => 'p'])->set('Check out our promotions');
68+
ViewWithContent::addTo($i, ['element' => 'p'])->set('Check out our promotions');
6969

7070
// menu without any item should not show
7171
Menu::addTo($app);

demos/basic/view.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Atk4\Ui\Paginator;
1717
use Atk4\Ui\Table;
1818
use Atk4\Ui\View;
19+
use Atk4\Ui\ViewWithContent;
1920
use Atk4\Ui\VirtualPage;
2021

2122
/** @var App $app */
@@ -24,10 +25,10 @@
2425
$img = $app->cdn['atk'] . '/logo.png';
2526

2627
Header::addTo($app, ['Default view has no styling']);
27-
View::addTo($app)->set('just a <div> element');
28+
ViewWithContent::addTo($app)->set('just a <div> element');
2829

2930
Header::addTo($app, ['View can specify CSS class']);
30-
View::addTo($app, ['ui' => 'segment', 'class.raised' => true])->set('Segment');
31+
ViewWithContent::addTo($app, ['ui' => 'segment', 'class.raised' => true])->set('Segment');
3132

3233
Header::addTo($app, ['View can contain stuff']);
3334
Header::addTo(View::addTo($app, ['ui' => 'segment'])
@@ -59,7 +60,7 @@
5960
$plane = View::addTo($app, ['template' => $planeTemplate]);
6061

6162
Header::addTo($app, ['Can be rendered into HTML']);
62-
View::addTo($app, ['ui' => 'segment', 'class.raised' => true, 'element' => 'pre'])->set($plane->renderToHtml());
63+
ViewWithContent::addTo($app, ['ui' => 'segment', 'class.raised' => true, 'element' => 'pre'])->set($plane->renderToHtml());
6364

6465
Header::addTo($app, ['Has a unique global identifier']);
6566
Label::addTo($app, ['Plane ID:', 'detail' => $plane->name]);

demos/data-action/jsactionsgrid.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Atk4\Ui\Header;
1212
use Atk4\Ui\Icon;
1313
use Atk4\Ui\UserAction\ExecutorFactory;
14-
use Atk4\Ui\View;
14+
use Atk4\Ui\ViewWithContent;
1515

1616
// Demo for Model action in Grid
1717

@@ -25,7 +25,7 @@
2525

2626
// creating special menu item for multi_step action
2727
$multiAction = $country->getUserAction('multi_step');
28-
$specialItem = Factory::factory([View::class], ['class' => ['item'], 'content' => 'Multi Step']);
28+
$specialItem = Factory::factory([ViewWithContent::class], ['class' => ['item'], 'content' => 'Multi Step']);
2929
Icon::addTo($specialItem, ['content' => 'window maximize outline']);
3030
// register this menu item in factory
3131
$app->getExecutorFactory()->registerTrigger(ExecutorFactory::TABLE_MENU_ITEM, $specialItem, $multiAction);
@@ -35,18 +35,18 @@
3535
$grid = Grid::addTo($app, ['menu' => false]);
3636
$grid->setModel($country);
3737

38-
$divider = Factory::factory([View::class], ['class' => ['divider'], 'content' => '']);
38+
$divider = Factory::factory([ViewWithContent::class], ['class' => ['divider'], 'content' => '']);
3939

40-
$modelHeader = Factory::factory([View::class], ['class' => ['header'], 'content' => 'Model Actions']);
40+
$modelHeader = Factory::factory([ViewWithContent::class], ['class' => ['header'], 'content' => 'Model Actions']);
4141
Icon::addTo($modelHeader, ['content' => 'database']);
4242

43-
$jsHeader = Factory::factory([View::class], ['class' => ['header'], 'content' => 'JS Actions']);
43+
$jsHeader = Factory::factory([ViewWithContent::class], ['class' => ['header'], 'content' => 'JS Actions']);
4444
Icon::addTo($jsHeader, ['content' => 'file code']);
4545

4646
$grid->addActionMenuItem($jsHeader);
4747
// beside model user action, grid menu items can also execute javascript
4848
$grid->addActionMenuItem('JS Callback', static function () {
49-
return (new View())->set('JS Callback done!');
49+
return (new ViewWithContent())->set('JS Callback done!');
5050
}, 'Are you sure?');
5151

5252
$grid->addActionMenuItem($divider);

0 commit comments

Comments
 (0)