createResult($result, ['path' => $file_directory_path], $visible); } /** * {@inheritdoc} */ public function help() { $paragraphs = []; $paragraphs[] = $this->t("If you have Drupal's private files feature enabled you should move the files directory outside of the web server's document root. Drupal will secure access to files that it renders the link to, but if a user knows the actual system path they can circumvent Drupal's private files feature. You can protect against this by specifying a files directory outside of the webserver root."); return [ '#theme' => 'check_help', '#title' => $this->t('Private files'), '#paragraphs' => $paragraphs, ]; } /** * {@inheritdoc} */ public function evaluate(CheckResult $result) { if ($result->result() != CheckResult::FAIL) { return []; } $paragraphs = []; $paragraphs[] = $this->t('Your files directory is not outside of the server root.'); $paragraphs[] = Link::createFromRoute( $this->t('Edit the files directory path.'), 'system.file_system_settings' ); return [ '#theme' => 'check_evaluation', '#paragraphs' => $paragraphs, '#items' => [], ]; } /** * {@inheritdoc} */ public function evaluatePlain(CheckResult $result) { if ($result->result() != CheckResult::FAIL) { return ''; } return $this->t('Private files directory: @path', ['@path' => $result->findings()['path']]); } /** * {@inheritdoc} */ public function getMessage($result_const) { switch ($result_const) { case CheckResult::SUCCESS: return $this->t('Private files directory is outside the web server root.'); case CheckResult::FAIL: return $this->t('Private files is enabled but the specified directory is not secure outside the web server root.'); default: return $this->t('Unexpected result.'); } } }