Elgg  Version 6.0
PluginException.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Exceptions;
4 
12 class PluginException extends Exception {
13 
14  public \ElggPlugin $plugin;
15 
19  public function __construct(string $message = '', int $code = 0, \Throwable $previous = null) {
20  if (!$message) {
21  $message = elgg_echo('ElggPlugin:Error');
22  }
23 
24  parent::__construct($message, $code, $previous);
25  }
26 
38  public static function factory(array $options = []): self {
39  $message = $options['message'] ?? '';
40  $code = $options['code'] ?? 0;
41  $previous = $options['previous'] ?? null;
42 
43  $exception = new static($message, $code, $previous);
44 
45  $plugin = $options['plugin'] ?? null;
46  if ($plugin instanceof \ElggPlugin) {
47  $exception->plugin = $plugin;
48  }
49 
50  return $exception;
51  }
52 }
Plugin class containing helper functions for plugin activation/deactivation, dependency checking capa...
Definition: ElggPlugin.php:17
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
Definition: language.php:20
Base exception of exceptions in the Elgg system.
Definition: Exception.php:11
static factory(array $options=[])
Create a new instance of a PluginException.
__construct(string $message= '', int $code=0,\Throwable $previous=null)
{}
$exception
Definition: error.php:15