Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a form node for showing notices #5713

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
};
}
}
Loading