Back to CMSApplication class

Method execute

public void
execute
()
Execute the application.
Returns
  • void
Since
  • 3.2

Method execute - Source code

/**
 * Execute the application.
 *
 * @return  void
 *
 * @since   3.2
 */
public function execute()
{
    try {
        $this->sanityCheckSystemVariables();
        $this->setupLogging();
        $this->createExtensionNamespaceMap();
        // Perform application routines.
        $this->doExecute();
        // If we have an application document object, render it.
        if ($this->document instanceof \Joomla\CMS\Document\Document) {
            // Render the application output.
            $this->render();
        }
        // If gzip compression is enabled in configuration and the server is compliant, compress the output.
        if ($this->get('gzip') && !ini_get('zlib.output_compression') && ini_get('output_handler') !== 'ob_gzhandler') {
            $this->compress();
            // Trigger the onAfterCompress event.
            $this->triggerEvent('onAfterCompress');
        }
    } catch (\Throwable $throwable) {
        /** @var ErrorEvent $event */
        $event = AbstractEvent::create('onError', ['subject' => $throwable, 'eventClass' => ErrorEvent::class, 'application' => $this]);
        // Trigger the onError event.
        $this->triggerEvent('onError', $event);
        ExceptionHandler::handleException($event->getError());
    }
    // Trigger the onBeforeRespond event.
    $this->getDispatcher()->dispatch('onBeforeRespond');
    // Send the application response.
    $this->respond();
    // Trigger the onAfterRespond event.
    $this->getDispatcher()->dispatch('onAfterRespond');
}