Skip to content

Commit

Permalink
Merge pull request #5713 from WoltLab/notice-form-node
Browse files Browse the repository at this point in the history
Add a form node for showing notices
  • Loading branch information
BurntimeX authored Nov 22, 2023
2 parents fb97af0 + 830bc12 commit f53ad96
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace wcf\system\form\builder;

/**
* Form node that shows a notice.
*
* @author Marcel Werk
* @copyright 2001-2023 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.1
*/
class NoticeFormNode extends LanguageItemFormNode
{
protected NoticeFormNodeType $type = NoticeFormNodeType::Info;

/**
* @inheritDoc
*/
public function getHtml()
{
return '<woltlab-core-notice type="' . $this->getType()->toString() . '">' . parent::getHtml() . '</woltlab-core-notice>';
}

/**
* Sets the type of this notice.
*/
public function type(NoticeFormNodeType $type): static
{
$this->type = $type;

return $this;
}

public function getType(): NoticeFormNodeType
{
return $this->type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace wcf\system\form\builder;

/**
* Defines the available types for the notice form node.
*
* @author Marcel Werk
* @copyright 2001-2023 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.1
*/
enum NoticeFormNodeType
{
case Info;
case Success;
case Warning;
case Error;

public function toString(): string
{
return match ($this) {
self::Info => 'info',
self::Success => 'success',
self::Warning => 'warning',
self::Error => 'error',
};
}
}

0 comments on commit f53ad96

Please sign in to comment.