Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions modules/system/classes/PluginBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ protected function getConfigurationFromYaml($exceptionMessage = null)
$this->loadedYamlConfiguration = [];
}
else {
$this->loadedYamlConfiguration = Yaml::parse(file_get_contents($yamlFilePath));
$this->loadedYamlConfiguration = Yaml::parseFile($yamlFilePath);
if (!is_array($this->loadedYamlConfiguration)) {
throw new SystemException(sprintf('Invalid format of the plugin configuration file: %s. The file should define an array.', $yamlFilePath));
}
Expand Down Expand Up @@ -404,8 +404,6 @@ public function getPluginIdentifier(): string

/**
* Returns the absolute path to this plugin's directory
*
* @return string
*/
public function getPluginPath(): string
{
Expand All @@ -414,7 +412,7 @@ public function getPluginPath(): string
}

$reflection = new ReflectionClass($this);
$this->path = dirname($reflection->getFileName());
$this->path = File::normalizePath(dirname($reflection->getFileName()));

return $this->path;
}
Expand All @@ -435,7 +433,7 @@ public function getPluginVersion(): string
if (
!File::isFile($versionFile)
|| !($versionInfo = Yaml::withProcessor(new VersionYamlProcessor, function ($yaml) use ($versionFile) {
return $yaml->parse(file_get_contents($versionFile));
return $yaml->parseFile($versionFile);
}))
|| !is_array($versionInfo)
) {
Expand All @@ -448,4 +446,25 @@ public function getPluginVersion(): string

return $this->version = trim(key(array_slice($versionInfo, -1, 1)));
}

/**
* Verifies the plugin's dependencies are present and enabled
*/
public function checkDependencies(PluginManager $manager): bool
{
$required = $manager->getDependencies($this);
if (empty($required)) {
return true;
}

foreach ($required as $require) {
$requiredPlugin = $manager->findByIdentifier($require);

if (!$requiredPlugin || $manager->isDisabled($requiredPlugin)) {
return false;
}
}

return true;
}
}
Loading