JamesMoss\Flywheel\Repository::delete PHP Метод

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

Delete a document from the repository using its ID.
public delete ( mixed $id ) : boolean
$id mixed The ID of the document (or the document itself) to delete
Результат boolean True if deleted, false if not.
    public function delete($id)
    {
        if ($id instanceof DocumentInterface) {
            $id = $id->getId();
        }
        $path = $this->getPathForDocument($id);
        return unlink($path);
    }

Usage Example

Пример #1
0
 public function testDeletingDocuments()
 {
     $config = new Config('/tmp/flywheel');
     $repo = new Repository('_pages', $config);
     $id = 'delete_test';
     $name = $id . '.json';
     $path = '/tmp/flywheel/_pages/' . $name;
     file_put_contents($path, '');
     $this->assertTrue(is_file($path));
     $repo->delete($id);
     $this->assertFalse(is_file($path));
 }