3.x redesign

This commit is contained in:
Samuel Štancl 2020-06-08 21:20:15 +02:00
parent 857122540f
commit f8f354c323
229 changed files with 201175 additions and 22440 deletions

View file

@ -0,0 +1,86 @@
---
title: Writing Storage Drivers
description: Writing Storage Drivers
extends: _layouts.documentation
section: content
---
# Writing Storage Drivers
If you don't want to use the provided DB/Redis storage drivers, you can write your own driver.
To create a driver, create a class that implements the `Stancl\Tenancy\Contracts\StorageDriver` interface.
Here's an example:
```php
<?php
namespace App\StorageDrivers\MongoDBStorageDriver;
use Stancl\Tenancy\Tenant;
use Stancl\Tenancy\Contracts\StorageDriver;
class MongoDBStorageDriver implements StorageDriver
{
public function createTenant(Tenant $tenant): void
{
//
}
public function updateTenant(Tenant $tenant): void
{
//
}
public function deleteTenant(Tenant $tenant): void
{
//
}
public function findById(string $id): Tenant
{
//
}
public function findByDomain(string $domain): Tenant
{
//
}
public function all(array $ids = []): array
{
//
}
public function ensureTenantCanBeCreated(Tenant $tenant): void
{
//
}
public function withDefaultTenant(Tenant $tenant)
{
//
}
public function get(string $key, Tenant $tenant = null)
{
//
}
public function getMany(array $keys, Tenant $tenant = null)
{
//
}
public function put(string $key, $value, Tenant $tenant = null): void
{
//
}
public function putMany(array $kvPairs, Tenant $tenant = null): void
{
//
}
}
```