Contao\CoreBundle\Analyzer\HtaccessAnalyzer::grantsAccess PHP Method

grantsAccess() public method

Checks whether the .htaccess file grants access via HTTP.
public grantsAccess ( ) : boolean
return boolean
    public function grantsAccess()
    {
        $content = array_filter(file($this->file));
        foreach ($content as $line) {
            if ($this->hasRequireGranted($line)) {
                return true;
            }
        }
        return false;
    }

Usage Example

 /**
  * Tests a file that does not grant access.
  */
 public function testDoesNotGrantAccess()
 {
     $file = new SplFileInfo($this->getRootDir() . '/system/modules/foobar/private/.htaccess', 'system/modules/foobar/private', 'system/modules/foobar/private/.htaccess');
     $htaccess = new HtaccessAnalyzer($file);
     $this->assertFalse($htaccess->grantsAccess());
 }