Skip to content

Commit

Permalink
Revert "update provider method code examples (laravel#5163)"
Browse files Browse the repository at this point in the history
This reverts commit 127a024.
  • Loading branch information
m777z committed Jun 8, 2019
1 parent c76cb0c commit 2d8034f
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 108 deletions.
18 changes: 9 additions & 9 deletions blade.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,25 +605,25 @@ The following example creates a `@datetime($var)` directive which formats a give
class AppServiceProvider extends ServiceProvider
{
/**
* Register bindings in the container.
* Perform post-registration booting of services.
*
* @return void
*/
public function register()
public function boot()
{
//
Blade::directive('datetime', function ($expression) {
return "<?php echo ($expression)->format('m/d/Y H:i'); ?>";
});
}

/**
* Bootstrap any application services.
* Register bindings in the container.
*
* @return void
*/
public function boot()
public function register()
{
Blade::directive('datetime', function ($expression) {
return "<?php echo ($expression)->format('m/d/Y H:i'); ?>";
});
//
}
}

Expand All @@ -641,7 +641,7 @@ Programming a custom directive is sometimes more complex than necessary when def
use Illuminate\Support\Facades\Blade;

/**
* Bootstrap any application services.
* Perform post-registration booting of services.
*
* @return void
*/
Expand Down
16 changes: 8 additions & 8 deletions cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,25 +379,25 @@ To register the custom cache driver with Laravel, we will use the `extend` metho
class CacheServiceProvider extends ServiceProvider
{
/**
* Register bindings in the container.
* Perform post-registration booting of services.
*
* @return void
*/
public function register()
public function boot()
{
//
Cache::extend('mongo', function ($app) {
return Cache::repository(new MongoStore);
});
}

/**
* Bootstrap any application services.
* Register bindings in the container.
*
* @return void
*/
public function boot()
public function register()
{
Cache::extend('mongo', function ($app) {
return Cache::repository(new MongoStore);
});
//
}
}

Expand Down
20 changes: 10 additions & 10 deletions database.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,6 @@ If you would like to receive each SQL query executed by your application, you ma

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}

/**
* Bootstrap any application services.
*
Expand All @@ -190,6 +180,16 @@ If you would like to receive each SQL query executed by your application, you ma
// $query->time
});
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
}
}

<a name="database-transactions"></a>
Expand Down
12 changes: 6 additions & 6 deletions eloquent-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,23 +324,23 @@ If you would like to disable the wrapping of the outer-most resource, you may us
class AppServiceProvider extends ServiceProvider
{
/**
* Register bindings in the container.
* Perform post-registration booting of services.
*
* @return void
*/
public function register()
public function boot()
{
//
Resource::withoutWrapping();
}

/**
* Bootstrap any application services.
* Register bindings in the container.
*
* @return void
*/
public function boot()
public function register()
{
Resource::withoutWrapping();
//
}
}

Expand Down
16 changes: 8 additions & 8 deletions eloquent-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,24 @@ Laravel extends the [Carbon](https://github.com/briannesbitt/Carbon) date librar
class AppServiceProvider extends ServiceProvider
{
/**
* Register bindings in the container.
* Perform post-registration booting of services.
*
* @return void
*/
public function register()
public function boot()
{
//
Carbon::serializeUsing(function ($carbon) {
return $carbon->format('U');
});
}

/**
* Bootstrap any application services.
* Register bindings in the container.
*
* @return void
*/
public function boot()
public function register()
{
Carbon::serializeUsing(function ($carbon) {
return $carbon->format('U');
});
//
}
}
2 changes: 1 addition & 1 deletion eloquent.md
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ To register an observer, use the `observe` method on the model you wish to obser
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
* Register the service provider.
*
* @return void
*/
Expand Down
22 changes: 11 additions & 11 deletions filesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,17 +408,7 @@ Next, you should create a [service provider](/docs/{{version}}/providers) such a
class DropboxServiceProvider extends ServiceProvider
{
/**
* Register bindings in the container.
*
* @return void
*/
public function register()
{
//
}

/**
* Bootstrap any application services.
* Perform post-registration booting of services.
*
* @return void
*/
Expand All @@ -432,6 +422,16 @@ Next, you should create a [service provider](/docs/{{version}}/providers) such a
return new Filesystem(new DropboxAdapter($client));
});
}

/**
* Register bindings in the container.
*
* @return void
*/
public function register()
{
//
}
}

The first argument of the `extend` method is the name of the driver and the second is a Closure that receives the `$app` and `$config` variables. The resolver Closure must return an instance of `League\Flysystem\Filesystem`. The `$config` variable contains the values defined in `config/filesystems.php` for the specified disk.
Expand Down
18 changes: 9 additions & 9 deletions packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ A service provider extends the `Illuminate\Support\ServiceProvider` class and co
Typically, you will need to publish your package's configuration file to the application's own `config` directory. This will allow users of your package to easily override your default configuration options. To allow your configuration files to be published, call the `publishes` method from the `boot` method of your service provider:

/**
* Bootstrap any application services.
* Perform post-registration booting of services.
*
* @return void
*/
Expand Down Expand Up @@ -125,7 +125,7 @@ You may also merge your own package configuration file with the application's pu
If your package contains routes, you may load them using the `loadRoutesFrom` method. This method will automatically determine if the application's routes are cached and will not load your routes file if the routes have already been cached:

/**
* Bootstrap any application services.
* Perform post-registration booting of services.
*
* @return void
*/
Expand All @@ -140,7 +140,7 @@ If your package contains routes, you may load them using the `loadRoutesFrom` me
If your package contains [database migrations](/docs/{{version}}/migrations), you may use the `loadMigrationsFrom` method to inform Laravel how to load them. The `loadMigrationsFrom` method accepts the path to your package's migrations as its only argument:

/**
* Bootstrap any application services.
* Perform post-registration booting of services.
*
* @return void
*/
Expand All @@ -157,7 +157,7 @@ Once your package's migrations have been registered, they will automatically be
If your package contains [translation files](/docs/{{version}}/localization), you may use the `loadTranslationsFrom` method to inform Laravel how to load them. For example, if your package is named `courier`, you should add the following to your service provider's `boot` method:

/**
* Bootstrap any application services.
* Perform post-registration booting of services.
*
* @return void
*/
Expand All @@ -175,7 +175,7 @@ Package translations are referenced using the `package::file.line` syntax conven
If you would like to publish your package's translations to the application's `resources/lang/vendor` directory, you may use the service provider's `publishes` method. The `publishes` method accepts an array of package paths and their desired publish locations. For example, to publish the translation files for the `courier` package, you may do the following:

/**
* Bootstrap any application services.
* Perform post-registration booting of services.
*
* @return void
*/
Expand All @@ -196,7 +196,7 @@ Now, when users of your package execute Laravel's `vendor:publish` Artisan comma
To register your package's [views](/docs/{{version}}/views) with Laravel, you need to tell Laravel where the views are located. You may do this using the service provider's `loadViewsFrom` method. The `loadViewsFrom` method accepts two arguments: the path to your view templates and your package's name. For example, if your package's name is `courier`, you would add the following to your service provider's `boot` method:

/**
* Bootstrap any application services.
* Perform post-registration booting of services.
*
* @return void
*/
Expand All @@ -220,7 +220,7 @@ When you use the `loadViewsFrom` method, Laravel actually registers two location
If you would like to make your views available for publishing to the application's `resources/views/vendor` directory, you may use the service provider's `publishes` method. The `publishes` method accepts an array of package view paths and their desired publish locations:

/**
* Bootstrap any application services.
* Perform post-registration booting of services.
*
* @return void
*/
Expand Down Expand Up @@ -261,7 +261,7 @@ To register your package's Artisan commands with Laravel, you may use the `comma
Your package may have assets such as JavaScript, CSS, and images. To publish these assets to the application's `public` directory, use the service provider's `publishes` method. In this example, we will also add a `public` asset group tag, which may be used to publish groups of related assets:

/**
* Bootstrap any application services.
* Perform post-registration booting of services.
*
* @return void
*/
Expand All @@ -282,7 +282,7 @@ Now, when your package's users execute the `vendor:publish` command, your assets
You may want to publish groups of package assets and resources separately. For instance, you might want to allow your users to publish your package's configuration files without being forced to publish your package's assets. You may do this by "tagging" them when calling the `publishes` method from a package's service provider. For example, let's use tags to define two publish groups in the `boot` method of a package service provider:

/**
* Bootstrap any application services.
* Perform post-registration booting of services.
*
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ To defer the loading of a provider, implement the `\Illuminate\Contracts\Support
class RiakServiceProvider extends ServiceProvider implements DeferrableProvider
{
/**
* Register any application services.
* Register the service provider.
*
* @return void
*/
Expand Down
22 changes: 11 additions & 11 deletions queues.md
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ If you would like to register an event that will be called when a job fails, you
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
* Register the service provider.
*
* @return void
*/
Expand Down Expand Up @@ -767,16 +767,6 @@ Using the `before` and `after` methods on the `Queue` [facade](/docs/{{version}}

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}

/**
* Bootstrap any application services.
*
Expand All @@ -796,6 +786,16 @@ Using the `before` and `after` methods on the `Queue` [facade](/docs/{{version}}
// $event->job->payload()
});
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
}
}

Using the `looping` method on the `Queue` [facade](/docs/{{version}}/facades), you may specify callbacks that execute before the worker attempts to fetch a job from a queue. For example, you might register a Closure to rollback any transactions that were left open by a previously failed job:
Expand Down
18 changes: 9 additions & 9 deletions session.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,26 +247,26 @@ Once your driver has been implemented, you are ready to register it with the fra
class SessionServiceProvider extends ServiceProvider
{
/**
* Register bindings in the container.
* Perform post-registration booting of services.
*
* @return void
*/
public function register()
public function boot()
{
//
Session::extend('mongo', function ($app) {
// Return implementation of SessionHandlerInterface...
return new MongoSessionHandler;
});
}

/**
* Bootstrap any application services.
* Register bindings in the container.
*
* @return void
*/
public function boot()
public function register()
{
Session::extend('mongo', function ($app) {
// Return implementation of SessionHandlerInterface...
return new MongoSessionHandler;
});
//
}
}

Expand Down
Loading

0 comments on commit 2d8034f

Please sign in to comment.