65 parent::initializeAttributes();
67 $this->attributes[
'subtype'] =
'plugin';
109 public function save() : bool {
113 $this->attributes[
'owner_guid'] =
$site->guid;
114 $this->attributes[
'container_guid'] =
$site->guid;
129 return parent::save();
174 if (isset($this->path)) {
189 return $this->
getPath() .
'languages/';
204 if ($this->static_config === null) {
205 $this->static_config = [];
208 $this->static_config = $this->
includeFile(self::STATIC_CONFIG_FILENAME);
210 elgg_log($ex, \Psr\Log\LogLevel::ERROR);
261 $old_priority = $old_priority ? : 1;
262 $max_priority =
_elgg_services()->plugins->getMaxPriority() ? : 1;
332 'plugin_id' => $this->
getID(),
339 elgg_log(
'Plugin settings cannot store arrays.',
'ERROR');
390 $this->
logDeprecatedMessage(__METHOD__ .
' is deprecated use \ElggUser::getPluginSetting()',
'4.0');
412 $this->
logDeprecatedMessage(__METHOD__ .
' is deprecated use \ElggUser::setPluginSetting()',
'4.0');
433 $this->
logDeprecatedMessage(__METHOD__ .
' is deprecated use \ElggUser::removePluginSetting()',
'4.0');
440 return $user->removePluginSetting($this->
getID(), $name);
454 $delete = Delete::fromTable(
'private_settings');
499 if (!$this->
getID()) {
500 throw PluginException::factory([
501 'message' =>
elgg_echo(
'ElggPlugin:MissingID', [$this->guid]),
508 if (file_exists($this->
getPath() .
'start.php')) {
509 throw PluginException::factory([
510 'message' =>
elgg_echo(
'ElggPlugin:StartFound', [$this->
getID()]),
522 if (isset($this->activated)) {
589 'plugin_id' => $this->
getID(),
590 'plugin_entity' => $this,
612 elgg_log($ex, \Psr\Log\LogLevel::ERROR);
618 if ($return ===
false) {
624 _elgg_services()->logger->notice(
"Plugin {$this->getID()} has been activated");
637 return (array)
elgg_extract(
'dependencies', $plugin_config, []);
653 $this->assertcanDeactivate();
673 foreach ($active_plugins as
$plugin) {
674 $dependencies = $plugin->getDependencies();
675 if (!array_key_exists($this->
getID(), $dependencies)) {
680 $dependents[$plugin->getID()] =
$plugin;
684 if (empty($dependents)) {
689 $css_id = preg_replace(
'/[^a-z0-9-]/i',
'-', $plugin->
getID());
693 'href' =>
"#{$css_id}",
698 throw PluginException::factory([
720 'plugin_id' => $this->
getID(),
721 'plugin_entity' => $this,
725 if ($return ===
false) {
735 _elgg_services()->logger->notice(
"Plugin {$this->getID()} has been deactivated");
751 if (!is_subclass_of($bootstrap, \
Elgg\PluginBootstrapInterface::class)) {
752 throw PluginException::factory([
753 'message' =>
elgg_echo(
'LogicException:InterfaceNotImplemented', [
755 \
Elgg\PluginBootstrapInterface::class
761 return new $bootstrap($this,
elgg());
764 return new \Elgg\DefaultPluginBootstrap($this,
elgg());
776 $autoload_file =
'vendor/autoload.php';
781 $autoloader = Includer::requireFileOnce(
"{$this->getPath()}{$autoload_file}");
783 if (!$autoloader instanceof \Composer\Autoload\ClassLoader) {
787 $autoloader->unregister();
790 $autoloader->register(
false);
801 public function register():
void {
852 $filepath =
"{$this->getPath()}{$filename}";
856 'ElggPlugin:Exception:CannotIncludeFile',
857 [$filename, $this->
getID(), $this->guid, $this->
getPath()]
860 throw PluginException::factory([
867 $ret = Includer::requireFile($filepath);
870 'ElggPlugin:Exception:IncludeFileThrew',
871 [$filename, $this->
getID(), $this->guid, $this->
getPath()]
874 throw PluginException::factory([
892 return is_file(
"{$this->getPath()}{$filename}");
902 if (!$this->
canReadFile(self::STATIC_CONFIG_FILENAME)) {
908 if (ob_get_clean() !==
'') {
909 throw PluginException::factory([
910 'message' =>
elgg_echo(
'ElggPlugin:activate:ConfigSentOutput'),
918 throw PluginException::factory([
919 'message' =>
elgg_echo(
'ElggPlugin:activate:BadConfigFormat'),
931 $services_path = $this->
getPath() . self::PUBLIC_SERVICES_FILENAME;
932 if (!is_file($services_path)) {
936 $services = Includer::includeFile($services_path);
937 foreach ($services as
$name => $definition) {
958 $views->mergeViewsSpec($spec);
962 if (!
$views->registerPluginViews($this->getPath())) {
963 $msg =
elgg_echo(
'ElggPlugin:Exception:CannotRegisterViews', [$this->
getID(), $this->guid, $this->
getPath()]);
965 throw PluginException::factory([
981 if (!isset($entity[
'type']) || !isset($entity[
'subtype'])) {
987 elgg_deprecated_notice(
"Registering the [{$entity['type']}-{$entity['subtype']}] entity as searchable should be done in the capabilities section of your elgg-plugin.php.",
'4.1');
992 $capabilities =
elgg_extract(
'capabilities', $entity, []);
993 foreach ($capabilities as $capability =>
$value) {
994 _elgg_services()->entity_capabilities->setCapability($entity[
'type'], $entity[
'subtype'], $capability,
$value);
1010 foreach ($spec as
$action => $action_spec) {
1011 if (!is_array($action_spec)) {
1020 $handler =
"$root_path/actions/{$action}.php";
1037 foreach ($spec as
$name => $route_spec) {
1038 if (!is_array($route_spec)) {
1042 $routes->register(
$name, $route_spec);
1055 foreach ($spec as $widget_id => $widget_definition) {
1056 if (!is_array($widget_definition)) {
1059 if (!isset($widget_definition[
'id'])) {
1060 $widget_definition[
'id'] = $widget_id;
1065 $widgets->registerType($definition);
1091 if (!is_dir($languages_path)) {
1095 _elgg_services()->translator->registerTranslations($languages_path);
1104 _elgg_services()->autoloadManager->addClasses(
"{$this->getPath()}classes");
1116 if (isset($entity[
'type'], $entity[
'subtype'], $entity[
'class'])) {
1117 _elgg_services()->entityTable->setEntityClass($entity[
'type'], $entity[
'subtype'], $entity[
'class']);
1131 if (isset($entity[
'type'], $entity[
'subtype'], $entity[
'class'])) {
1132 _elgg_services()->entityTable->setEntityClass($entity[
'type'], $entity[
'subtype']);
1147 foreach ($spec as
$name => $types) {
1148 foreach ($types as
$type => $callbacks) {
1149 foreach ($callbacks as $callback => $hook_spec) {
1150 if (!is_array($hook_spec)) {
1154 $unregister = (bool)
elgg_extract(
'unregister', $hook_spec,
false);
1157 $hooks->unregisterHandler(
$name,
$type, $callback);
1178 foreach ($spec as
$name => $types) {
1179 foreach ($types as
$type => $callbacks) {
1180 foreach ($callbacks as $callback => $hook_spec) {
1181 if (!is_array($hook_spec)) {
1185 $unregister = (bool)
elgg_extract(
'unregister', $hook_spec,
false);
1188 $events->unregisterHandler(
$name,
$type, $callback);
1210 foreach (
$extensions as $extention => $extention_spec) {
1211 if (!is_array($extention_spec)) {
1215 $unextend = (bool)
elgg_extract(
'unextend', $extention_spec,
false);
1218 $views->unextendView($src_view, $extention);
1238 foreach ($spec as $tool_name => $tool_options) {
1239 if (!is_array($tool_options)) {
1243 $unregister = (bool)
elgg_extract(
'unregister', $tool_options,
false);
1246 $tools->unregister($tool_name);
1248 $tools->register($tool_name, $tool_options);
1261 foreach ($spec as $view_name =>
$options) {
1291 if ($callback ===
false) {
1293 }
elseif ($callback ===
true) {
1312 if (array_key_exists(
$name, $this->attributes)) {
1313 return $this->attributes[
$name];
1317 if (in_array(
$name, [
'title',
'description'])) {
1318 return parent::__get(
$name);
1342 if (array_key_exists(
$name, $this->attributes)) {
1344 if ((array_key_exists(
'guid', $this->attributes)) && (
$name ==
'guid')) {
1354 if (in_array(
$name, [
'title',
'description'])) {
1402 public function cache($persist =
true) {
1405 parent::cache($persist);
1416 parent::invalidateCache();
1427 if (isset($this->composer)) {
1431 $this->composer = new \Elgg\Plugin\Composer($this);
1462 $this->
getComposer()->assertActivePluginConflicts();
1464 $this->
getComposer()->assertRequiredPhpExtensions();
1478 $must_be_active =
elgg_extract(
'must_be_active', $plugin_dep,
true);
1483 if ($must_be_active && (!$dependent_plugin instanceof \
ElggPlugin || !$dependent_plugin->isActive())) {
1484 throw PluginException::factory([
1490 if ($dependent_plugin instanceof \
ElggPlugin &&
$position && $dependent_plugin->isActive()) {
1492 throw PluginException::factory([
1497 throw PluginException::factory([
1526 if (in_array($this->
getID(), Plugins::BUNDLED_PLUGINS)) {
1563 return (
string) $this->
getComposer()->getConfiguration()->description();
1574 return (
string) $this->
getComposer()->getConfiguration()->support()->source();
1585 return (
string) $this->
getComposer()->getConfiguration()->support()->issues();
1596 return (
string) $this->
getComposer()->getConfiguration()->homepage();
1607 return (array) $this->
getComposer()->getConfiguration()->authors();
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags...
registerViews()
Registers the plugin's views.
registerEntities()
Registers the plugin's entities.
getID()
Returns the ID (dir name) of this plugin.
elgg_get_release()
Get the current Elgg release.
elgg_get_plugins(string $status= 'active')
Returns an ordered list of plugins.
registerActions()
Registers the plugin's actions provided in the plugin config file.
if(!$user||!$user->canDelete()) $name
$params
Saves global plugin settings.
getAllPrivateSettings()
Returns all private settings.
getLanguagesPath()
Returns the plugin's languages directory full path with trailing slash.
registerClasses()
Registers the plugin's classes.
assertCanDeactivate()
Asserts if a plugin can be deactivated.
elgg_deprecated_notice(string $msg, string $dep_version)
Log a notice about deprecated use of a function, view, etc.
const STATIC_CONFIG_FILENAME
removePrivateSetting($name)
Removes private setting.
setSetting(string $name, $value)
Set a plugin setting for the plugin.
elgg_get_plugin_from_id(string $plugin_id)
Elgg plugins library Contains functions for managing plugins.
setPrivateSetting($name, $value)
Adds a private setting to this entity.
getAllSettings()
Returns an array of all settings saved for this plugin.
getUserSetting(string $name, int $user_guid=0, $default=null)
Returns a user's setting for this plugin.
getPrivateSetting($name)
Returns a private setting value.
getConflicts()
Returns an array of projectnames with their conflicting version.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
setUserSetting(string $name, $value, int $user_guid=0)
Sets a user setting for a plugin.
assertValid()
Asserts if a plugin is valid.
registerPublicServices()
Registers the plugin public services.
meetsDependencies()
Checks if dependencies are met.
unsetSetting(string $name)
Removes a plugin setting name and value.
getDescription()
Return the description.
registerRoutes()
Registers the plugin's routes provided in the plugin config file.
setPriority($priority)
Sets the priority of the plugin Returns the new priority or false on error.
activateEntities()
Activates the plugin's entities.
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
elgg_entity_enable_capability(string $type, string $subtype, string $capability)
Enables the capability for a specified type/subtype.
assertCanActivate()
Asserts if a plugin can activate.
const PUBLIC_SERVICES_FILENAME
$plugin_id
Remove all user and plugin settings from the give plugin ID.
elgg_delete_admin_notice(string $id)
Remove an admin notice by ID.
deactivateEntities()
Deactivates the plugin's entities.
canDeactivate()
Checks if this plugin can be deactivated on the current Elgg installation.
elgg_invalidate_caches()
Invalidate all the registered caches.
getDependencies()
Returns an array of dependencies as configured in the static config.
const ADDITIONAL_TEXT_FILES
getDisplayName()
Returns the name from elgg-plugin.php if available, otherwise a nicely formatted ID.
assertStaticConfigValid()
If a static config file is present, is it a serializable array?
const ELGG_IGNORE_ACCESS
elgg_call() flags
assertDependencies()
Assert plugin dependencies.
isActive()
Is this plugin active?
getRepositoryURL()
Returns the repository url.
registerLanguages()
Registers the plugin's languages.
getCategories()
Returns an array with categories.
elgg_is_active_plugin(string $plugin_id)
Returns if a plugin is active for a current site.
setStatus(bool $active)
Sets the plugin to active or inactive.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
A generic parent class for database exceptions.
normalizePriority($priority)
Normalize and validate new priority.
unsetAllSettings()
Removes all settings for this plugin.
getBugTrackerURL()
Returns the bug tracker page.
getStaticConfig($key, $default=null)
Get a value from the plugins's static config file.
if(!$menu instanceof\Elgg\Menu\PreparedMenu) $actions
getWebsite()
Return the website.
getBootstrap()
Bootstrap object.
isValid()
Returns if the plugin is complete, meaning has all required files and Elgg can read them and they mak...
elgg_get_site_entity()
Get the current site entity.
const PRIORITY_SETTING_NAME
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
registerHooks()
Registers the plugin's hooks provided in the plugin config file.
getVersion()
Returns the plugin version.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
registerViewExtensions()
Registers the plugin's view extensions provided in the plugin config file.
activate()
Activates the plugin for the current site.
registerWidgets()
Registers the plugin's widgets provided in the plugin config file.
deactivate()
Deactivates the plugin.
__get($name)
Get an attribute, metadata or private setting value.
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof ElggRelationship) elseif(is_callable([$item, 'getType']))
getComposer()
Returns the composer parser.
canReadFile(string $filename)
Checks whether a plugin file with the given name exists.
registerNotifications()
Registers the plugin's notification events.
registerEvents()
Registers the plugin's events provided in the plugin config file.
getPriority()
Gets the plugin's load priority.
__set($name, $value)
Set a value as attribute, metadata or private setting.
static sanitize($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
_elgg_services()
Get the global service provider.
loadLanguages()
Loads the plugin's translations.
elgg_get_plugins_path()
Get the plugin path for this installation, ending with slash.
getSetting(string $name, $default=null)
Returns a plugin setting.
registerGroupTools()
Registers the plugin's group tools provided in the plugin config file.
canActivate()
Checks if this plugin can be activated on the current Elgg installation.
includeFile(string $filename)
Includes one of the plugins files.
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
static fromId($plugin_id, $path=null)
Load a plugin object from its ID Create a new plugin entity if doesn't exist.
getPath()
Returns the plugin's full path with trailing slash.
getLicense()
Returns the license.
assertPluginDependencies()
Assert required plugins or plugin position.
autoload()
Register plugin classes and require composer autoloader.
unsetAllEntityAndPluginSettings()
Remove all entity and plugin settings for this plugin.
unsetUserSetting(string $name, int $user_guid=0)
Removes a user setting name and value.
registerViewOptions()
Registers the plugin's view options provided in the plugin config file.
$guid
Reset an ElggUpgrade.
getAuthors()
Returns an array of authors.
logDeprecatedMessage(string $message, string $version)
Sends a message about deprecated use of a function, view, etc.