Bolt\Configuration\ComposerChecks::checkDir PHP Méthode

checkDir() public méthode

public checkDir ( $location )
    public function checkDir($location)
    {
        // As a last resort we can try to create the directory here:
        if (!is_dir($location)) {
            @mkdir($location, 0777, true);
        }
        if (!is_dir($location)) {
            throw new BootException('The default folder <code>' . $location . "</code> doesn't exist. Make sure it's " . 'present and writable to the user that the web server is using.' . $this->checkSummary());
        } elseif (!is_writable($location)) {
            throw new BootException('The default folder <code>' . $location . "</code> isn't writable. Make sure it's writable to the user that the web server is using." . $this->checkSummary());
        }
    }

Usage Example

 public function testCheckDir()
 {
     $fakeLocation = "/path/to/nowhere";
     $config = new Composer(TEST_ROOT);
     $verifier = new ComposerChecks($config);
     $app['resources'] = $config;
     ResourceManager::$theApp = $app;
     // Check we get an exception if the directory isn't writable
     $this->php->expects($this->at(0))->method('is_dir')->will($this->returnValue(true));
     $this->php->expects($this->at(1))->method('is_dir')->will($this->returnValue(true));
     $this->php->expects($this->any())->method('is_writable')->will($this->returnValue(false));
     $this->setExpectedException('Bolt\\Exception\\LowlevelException');
     $this->expectOutputRegex("/Bolt - Fatal Error/");
     $verifier->checkDir($fakeLocation);
 }
All Usage Examples Of Bolt\Configuration\ComposerChecks::checkDir