DrupalSetup.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace Hestia\WebApp\Installers\Drupal;
  3. use Hestia\WebApp\Installers\BaseSetup as BaseSetup;
  4. class DrupalSetup extends BaseSetup {
  5. protected $appname = "drupal";
  6. protected $appInfo = [
  7. "name" => "Drupal",
  8. "group" => "cms",
  9. "enabled" => "yes",
  10. "version" => "latest",
  11. "thumbnail" => "drupal-thumb.png",
  12. ];
  13. protected $config = [
  14. "form" => [
  15. "username" => ["type" => "text", "value" => "admin"],
  16. "password" => "password",
  17. "email" => "text",
  18. ],
  19. "database" => true,
  20. "resources" => [
  21. "composer" => ["src" => "drupal/recommended-project", "dst" => "/"],
  22. ],
  23. "server" => [
  24. "nginx" => [
  25. "template" => "drupal-composer",
  26. ],
  27. "php" => [
  28. "supported" => ["8.1", "8.2", "8.3"],
  29. ],
  30. ],
  31. ];
  32. public function install(array $options = null): bool {
  33. parent::install($options);
  34. parent::setup($options);
  35. $this->appcontext->runComposer(
  36. ["require", "-d " . $this->getDocRoot(), "drush/drush"],
  37. $status2,
  38. ["version" => 2, "php_version" => $options["php_version"]],
  39. );
  40. $htaccess_rewrite = '
  41. <IfModule mod_rewrite.c>
  42. RewriteEngine On
  43. RewriteRule ^(.*)$ web/$1 [L]
  44. </IfModule>';
  45. $tmp_configpath = $this->saveTempFile($htaccess_rewrite);
  46. $this->appcontext->runUser(
  47. "v-move-fs-file",
  48. [$tmp_configpath, $this->getDocRoot(".htaccess")],
  49. $result,
  50. );
  51. $this->appcontext->runUser(
  52. "v-run-cli-cmd",
  53. [
  54. "/usr/bin/php" . $options["php_version"],
  55. $this->getDocRoot("/vendor/drush/drush/drush"),
  56. "site-install",
  57. "standard",
  58. "--db-url=mysql://" .
  59. $this->appcontext->user() .
  60. "_" .
  61. $options["database_user"] .
  62. ":" .
  63. $options["database_password"] .
  64. "@" .
  65. $options["database_host"] .
  66. ":3306/" .
  67. $this->appcontext->user() .
  68. "_" .
  69. $options["database_name"] .
  70. "",
  71. "--account-name=" .
  72. $options["username"] .
  73. " --account-pass=" .
  74. $options["password"],
  75. "--site-name=Drupal",
  76. "--site-mail=" . $options["email"],
  77. ],
  78. $status,
  79. );
  80. return $status->code === 0;
  81. }
  82. }