You are here

private function SpiController::getSettingsPermissions in Acquia Connector 8

Same name and namespace in other branches
  1. 8.2 src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::getSettingsPermissions()
  2. 3.x src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::getSettingsPermissions()

Determines if settings.php is read-only.

Return value

bool TRUE if settings.php is read-only, FALSE otherwise.

1 call to SpiController::getSettingsPermissions()
SpiController::get in src/Controller/SpiController.php
Gather site profile information about this site.

File

src/Controller/SpiController.php, line 706

Class

SpiController
SPI Controller class.

Namespace

Drupal\acquia_connector\Controller

Code

private function getSettingsPermissions() {
  $settings_permissions_read_only = TRUE;

  // http://en.wikipedia.org/wiki/File_system_permissions.
  $writes = [
    '2',
    '3',
    '6',
    '7',
  ];
  $settings_file = './' . DrupalKernel::findSitePath(\Drupal::request(), TRUE) . '/settings.php';
  $permissions = mb_substr(sprintf('%o', fileperms($settings_file)), -4);
  foreach ($writes as $bit) {
    if (strpos($permissions, $bit)) {
      $settings_permissions_read_only = FALSE;
      break;
    }
  }
  return $settings_permissions_read_only;
}