Skip to content

Commit

Permalink
Fix Nette deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar committed May 25, 2024
1 parent 7b07b5a commit 3c82c5f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 38 deletions.
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
"league/mime-type-detection": "^1.11.0",
"monolog/monolog": "^3.2.0",
"nette/application": "^3.1.8",
"nette/di": "^3.0.14",
"nette/forms": "^3.1.8",
"nette/http": "^3.2.1",
"nette/neon": "^3.3.3",
"nette/php-generator": "^4.0.5",
"nette/schema": "^1.2.3",
"nette/utils": "^3.2.8|^4.0.0",
"nette/di": "^3.1.7",
"nette/forms": "^3.1.12",
"nette/http": "^3.2.2",
"nette/neon": "^3.4.1",
"nette/php-generator": "^4.1.1",
"nette/schema": "^1.2.5",
"nette/utils": "^3.2.8|^4.0.2",
"nextras/dbal": "~4.0.5",
"nextras/migrations": "~3.2.0",
"nextras/orm": "~4.0.7",
Expand Down
4 changes: 2 additions & 2 deletions src/UI/Control/BaseControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ protected function getFirewall(): BaseUIFirewall
return $this->firewall ??= $this->getPresenter()->getFirewall();
}

protected function createTemplate(): BaseControlTemplate
protected function createTemplate(string|null $class = null): BaseControlTemplate
{
$templateFactory = $this->getPresenter()->getTemplateFactory();
$template = $templateFactory->createTemplate($this, $this->formatTemplateClass());
$template = $templateFactory->createTemplate($this, $class ?? $this->formatTemplateClass());
assert($template instanceof BaseControlTemplate);

$template->firewall = $this->getFirewall();
Expand Down
5 changes: 4 additions & 1 deletion src/UI/DataGrid/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ private function processForm(Form $form): void
$rows[] = $this->getCellValue($row, $rowPrimaryKey);
}

$ids = array_intersect($rows, $form->getHttpData($form::DATA_TEXT, 'actions[items][]'));
$httpData = $form->getHttpData($form::DataText, 'actions[items][]');
assert(is_array($httpData));

$ids = array_intersect($rows, $httpData);
[, $callback] = $this->globalActions[$action];
$callback($ids, $this);
$this->data = null;
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Form extends NetteForm
* @deprecated Translate values passed into form directly instead
* @internal
*/
public function setTranslator(Translator|null $translator = null): self
public function setTranslator(Translator|null $translator = null): static
{
throw Deprecated::create()
->withMessage('Do not use form built-in translator, translate values passed into form directly.');
Expand Down
40 changes: 20 additions & 20 deletions src/UI/Form/FormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ private function initialize(): void

private function configureDefaultMessages(): void
{
Validator::$messages[NForm::EQUAL] = t('ori.cmf.ui.forms.equal');
Validator::$messages[NForm::NOT_EQUAL] = t('ori.cmf.ui.forms.notEqual');
Validator::$messages[NForm::FILLED] = t('ori.cmf.ui.forms.filled');
Validator::$messages[NForm::BLANK] = t('ori.cmf.ui.forms.blank');
Validator::$messages[NForm::MIN_LENGTH] = t('ori.cmf.ui.forms.minLength');
Validator::$messages[NForm::MAX_LENGTH] = t('ori.cmf.ui.forms.maxLength');
Validator::$messages[NForm::LENGTH] = t('ori.cmf.ui.forms.length');
Validator::$messages[NForm::EMAIL] = t('ori.cmf.ui.forms.email');
Validator::$messages[NForm::Equal] = t('ori.cmf.ui.forms.equal');
Validator::$messages[NForm::NotEqual] = t('ori.cmf.ui.forms.notEqual');
Validator::$messages[NForm::Filled] = t('ori.cmf.ui.forms.filled');
Validator::$messages[NForm::Blank] = t('ori.cmf.ui.forms.blank');
Validator::$messages[NForm::MinLength] = t('ori.cmf.ui.forms.minLength');
Validator::$messages[NForm::MaxLength] = t('ori.cmf.ui.forms.maxLength');
Validator::$messages[NForm::Length] = t('ori.cmf.ui.forms.length');
Validator::$messages[NForm::Email] = t('ori.cmf.ui.forms.email');
Validator::$messages[NForm::URL] = t('ori.cmf.ui.forms.url');
Validator::$messages[NForm::INTEGER] = t('ori.cmf.ui.forms.integer');
Validator::$messages[NForm::FLOAT] = t('ori.cmf.ui.forms.number');
Validator::$messages[NForm::NUMERIC] = t('ori.cmf.ui.forms.number');
Validator::$messages[NForm::MIN] = t('ori.cmf.ui.forms.min');
Validator::$messages[NForm::MAX] = t('ori.cmf.ui.forms.max');
Validator::$messages[NForm::RANGE] = t('ori.cmf.ui.forms.range');
Validator::$messages[NForm::MAX_FILE_SIZE] = t('ori.cmf.ui.forms.maxFileSize');
Validator::$messages[NForm::MAX_POST_SIZE] = t('ori.cmf.ui.forms.maxPostSize');
Validator::$messages[NForm::MIME_TYPE] = t('ori.cmf.ui.forms.mimeType');
Validator::$messages[NForm::IMAGE] = t('ori.cmf.ui.forms.image');
Validator::$messages[SelectBox::VALID] = t('ori.cmf.ui.forms.select');
Validator::$messages[UploadControl::VALID] = t('ori.cmf.ui.forms.upload');
Validator::$messages[NForm::Integer] = t('ori.cmf.ui.forms.integer');
Validator::$messages[NForm::Float] = t('ori.cmf.ui.forms.number');
Validator::$messages[NForm::Numeric] = t('ori.cmf.ui.forms.number');
Validator::$messages[NForm::Min] = t('ori.cmf.ui.forms.min');
Validator::$messages[NForm::Max] = t('ori.cmf.ui.forms.max');
Validator::$messages[NForm::Range] = t('ori.cmf.ui.forms.range');
Validator::$messages[NForm::MaxFileSize] = t('ori.cmf.ui.forms.maxFileSize');
Validator::$messages[NForm::MaxPostSize] = t('ori.cmf.ui.forms.maxPostSize');
Validator::$messages[NForm::MimeType] = t('ori.cmf.ui.forms.mimeType');
Validator::$messages[NForm::Image] = t('ori.cmf.ui.forms.image');
Validator::$messages[SelectBox::Valid] = t('ori.cmf.ui.forms.select');
Validator::$messages[UploadControl::Valid] = t('ori.cmf.ui.forms.upload');
}

public function create(): Form
Expand Down
4 changes: 2 additions & 2 deletions src/UI/Presenter/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ protected function linkToAction(ActionLink|HandleLink $link): string
return $this->link($link->getDestination(), $link->getArguments());
}

protected function createTemplate(): BasePresenterTemplate
protected function createTemplate(string|null $class = null): BasePresenterTemplate
{
$templateFactory = $this->getTemplateFactory();
$template = $templateFactory->createTemplate($this, $this->formatTemplateClass());
$template = $templateFactory->createTemplate($this, $class ?? $this->formatTemplateClass());
assert($template instanceof BasePresenterTemplate);

return $template;
Expand Down
6 changes: 3 additions & 3 deletions src/UI/Routing/ClassRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ final class ClassRoute extends Route

private const UIMeta = [
'action' => [
self::PATTERN => '[a-z][a-z0-9-]*',
self::FILTER_IN => [OriginalRoute::class, 'path2action'],
self::FILTER_OUT => [OriginalRoute::class, 'action2path'],
self::Pattern => '[a-z][a-z0-9-]*',
self::FilterIn => [OriginalRoute::class, 'path2action'],
self::FilterOut => [OriginalRoute::class, 'action2path'],
],
];

Expand Down
4 changes: 2 additions & 2 deletions src/UI/TemplateLocator/Locator/PresenterTemplateLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function getLayoutTemplatePath(Presenter $presenter, string $layoutName):
"@$layoutName",
'Presenter',
self::BreakClasses,
Presenter::DEFAULT_ACTION,
Presenter::DefaultAction,
);
}

Expand All @@ -42,7 +42,7 @@ public function getActionTemplatePath(Presenter $presenter, string $viewName): s
$viewName,
'',
self::BreakClasses,
Presenter::DEFAULT_ACTION,
Presenter::DefaultAction,
);
}

Expand Down

0 comments on commit 3c82c5f

Please sign in to comment.