Bolt\Stack::delete PHP Метод

delete() публичный Метод

Delete a file from the stack.
public delete ( Bolt\Filesystem\Handler\FileInterface | string $filename )
$filename Bolt\Filesystem\Handler\FileInterface | string
    public function delete($filename)
    {
        $this->initialize();
        try {
            $file = $this->matcher->getFile($filename);
        } catch (FileNotFoundException $e) {
            return;
        }
        foreach ($this->files as $key => $item) {
            if ($item->getFullPath() === $file->getFullPath()) {
                unset($this->files[$key]);
                $this->files = array_values($this->files);
                // normalize indexes
                $this->persist();
                break;
            }
        }
    }

Usage Example

Пример #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::delete