self::ACTION_UPLOAD, 'move' => self::ACTION_MOVE, 'create' => self::ACTION_CREATE, ]; /** * @param HookContainer $hookContainer */ public function __construct( HookContainer $hookContainer ) { $this->hookRunner = new HookRunner( $hookContainer ); } /** * Cache the array of actions * @var int[]|null */ private $allBlockActions = null; /** * @return int[] */ public function getAllBlockActions(): array { // Don't run the hook multiple times in the same request if ( !$this->allBlockActions ) { $this->allBlockActions = self::CORE_BLOCK_ACTIONS; $this->hookRunner->onGetAllBlockActions( $this->allBlockActions ); } if ( count( $this->allBlockActions ) !== count( array_unique( $this->allBlockActions ) ) ) { throw new MWException( 'Blockable action IDs not unique' ); } return $this->allBlockActions; } /** * @param int $actionId * @return string|false */ public function getActionFromId( int $actionId ) { return array_search( $actionId, $this->getAllBlockActions() ); } /** * @param string $action * @return int|bool False if the action is not in the list of blockable actions */ public function getIdFromAction( string $action ) { return $this->getAllBlockActions()[$action] ?? false; } }