private function getPluginMetadataIfValid($tmpPluginFolder)
{
$pluginJsonPath = $this->getPathToPluginJson($tmpPluginFolder);
$metadata = file_get_contents($pluginJsonPath);
$metadata = json_decode($metadata);
if (empty($metadata)) {
throw new PluginInstallerException('Plugin is not valid, plugin.json is empty or does not contain valid JSON.');
}
if (empty($metadata->name)) {
throw new PluginInstallerException('Plugin is not valid, the plugin.json file does not specify the plugin name.');
}
if (!preg_match('/^[a-zA-Z0-9_-]+$/', $metadata->name)) {
throw new PluginInstallerException('The plugin name specified in plugin.json contains illegal characters. ' . 'Plugin name can only contain following characters: [a-zA-Z0-9-_].');
}
if (empty($metadata->version)) {
throw new PluginInstallerException('Plugin is not valid, the plugin.json file does not specify the plugin version.');
}
if (empty($metadata->description)) {
throw new PluginInstallerException('Plugin is not valid, the plugin.json file does not specify a description.');
}
return $metadata;
}