Skip to content

Commit

Permalink
Adapt new yiisoft/widget:^2.0 (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
rustamwin committed Jan 26, 2023
1 parent 46e4e2b commit 1182172
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -26,7 +26,7 @@
"yiisoft/http": "^1.2",
"yiisoft/strings": "^2.0",
"yiisoft/validator": "dev-master",
"yiisoft/widget": "^1.0"
"yiisoft/widget": "^2.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
Expand Down
2 changes: 1 addition & 1 deletion src/Field/Base/BaseField.php
Expand Up @@ -103,7 +103,7 @@ final public function begin(): ?string
return $this->renderOpenContainerAndContent($content);
}

final protected function run(): string
final public function render(): string
{
if ($this->isStartedByBegin) {
$this->isStartedByBegin = false;
Expand Down
6 changes: 3 additions & 3 deletions src/Field/Base/PartsField.php
Expand Up @@ -480,7 +480,7 @@ private function makeContent(string $template, array $parts): string

private function generateLabel(): string
{
$label = Label::widget($this->labelConfig);
$label = Label::widget([], $this->labelConfig);

$labelAttributes = $this->labelAttributes;
if (!empty($labelAttributes)) {
Expand All @@ -506,7 +506,7 @@ private function generateLabel(): string

private function generateHint(): string
{
$hint = Hint::widget($this->hintConfig);
$hint = Hint::widget([], $this->hintConfig);

$hintAttributes = $this->hintAttributes;
if (!empty($hintAttributes)) {
Expand All @@ -532,7 +532,7 @@ private function generateHint(): string

private function generateError(): string
{
$error = Error::widget($this->errorConfig);
$error = Error::widget([], $this->errorConfig);

$errorAttributes = $this->errorAttributes;
if (!empty($errorAttributes)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Field/Part/Error.php
Expand Up @@ -139,7 +139,7 @@ public function messageCallback(?callable $value): self
*
* @return string The generated error tag.
*/
protected function run(): string
public function render(): string
{
$useModel = $this->hasFormModelAndAttribute();

Expand Down
2 changes: 1 addition & 1 deletion src/Field/Part/Hint.php
Expand Up @@ -113,7 +113,7 @@ public function encode(bool $value): self
return $new;
}

protected function run(): string
public function render(): string
{
$content = $this->hasFormModelAndAttribute()
? $this->content ?? $this->getFormAttributeHint()
Expand Down
2 changes: 1 addition & 1 deletion src/Field/Part/Label.php
Expand Up @@ -118,7 +118,7 @@ public function encode(bool $value): self
return $new;
}

protected function run(): string
public function render(): string
{
$useModel = $this->hasFormModelAndAttribute();

Expand Down
6 changes: 3 additions & 3 deletions src/FieldFactory.php
Expand Up @@ -233,7 +233,7 @@ public function label(FormModelInterface $formModel, string $attribute, array $c
$this->labelConfig,
$config,
);
return Label::widget($widgetConfig)->formAttribute($formModel, $attribute);
return Label::widget([], $widgetConfig)->formAttribute($formModel, $attribute);
}

public function hint(FormModelInterface $formModel, string $attribute, array $config = []): Hint
Expand All @@ -242,7 +242,7 @@ public function hint(FormModelInterface $formModel, string $attribute, array $co
$this->hintConfig,
$config,
);
return Hint::widget($widgetConfig)->formAttribute($formModel, $attribute);
return Hint::widget([], $widgetConfig)->formAttribute($formModel, $attribute);
}

public function error(FormModelInterface $formModel, string $attribute, array $config = []): Error
Expand All @@ -251,7 +251,7 @@ public function error(FormModelInterface $formModel, string $attribute, array $c
$this->errorConfig,
$config,
);
return Error::widget($widgetConfig)->formAttribute($formModel, $attribute);
return Error::widget([], $widgetConfig)->formAttribute($formModel, $attribute);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/FormErrors.php
Expand Up @@ -99,9 +99,9 @@ private function renderErrorSummary(array $errors): array

/** @var string[] errors */
foreach ($errors as $error) {
$lines = array_merge($lines, $error);
$lines[] = $error;
}

return $lines;
return array_merge(...$lines);
}
}

0 comments on commit 1182172

Please sign in to comment.