@manuth/woltlab-compiler
Version:
A compiler for generating WoltLab-Package `.tar` Archives and other WoltLab-Package Components
109 lines • 3 kB
JavaScript
import { ListenerEnvironment } from "./ListenerEnvironment.js";
/**
* Represents a component which listens to specific events.
*/
export class Listener {
/**
* Initializes a new instance of the {@link Listener `Listener`} class.
*
* @param options
* The options of the listener.
*/
constructor(options) {
/**
* The environment to install the listener to.
*/
this.environment = ListenerEnvironment.FrontEnd;
/**
* A number indicating the execution order of the event-listener.
*/
this.executionOrder = null;
/**
* The permissions of which the active user must have at least one in order to execute the listener.
*/
this.permissions = [];
/**
* The options of which at least one must be enabled in order to execute the listener.
*/
this.options = [];
this.Name = options.Name;
if ((options.Environment !== null) &&
(options.Environment !== undefined)) {
this.Environment = options.Environment;
}
this.EventName = options.EventName;
if ((options.ExecutionOrder !== null) &&
(options.ExecutionOrder !== undefined)) {
this.ExecutionOrder = options.ExecutionOrder;
}
if ((options.Permissions !== null) &&
(options.Permissions !== undefined)) {
this.Permissions.push(...options.Permissions);
}
if ((options.Options !== null) &&
(options.Options !== undefined)) {
this.Options.push(...options.Options);
}
}
/**
* Gets or sets the name of the listener.
*/
get Name() {
return this.name;
}
/**
* @inheritdoc
*/
set Name(value) {
this.name = value;
}
/**
* Gets or sets the environment to install the listener to.
*/
get Environment() {
return this.environment;
}
/**
* @inheritdoc
*/
set Environment(value) {
this.environment = value;
}
/**
* Gets or sets the name of the event to listen to.
*/
get EventName() {
return this.eventName;
}
/**
* @inheritdoc
*/
set EventName(value) {
this.eventName = value;
}
/**
* Gets or sets a number indicating the execution order of the event-listener.
*/
get ExecutionOrder() {
return this.executionOrder;
}
/**
* @inheritdoc
*/
set ExecutionOrder(value) {
this.executionOrder = value;
}
/**
* Gets the permissions of which the active user must have at least one in order to execute the listener.
*/
get Permissions() {
return this.permissions;
}
/**
* Gets the options of which at least one must be enabled in order to execute the listener.
*/
get Options() {
return this.options;
}
}
//# sourceMappingURL=Listener.js.map