vendor/codeages/plugin-bundle/System/PluginRegister.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Codeages\PluginBundle\System;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Yaml\Yaml;
class PluginRegister
{
protected $pluginRootDir;
protected $biz;
public function __construct($rootDir, $pluginBaseDir, $biz = null)
{
$this->rootDir = rtrim($rootDir, "\/");
$this->pluginRootDir = $this->rootDir."/{$pluginBaseDir}";
$this->biz = $biz;
}
public function isPluginRegisted($code)
{
$app = $this->biz->service('CodeagesPluginBundle:AppService')->getAppByCode($code);
return $app ? true : false;
}
public function parseMetas($code)
{
$file = $this->getPluginMetasFile($code);
if (!file_exists($file)) {
throw new \RuntimeException('Plugin metas file (plugin.json) not exist');
}
$metas = json_decode(file_get_contents($file), true);
if (empty($metas)) {
throw new \RuntimeException('Parse plugin metas file failed.');
}
if (empty($metas['code']) || empty($metas['name']) || empty($metas['version']) || empty($metas['support_version'])) {
throw new \RuntimeException('Plugin metas file parameters missing, must have `code`, `name`, `version`, `support_version`.');
}
if ($code !== $metas['code']) {
throw new \RuntimeException("Plugin meta code must equal `{$code}`, but you give `{$metas['code']}`");
}
return $metas;
}
public function executeDatabaseScript($code)
{
$file = $this->getPluginDirectory($code).DIRECTORY_SEPARATOR.'Scripts'.DIRECTORY_SEPARATOR.'database.sql';
if (!file_exists($file)) {
return false;
}
$this->biz['db']->query(file_get_contents($file));
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。