Skip to content

Commit 06fa70a

Browse files
committed
Progress on v4
1 parent 9d1a077 commit 06fa70a

11 files changed

+141
-79
lines changed

composer.json

-8
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@
5757
"phpbench run tests\\Benchmark\\ --report=default"
5858
]
5959
},
60-
"extra": {
61-
"laravel": {
62-
"providers": [
63-
"October\\Rain\\Foundation\\Providers\\AppSupportServiceProvider",
64-
"October\\Rain\\Foundation\\Providers\\AppDeferSupportServiceProvider"
65-
]
66-
}
67-
},
6860
"minimum-stability": "dev",
6961
"prefer-stable": true
7062
}

src/Foundation/Application.php

+28-7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,25 @@ class Application extends ApplicationBase
3838
*/
3939
protected $cachePath;
4040

41+
/**
42+
* Begin configuring a new Laravel application instance.
43+
*
44+
* @param string|null $basePath
45+
* @return \Illuminate\Foundation\Configuration\ApplicationBuilder
46+
*/
47+
public static function configure($basePath = null)
48+
{
49+
if (!is_string($basePath)) {
50+
$basePath = static::inferBasePath();
51+
}
52+
53+
return (new Configuration\ApplicationBuilder(new static($basePath)))
54+
->withKernels()
55+
->withEvents()
56+
->withCommands()
57+
->withProviders();
58+
}
59+
4160
/**
4261
* registerBaseServiceProviders registers all of the base service providers
4362
*/
@@ -289,7 +308,7 @@ public function setLocale($locale)
289308
*/
290309
public function registerConfiguredProviders()
291310
{
292-
$providers = Collection::make($this->config['app.providers'])
311+
$providers = (new Collection($this->make('config')->get('app.providers')))
293312
->partition(function ($provider) {
294313
return strpos($provider, 'Illuminate\\') === 0 ||
295314
strpos($provider, 'October\\Rain\\') === 0;
@@ -310,25 +329,27 @@ public function registerCoreContainerAliases()
310329
{
311330
$aliases = [
312331
'app' => [\October\Rain\Foundation\Application::class, \Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class],
332+
'auth' => [\Illuminate\Auth\AuthManager::class, \Illuminate\Contracts\Auth\Factory::class],
333+
'auth.driver' => [\Illuminate\Contracts\Auth\Guard::class],
313334
'blade.compiler' => [\Illuminate\View\Compilers\BladeCompiler::class],
314335
'cache' => [\Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class],
315-
'cache.store' => [\Illuminate\Cache\Repository::class, \Illuminate\Contracts\Cache\Repository::class],
336+
'cache.store' => [\Illuminate\Cache\Repository::class, \Illuminate\Contracts\Cache\Repository::class, \Psr\SimpleCache\CacheInterface::class],
316337
'cache.psr6' => [\Symfony\Component\Cache\Adapter\Psr16Adapter::class, \Symfony\Component\Cache\Adapter\AdapterInterface::class, \Psr\Cache\CacheItemPoolInterface::class],
317338
'config' => [\Illuminate\Config\Repository::class, \Illuminate\Contracts\Config\Repository::class],
318339
'cookie' => [\Illuminate\Cookie\CookieJar::class, \Illuminate\Contracts\Cookie\Factory::class, \Illuminate\Contracts\Cookie\QueueingFactory::class],
319-
'db' => [\Illuminate\Database\DatabaseManager::class],
340+
'db' => [\Illuminate\Database\DatabaseManager::class, \Illuminate\Database\ConnectionResolverInterface::class],
320341
'db.connection' => [\Illuminate\Database\Connection::class, \Illuminate\Database\ConnectionInterface::class],
321342
'db.schema' => [\Illuminate\Database\Schema\Builder::class],
322-
'encrypter' => [\Illuminate\Encryption\Encrypter::class, \Illuminate\Contracts\Encryption\Encrypter::class],
323-
'events' => [\October\Rain\Events\Dispatcher::class, \Illuminate\Contracts\Events\Dispatcher::class],
343+
'encrypter' => [\Illuminate\Encryption\Encrypter::class, \Illuminate\Contracts\Encryption\Encrypter::class, \Illuminate\Contracts\Encryption\StringEncrypter::class],
344+
'events' => [\October\Rain\Events\Dispatcher::class, \Illuminate\Events\Dispatcher::class, \Illuminate\Contracts\Events\Dispatcher::class],
324345
'files' => [\October\Rain\Filesystem\Filesystem::class, \Illuminate\Filesystem\Filesystem::class],
325346
'filesystem' => [\Illuminate\Filesystem\FilesystemManager::class, \Illuminate\Contracts\Filesystem\Factory::class],
326347
'filesystem.disk' => [\Illuminate\Contracts\Filesystem\Filesystem::class],
327348
'filesystem.cloud' => [\Illuminate\Contracts\Filesystem\Cloud::class],
328-
'hash' => [\Illuminate\Contracts\Hashing\Hasher::class],
349+
'hash' => [\Illuminate\Hashing\HashManager::class],
329350
'hash.driver' => [\Illuminate\Contracts\Hashing\Hasher::class],
330351
'translator' => [\Illuminate\Translation\Translator::class, \Illuminate\Contracts\Translation\Translator::class],
331-
'log' => [\Illuminate\Log\Logger::class, \Psr\Log\LoggerInterface::class],
352+
'log' => [\Illuminate\Log\LogManager::class, \Psr\Log\LoggerInterface::class],
332353
'mail.manager' => [\Illuminate\Mail\MailManager::class, \Illuminate\Contracts\Mail\Factory::class],
333354
'mailer' => [\Illuminate\Mail\Mailer::class, \Illuminate\Contracts\Mail\Mailer::class, \Illuminate\Contracts\Mail\MailQueue::class],
334355
'auth.password' => [\Illuminate\Auth\Passwords\PasswordBrokerManager::class, \Illuminate\Contracts\Auth\PasswordBrokerFactory::class],

src/Foundation/Bootstrap/LoadConfiguration.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function bootstrap(Application $app)
2424
if (file_exists($cached = $app->getCachedConfigPath())) {
2525
$items = require $cached;
2626

27-
$loadedFromCache = true;
27+
$app->instance('config_loaded_from_cache', $loadedFromCache = true);
2828
}
2929

3030
// Next we will spin through all of the configuration files in the configuration

src/Foundation/Bootstrap/RegisterOctober.php

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use October\Rain\Support\Str;
44
use October\Rain\Support\ClassLoader;
55
use Illuminate\Contracts\Foundation\Application;
6+
use October\Rain\Extension\Container as OctoberContainer;
67

78
/**
89
* RegisterOctober specific features
@@ -77,6 +78,9 @@ public function bootstrap(Application $app)
7778
// Initialize class loader cache
7879
$loader = $app->make(ClassLoader::class);
7980
$loader->initManifest($app->getCachedClassesPath());
81+
82+
// Clear service container
83+
OctoberContainer::clearExtensions();
8084
}
8185

8286
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace October\Rain\Foundation\Bootstrap;
4+
5+
use Illuminate\Contracts\Foundation\Application;
6+
use October\Rain\Support\ServiceProvider;
7+
use Illuminate\Foundation\Bootstrap\RegisterProviders as RegisterProvidersBase;
8+
9+
class RegisterProviders extends RegisterProvidersBase
10+
{
11+
/**
12+
* Carbon copy of parent except defaultProviders
13+
*/
14+
protected function mergeAdditionalProviders(Application $app)
15+
{
16+
if (static::$bootstrapProviderPath &&
17+
file_exists(static::$bootstrapProviderPath)) {
18+
$packageProviders = require static::$bootstrapProviderPath;
19+
20+
foreach ($packageProviders as $index => $provider) {
21+
if (! class_exists($provider)) {
22+
unset($packageProviders[$index]);
23+
}
24+
}
25+
}
26+
27+
$app->make('config')->set(
28+
'app.providers',
29+
array_merge(
30+
$app->make('config')->get('app.providers') ?? ServiceProvider::defaultProviders()->toArray(),
31+
static::$merge,
32+
array_values($packageProviders ?? []),
33+
),
34+
);
35+
}
36+
}

src/Foundation/Console/Kernel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Kernel extends ConsoleKernel
1919
\Illuminate\Foundation\Bootstrap\RegisterFacades::class,
2020
\Illuminate\Foundation\Bootstrap\SetRequestForConsole::class,
2121
\October\Rain\Foundation\Bootstrap\RegisterOctober::class,
22-
\Illuminate\Foundation\Bootstrap\RegisterProviders::class,
22+
\October\Rain\Foundation\Bootstrap\RegisterProviders::class,
2323
\Illuminate\Foundation\Bootstrap\BootProviders::class,
2424
];
2525

src/Foundation/Http/Kernel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Kernel extends HttpKernel
2323
\Illuminate\Foundation\Bootstrap\HandleExceptions::class,
2424
\Illuminate\Foundation\Bootstrap\RegisterFacades::class,
2525
\October\Rain\Foundation\Bootstrap\RegisterOctober::class,
26-
\Illuminate\Foundation\Bootstrap\RegisterProviders::class,
26+
\October\Rain\Foundation\Bootstrap\RegisterProviders::class,
2727
\Illuminate\Foundation\Bootstrap\BootProviders::class,
2828
];
2929
/**

src/Foundation/Providers/AppDeferSupportServiceProvider.php

-32
This file was deleted.

src/Foundation/Providers/AppSupportServiceProvider.php

-29
This file was deleted.

src/Support/DefaultProviders.php

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace October\Rain\Support;
4+
5+
use Illuminate\Support\DefaultProviders as DefaultProvidersBase;
6+
7+
class DefaultProviders extends DefaultProvidersBase
8+
{
9+
/**
10+
* Create a new default provider collection.
11+
*
12+
* @return void
13+
*/
14+
public function __construct(?array $providers = null)
15+
{
16+
$this->providers = $providers ?: [
17+
// October Providers
18+
//
19+
\October\Rain\Database\DatabaseServiceProvider::class,
20+
\October\Rain\Halcyon\HalcyonServiceProvider::class,
21+
\October\Rain\Filesystem\FilesystemServiceProvider::class,
22+
\October\Rain\Html\UrlServiceProvider::class,
23+
\October\Rain\Argon\ArgonServiceProvider::class,
24+
25+
// October Providers (Deferred)
26+
\October\Rain\Mail\MailServiceProvider::class,
27+
\October\Rain\Html\HtmlServiceProvider::class,
28+
\October\Rain\Flash\FlashServiceProvider::class,
29+
\October\Rain\Parse\ParseServiceProvider::class,
30+
\October\Rain\Assetic\AsseticServiceProvider::class,
31+
\October\Rain\Resize\ResizeServiceProvider::class,
32+
\October\Rain\Validation\ValidationServiceProvider::class,
33+
\October\Rain\Translation\TranslationServiceProvider::class,
34+
\Illuminate\Auth\Passwords\PasswordResetServiceProvider:: class,
35+
36+
// October Console (Deferred)
37+
\October\Rain\Foundation\Providers\ArtisanServiceProvider::class,
38+
\October\Rain\Database\MigrationServiceProvider::class,
39+
\October\Rain\Scaffold\ScaffoldServiceProvider::class,
40+
\Illuminate\Foundation\Providers\ComposerServiceProvider::class,
41+
42+
// Laravel Providers
43+
//
44+
\Illuminate\Broadcasting\BroadcastServiceProvider::class,
45+
\Illuminate\Bus\BusServiceProvider::class,
46+
\Illuminate\Cache\CacheServiceProvider::class,
47+
\Illuminate\Concurrency\ConcurrencyServiceProvider::class,
48+
\Illuminate\Cookie\CookieServiceProvider::class,
49+
\Illuminate\Encryption\EncryptionServiceProvider::class,
50+
\Illuminate\Foundation\Providers\FoundationServiceProvider::class,
51+
\Illuminate\Hashing\HashServiceProvider::class,
52+
\Illuminate\Pagination\PaginationServiceProvider::class,
53+
\Illuminate\Pipeline\PipelineServiceProvider::class,
54+
\Illuminate\Queue\QueueServiceProvider::class,
55+
\Illuminate\Redis\RedisServiceProvider::class,
56+
\Illuminate\Session\SessionServiceProvider::class,
57+
\Illuminate\View\ViewServiceProvider::class,
58+
];
59+
}
60+
}

src/Support/ServiceProvider.php

+10
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,14 @@ protected function callBeforeResolving($name, $callback)
3131
$callback($this->app->make($name), $this->app);
3232
}
3333
}
34+
35+
/**
36+
* Get the default providers for a Laravel application.
37+
*
38+
* @return \October\Rain\Support\DefaultProviders
39+
*/
40+
public static function defaultProviders()
41+
{
42+
return new DefaultProviders;
43+
}
3444
}

0 commit comments

Comments
 (0)