Skip to content

Update pennant.md #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 11.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions pennant.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use Laravel\Pennant\Feature;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
* Загрузка любых сервисов приложения.
*/
public function boot(): void
{
Expand Down Expand Up @@ -105,7 +105,7 @@ use Illuminate\Support\Lottery;
class NewApi
{
/**
* Resolve the feature's initial value.
* Определите начальное значение функции.
*/
public function resolve(User $user): mixed
{
Expand Down Expand Up @@ -141,7 +141,7 @@ namespace App\Features;
class NewApi
{
/**
* The stored name of the feature.
* Сохраненное имя функции.
*
* @var string
*/
Expand All @@ -168,7 +168,7 @@ use Laravel\Pennant\Feature;
class PodcastController
{
/**
* Display a listing of the resource.
* Отобразить список ресурсов.
*/
public function index(Request $request): Response
{
Expand Down Expand Up @@ -229,7 +229,7 @@ use Laravel\Pennant\Feature;
class PodcastController
{
/**
* Display a listing of the resource.
* Отобразить список ресурсов.
*/
public function index(Request $request): Response
{
Expand Down Expand Up @@ -259,7 +259,7 @@ class PodcastController
class PodcastController
{
/**
* Display a listing of the resource.
* Отобразить список ресурсов.
*/
public function index(Request $request): Response
{
Expand Down Expand Up @@ -343,13 +343,13 @@ $user->features()->unless('new-api',

```blade
@feature('site-redesign')
<!-- 'site-redesign' is active -->
<!-- 'site-redesign' активен -->
@else
<!-- 'site-redesign' is inactive -->
<!-- 'site-redesign' неактивен -->
@endfeature

@featureany(['site-redesign', 'beta'])
<!-- 'site-redesign' or `beta` is active -->
<!-- 'site-redesign' или `beta` активен -->
@endfeatureany
```

Expand Down Expand Up @@ -378,7 +378,7 @@ use Illuminate\Http\Response;
use Laravel\Pennant\Middleware\EnsureFeaturesAreActive;

/**
* Bootstrap any application services.
* Загрузка любых сервисов приложения.
*/
public function boot(): void
{
Expand Down Expand Up @@ -411,7 +411,7 @@ use Illuminate\Support\Lottery;
class NewApi
{
/**
* Run an always-in-memory check before the stored value is retrieved.
* Запустите проверку «всегда в памяти» перед извлечением сохраненного значения.
*/
public function before(User $user): mixed
{
Expand All @@ -421,7 +421,7 @@ class NewApi
}

/**
* Resolve the feature's initial value.
* Определите начальное значение функции.
*/
public function resolve(User $user): mixed
{
Expand All @@ -447,7 +447,7 @@ use Illuminate\Support\Facades\Config;
class NewApi
{
/**
* Run an always-in-memory check before the stored value is retrieved.
* Запустите проверку «всегда в памяти» перед извлечением сохраненного значения.
*/
public function before(User $user): mixed
{
Expand Down Expand Up @@ -535,7 +535,7 @@ use Laravel\Pennant\Feature;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
* Загрузка любых сервисов приложения.
*/
public function boot(): void
{
Expand Down Expand Up @@ -600,7 +600,7 @@ use Laravel\Pennant\Contracts\FeatureScopeable;
class User extends Model implements FeatureScopeable
{
/**
* Cast the object to a feature scope identifier for the given driver.
* Приведите объект к идентификатору области функций для данного драйвера.
*/
public function toFeatureIdentifier(string $driver): mixed
{
Expand Down Expand Up @@ -659,11 +659,11 @@ $color = Feature::value('purchase-button');

```blade
@feature('purchase-button', 'blue-sapphire')
<!-- 'blue-sapphire' is active -->
<!-- 'blue-sapphire' активен -->
@elsefeature('purchase-button', 'seafoam-green')
<!-- 'seafoam-green' is active -->
<!-- 'seafoam-green' активен -->
@elsefeature('purchase-button', 'tart-orange')
<!-- 'tart-orange' is active -->
<!-- 'tart-orange' активен -->
@endfeature
```

Expand Down Expand Up @@ -724,7 +724,7 @@ Feature::all();
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
* Загрузка любых сервисов приложения.
*/
public function boot(): void
{
Expand Down Expand Up @@ -802,10 +802,10 @@ Feature::for($users)->loadAll();
```php
use Laravel\Pennant\Feature;

// Activate the feature for the default scope...
// Активируем функцию для области действия по умолчанию...
Feature::activate('new-api');

// Deactivate the feature for the given scope...
// Деактивируем функцию для данной области действия...
Feature::for($user->team)->deactivate('billing-v2');
```

Expand Down Expand Up @@ -853,10 +853,10 @@ Feature::deactivateForEveryone('new-api');
Вы можете удалить все сохраненные значения для функции, используя метод `purge`:

```php
// Purging a single feature...
// Очистка одной функции...
Feature::purge('new-api');

// Purging multiple features...
// Очистка нескольких функций...
Feature::purge(['new-api', 'purchase-button']);
```

Expand Down Expand Up @@ -907,7 +907,7 @@ Feature::define('purchase-button', fn () => Arr::random([
```php tab=Pest
use Laravel\Pennant\Feature;

test('it can control feature values', function () {
test('он может контролировать значения функций', function () {
Feature::define('purchase-button', 'seafoam-green');

expect(Feature::value('purchase-button'))->toBe('seafoam-green');
Expand All @@ -930,7 +930,7 @@ public function test_it_can_control_feature_values()
```php tab=Pest
use Laravel\Pennant\Feature;

test('it can control feature values', function () {
test('он может контролировать значения функций', function () {
Feature::define(NewApi::class, true);

expect(Feature::value(NewApi::class))->toBeTrue();
Expand Down Expand Up @@ -1018,15 +1018,15 @@ use Laravel\Pennant\Feature;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
* Зарегистрируйте любые службы приложения.
*/
public function register(): void
{
// ...
}

/**
* Bootstrap any application services.
* Загрузка любых сервисов приложения.
*/
public function boot(): void
{
Expand Down Expand Up @@ -1106,12 +1106,12 @@ use Laravel\Pennant\Events\UnknownFeatureResolved;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
* Загрузка любых сервисов приложения.
*/
public function boot(): void
{
Event::listen(function (UnknownFeatureResolved $event) {
Log::error("Resolving unknown feature [{$event->feature}].");
Log::error("Решение неизвестной функции [{$event->feature}].");
});
}
}
Expand All @@ -1132,7 +1132,7 @@ use Illuminate\Support\Facades\Log;
use Laravel\Pennant\Events\UnexpectedNullScopeEncountered;

/**
* Bootstrap any application services.
* Загрузка любых сервисов приложения.
*/
public function boot(): void
{
Expand Down