2018-08-16 22:30:59 +00:00
|
|
|
<?php
|
2022-03-04 17:10:24 +00:00
|
|
|
|
2018-08-16 22:30:59 +00:00
|
|
|
/*
|
2022-03-04 17:10:24 +00:00
|
|
|
* Copyright (c) 2010-2022 Tim Düsterhus.
|
2018-08-16 22:30:59 +00:00
|
|
|
*
|
|
|
|
* Use of this software is governed by the Business Source License
|
|
|
|
* included in the LICENSE file.
|
|
|
|
*
|
2022-09-17 14:23:02 +00:00
|
|
|
* Change Date: 2026-09-17
|
2018-08-16 22:30:59 +00:00
|
|
|
*
|
|
|
|
* On the date above, in accordance with the Business Source
|
|
|
|
* License, use of this software will be governed by version 2
|
|
|
|
* or later of the General Public License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace chat\system\command;
|
|
|
|
|
2022-03-04 17:10:24 +00:00
|
|
|
use chat\data\room\Room;
|
|
|
|
use wcf\data\user\UserProfile;
|
2018-08-16 22:30:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for Command processors.
|
|
|
|
*/
|
2022-03-04 17:10:24 +00:00
|
|
|
interface ICommand
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Returns whether the command can be used even when
|
|
|
|
* no trigger is configured for it.
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function allowWithoutTrigger();
|
2018-08-16 22:30:59 +00:00
|
|
|
|
2022-03-04 17:10:24 +00:00
|
|
|
/**
|
|
|
|
* Returns the name of the JavaScript module.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getJavaScriptModuleName();
|
2018-08-16 22:30:59 +00:00
|
|
|
|
2022-03-04 17:10:24 +00:00
|
|
|
/**
|
|
|
|
* Returns whether this command theoretically is available
|
|
|
|
* in the given room, for the given user.
|
|
|
|
* If no user is given the active user should be assumed.
|
|
|
|
*
|
|
|
|
* The return value sets a flag for the JavaScript to
|
|
|
|
* consume. You still need to validate() this as well!
|
|
|
|
*
|
|
|
|
* @param Room $room
|
|
|
|
* @param UserProfile $user
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function isAvailable(Room $room, ?UserProfile $user = null);
|
2018-08-16 22:30:59 +00:00
|
|
|
|
2022-03-04 17:10:24 +00:00
|
|
|
/**
|
|
|
|
* Validates the execution of the command with the given parameters
|
|
|
|
* in the given room for the given user.
|
|
|
|
* If no user is given the active user should be assumed.
|
|
|
|
* This method must throw if the command may not be executed in this form.
|
|
|
|
*
|
|
|
|
* @param mixed $parameters
|
|
|
|
* @param Room $room
|
|
|
|
* @param UserProfile $user
|
|
|
|
*/
|
|
|
|
public function validate($parameters, Room $room, ?UserProfile $user = null);
|
2018-08-16 22:30:59 +00:00
|
|
|
|
2022-03-04 17:10:24 +00:00
|
|
|
/**
|
|
|
|
* Executes the command with the given parameters in the given room in
|
|
|
|
* the context of the given user.
|
|
|
|
* If no user is given the active user should be assumed.
|
|
|
|
* This method must throw if the command may not be executed in this form.
|
|
|
|
*
|
|
|
|
* @param mixed $parameters
|
|
|
|
* @param Room $room
|
|
|
|
* @param UserProfile $user
|
|
|
|
*/
|
|
|
|
public function execute($parameters, Room $room, ?UserProfile $user = null);
|
2018-08-16 22:30:59 +00:00
|
|
|
}
|