Back to FinderIndexCommand class

Method purge

private void
purge
()
Purge the index.
Returns
  • void
Since
  • 3.3

Method purge - Source code

/**
 * Purge the index.
 *
 * @return  void
 *
 * @since   3.3
 */
private function purge()
{
    $this->ioStyle->text(Text::_('FINDER_CLI_INDEX_PURGE'));
    // Load the model.
    $app = $this->getApplication();
    $model = $app->bootComponent('com_finder')->getMVCFactory($app)->createModel('Index', 'Administrator');
    // Attempt to purge the index.
    $return = $model->purge();
    // If unsuccessful then abort.
    if (!$return) {
        $message = Text::_('FINDER_CLI_INDEX_PURGE_FAILED', $model->getError());
        $this->ioStyle->error($message);
        exit;
    }
    $this->ioStyle->text(Text::_('FINDER_CLI_INDEX_PURGE_SUCCESS'));
}