Install.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace fectfurnilife\administer;
  3. use Yii;
  4. /**
  5. * 应用安装类
  6. * 您可以在这里添加类变量,在配置中的值可以注入进来。
  7. */
  8. class Install implements \fecshop\services\extension\InstallInterface
  9. {
  10. public $version = '1.0.0';
  11. public $test;
  12. /**
  13. * @return mixed|void
  14. */
  15. public function run()
  16. {
  17. if (!$this->installDbSql()) {
  18. return false;
  19. }
  20. if (!$this->copyImageFile()) {
  21. return false;
  22. }
  23. return true;
  24. }
  25. /**
  26. * 进行数据库的初始化
  27. * sql语句执行,多个sql用分号 `;`隔开
  28. */
  29. public function installDbSql()
  30. {
  31. // $sql = "";
  32. // 执行sql, 创建表结构的时候,这个函数会返回0,因此不能以返回值作为return
  33. // Yii::$app->getDb()->createCommand($sql)->execute();
  34. return true;
  35. }
  36. /**
  37. * 复制图片文件到appimage/common/addons/{namespace},如果存在,则会被强制覆盖
  38. */
  39. public function copyImageFile()
  40. {
  41. $sourcePath = Yii::getAlias('@fectfurnilife/app/appimage/common/addons/fectfurnilife');
  42. Yii::$service->extension->administer->copyThemeFile($sourcePath);
  43. return true;
  44. }
  45. }