Invision Power Services, Inc. * @copyright (c) Invision Power Services, Inc. * @license https://www.invisioncommunity.com/legal/standards/ * @package Invision Community {subpackage} * @since {date} */ namespace IPS\{app}\extensions\core\Queue; /* To prevent PHP errors (extending class does not exist) revealing path */ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) ) { header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' ); exit; } /** * Background Task */ class _{class} { /** * Parse data before queuing * * @param array $data * @return array */ public function preQueueData( $data ): ?array { return $data; } /** * Run Background Task * * @param mixed $data Data as it was passed to \IPS\Task::queue() * @param int $offset Offset * @return int New offset * @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete */ public function run( $data, $offset ) { } /** * Get Progress * * @param mixed $data Data as it was passed to \IPS\Task::queue() * @param int $offset Offset * @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete * @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete */ public function getProgress( $data, $offset ): array { return array( 'text' => 'Doing something...', 'complete' => 50 ); } /** * Perform post-completion processing * * @param array $data Data returned from preQueueData * @param bool $processed Was anything processed or not? If preQueueData returns NULL, this will be FALSE. * @return void */ public function postComplete( $data, $processed = TRUE ) { } }