Bolt\Stack::isStackable PHP Method

isStackable() public method

Requirements: - File's extension is accepted - File can be matched to filesystem - File is not currently on the stack
public isStackable ( Bolt\Filesystem\Handler\FileInterface | string $filename ) : boolean
$filename Bolt\Filesystem\Handler\FileInterface | string
return boolean
    public function isStackable($filename)
    {
        try {
            $file = $this->matcher->getFile($filename);
        } catch (FileNotFoundException $e) {
            return false;
        }
        if (!in_array($file->getExtension(), $this->acceptedFileTypes)) {
            return false;
        }
        return !$this->contains($file);
    }

Usage Example

Esempio n. 1
0
 public function testSetup()
 {
     $app = $this->getApp();
     $users = $this->getMock('Bolt\\Users', array('getCurrentUser', 'saveUser'), array($app));
     $app['users'] = $users;
     $stack = new Stack($app);
     $stack->add('mytestfile');
     $this->assertTrue($stack->isOnStack('mytestfile'));
     $stack->delete('mytestfile');
     $this->assertFalse($stack->isOnStack('mytestfile'));
     $this->assertFalse($stack->isStackable('mytestfile'));
     $this->assertTrue($stack->isStackable('mytestfile.png'));
 }
All Usage Examples Of Bolt\Stack::isStackable