|
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace SixShop\Core;
|
|
namespace SixShop\Core;
|
|
|
|
|
|
|
|
|
|
+use Composer\Json\JsonFile;
|
|
|
use Exception;
|
|
use Exception;
|
|
|
use SixShop\Core\Contracts\ExtensionInterface;
|
|
use SixShop\Core\Contracts\ExtensionInterface;
|
|
|
use think\helper\Macroable;
|
|
use think\helper\Macroable;
|
|
@@ -24,10 +25,19 @@ abstract class ExtensionAbstract implements ExtensionInterface
|
|
|
public function getInfo(): array
|
|
public function getInfo(): array
|
|
|
{
|
|
{
|
|
|
if (empty($this->info)) {
|
|
if (empty($this->info)) {
|
|
|
- if (!file_exists($this->getBaseDir() . '/info.php')) {
|
|
|
|
|
- throw new Exception('Extension info file not found, please check the extension directory and info.php file.');
|
|
|
|
|
|
|
+ if (file_exists($this->getBaseDir() . '/info.php')) {
|
|
|
|
|
+ $this->info = require $this->getBaseDir() . '/info.php';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $localConfig = $this->getBaseDir() . '/composer.json';
|
|
|
|
|
+ $file = new JsonFile($localConfig);
|
|
|
|
|
+ $localConfig = $file->read();
|
|
|
|
|
+ $this->info = [
|
|
|
|
|
+ 'id' => static::EXTENSION_ID,
|
|
|
|
|
+ 'name' => $localConfig['name'],
|
|
|
|
|
+ 'description' => $localConfig['description'],
|
|
|
|
|
+ ];
|
|
|
}
|
|
}
|
|
|
- $this->info = require $this->getBaseDir() . '/info.php';
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
return $this->info;
|
|
return $this->info;
|
|
|
}
|
|
}
|