HtaccessGuardStatus
in package
FinalYes
インストーラーの .htaccess 有効化判定(W7)。
現行は「ルート .htaccess の存在」だけを必須チェックしていたが、直アクセス防止は php/lang 等 配置対象すべてで効いていないと意味がない。ここでは配置対象ディレクトリごとの存在有無と サーバ種別(Apache か)から、各ディレクトリの状態(ok/error/warn/skip)を返す。
.htaccess は Apache 系でのみ有効なため、非 Apache(nginx 等)では必須化してインストールを 止めるのは不適切。非 Apache は一律 skip とし、別途サーバ設定を促す運用とする。
ディレクトリの存在確認・サーバ種別判定という副作用(I/O・$_SERVER)は呼び出し側に置き、 本クラスは真偽の組み合わせから状態を導くだけの純粋ロジックとする。
Table of Contents
Constants
- STATUS_ERROR = 'error'
- STATUS_OK = 'ok'
- STATUS_SKIP = 'skip'
- STATUS_WARN = 'warn'
Methods
- evaluate() : array<string, string>
- 配置対象ディレクトリ群を評価し、path => status の連想配列を返す。
- hasBlockingError() : bool
- evaluate() の結果に、インストール続行を妨げる error が含まれるか。
- statusFor() : string
Constants
STATUS_ERROR
public
mixed
STATUS_ERROR
= 'error'
STATUS_OK
public
mixed
STATUS_OK
= 'ok'
STATUS_SKIP
public
mixed
STATUS_SKIP
= 'skip'
STATUS_WARN
public
mixed
STATUS_WARN
= 'warn'
Methods
evaluate()
配置対象ディレクトリ群を評価し、path => status の連想配列を返す。
public
evaluate(array<int, array{path: string, present: bool, required: bool}> $directories, bool $isApache) : array<string, string>
Parameters
- $directories : array<int, array{path: string, present: bool, required: bool}>
- $isApache : bool
-
Apache 系サーバか(.htaccess が有効か)
Return values
array<string, string> —path => STATUS_*
hasBlockingError()
evaluate() の結果に、インストール続行を妨げる error が含まれるか。
public
hasBlockingError(array<string, string> $statuses) : bool
Parameters
- $statuses : array<string, string>
Return values
boolstatusFor()
private
statusFor(bool $present, bool $required, bool $isApache) : string
Parameters
- $present : bool
- $required : bool
- $isApache : bool