Skip to content

Commit 78b3fe6

Browse files
collegemantaylorotwell
authored andcommitted
Make consistent the disuse of helper functions within ServiceProviders (#18521)
* Update helpers.php * Update Application.php * Update DatabaseServiceProvider.php * Update PaginationServiceProvider.php * Update NotificationServiceProvider.php * Update Application.php * Update Application.php * Update Application.php * Update Application.php * Update Application.php This is not normally how I would code such an expression, but StyleCI is failing me on leading whitespace that I can't seem to kill.
1 parent 9ff4614 commit 78b3fe6

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

src/Illuminate/Database/DatabaseServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected function registerEloquentFactory()
8080

8181
$this->app->singleton(EloquentFactory::class, function ($app) {
8282
return EloquentFactory::construct(
83-
$app->make(FakerGenerator::class), database_path('factories')
83+
$app->make(FakerGenerator::class), $this->app->databasePath('factories')
8484
);
8585
});
8686
}

src/Illuminate/Foundation/Application.php

+15-10
Original file line numberDiff line numberDiff line change
@@ -294,51 +294,56 @@ protected function bindPathsInContainer()
294294
/**
295295
* Get the path to the application "app" directory.
296296
*
297+
* @param string $path Optionally, a path to append to the app path
297298
* @return string
298299
*/
299-
public function path()
300+
public function path($path = '')
300301
{
301-
return $this->basePath.DIRECTORY_SEPARATOR.'app';
302+
return $this->basePath.DIRECTORY_SEPARATOR.'app'.($path ? DIRECTORY_SEPARATOR.$path : $path);
302303
}
303304

304305
/**
305306
* Get the base path of the Laravel installation.
306307
*
308+
* @param string $path Optionally, a path to append to the base path
307309
* @return string
308310
*/
309-
public function basePath()
311+
public function basePath($path = '')
310312
{
311-
return $this->basePath;
313+
return $this->basePath.($path ? DIRECTORY_SEPARATOR.$path : $path);
312314
}
313315

314316
/**
315317
* Get the path to the bootstrap directory.
316318
*
319+
* @param string $path Optionally, a path to append to the bootstrap path
317320
* @return string
318321
*/
319-
public function bootstrapPath()
322+
public function bootstrapPath($path = '')
320323
{
321-
return $this->basePath.DIRECTORY_SEPARATOR.'bootstrap';
324+
return $this->basePath.DIRECTORY_SEPARATOR.'bootstrap'.($path ? DIRECTORY_SEPARATOR.$path : $path);
322325
}
323326

324327
/**
325328
* Get the path to the application configuration files.
326329
*
330+
* @param string $path Optionally, a path to append to the config path
327331
* @return string
328332
*/
329-
public function configPath()
333+
public function configPath($path = '')
330334
{
331-
return $this->basePath.DIRECTORY_SEPARATOR.'config';
335+
return $this->basePath.DIRECTORY_SEPARATOR.'config'.($path ? DIRECTORY_SEPARATOR.$path : $path);
332336
}
333337

334338
/**
335339
* Get the path to the database directory.
336340
*
341+
* @param string $path Optionally, a path to append to the database path
337342
* @return string
338343
*/
339-
public function databasePath()
344+
public function databasePath($path = '')
340345
{
341-
return $this->databasePath ?: $this->basePath.DIRECTORY_SEPARATOR.'database';
346+
return ($this->databasePath ?: $this->basePath.DIRECTORY_SEPARATOR.'database').($path ? DIRECTORY_SEPARATOR.$path : $path);
342347
}
343348

344349
/**

src/Illuminate/Foundation/helpers.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ function csrf_token()
346346
*/
347347
function database_path($path = '')
348348
{
349-
return app()->databasePath().($path ? DIRECTORY_SEPARATOR.$path : $path);
349+
return app()->databasePath($path);
350350
}
351351
}
352352

src/Illuminate/Notifications/NotificationServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function boot()
1919

2020
if ($this->app->runningInConsole()) {
2121
$this->publishes([
22-
__DIR__.'/resources/views' => resource_path('views/vendor/notifications'),
22+
__DIR__.'/resources/views' => $this->app->resourcePath('views/vendor/notifications'),
2323
], 'laravel-notifications');
2424
}
2525
}

src/Illuminate/Pagination/PaginationServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function boot()
1717

1818
if ($this->app->runningInConsole()) {
1919
$this->publishes([
20-
__DIR__.'/resources/views' => resource_path('views/vendor/pagination'),
20+
__DIR__.'/resources/views' => $this->app->resourcePath('views/vendor/pagination'),
2121
], 'laravel-pagination');
2222
}
2323
}

0 commit comments

Comments
 (0)