Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| ComposerVendorHtaccessCreator | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| onEvent | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Copyright (C) 2017 Kunal Mehta <legoktm@debian.org> |
| 4 | * |
| 5 | * @license GPL-2.0-or-later |
| 6 | * @file |
| 7 | */ |
| 8 | |
| 9 | namespace MediaWiki\Composer; |
| 10 | |
| 11 | /** |
| 12 | * Creates a .htaccess in the vendor/ directory |
| 13 | * to prevent web access. |
| 14 | * |
| 15 | * This class runs *outside* of the normal MediaWiki |
| 16 | * environment and cannot depend upon any MediaWiki |
| 17 | * code. |
| 18 | */ |
| 19 | class ComposerVendorHtaccessCreator { |
| 20 | |
| 21 | /** |
| 22 | * Handle post-install-cmd and post-update-cmd hooks |
| 23 | */ |
| 24 | public static function onEvent() { |
| 25 | $fname = dirname( dirname( __DIR__ ) ) . "/vendor/.htaccess"; |
| 26 | if ( file_exists( $fname ) ) { |
| 27 | // Already exists |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | file_put_contents( $fname, |
| 32 | "Require all denied\n" . |
| 33 | "Satisfy All\n" ); |
| 34 | } |
| 35 | } |