Skip to content

Commit 9c3e968

Browse files
committed
Updating of service providers to match latest L4 update.
Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com>
1 parent 26ed676 commit 9c3e968

15 files changed

Lines changed: 217 additions & 132 deletions

app/config/app.php

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -120,35 +120,38 @@
120120

121121
'aliases' => array(
122122

123-
'App' => 'Illuminate\Foundation\Facades\App',
124-
'Artisan' => 'Illuminate\Foundation\Facades\Artisan',
125-
'Auth' => 'Illuminate\Foundation\Facades\Auth',
126-
'Cache' => 'Illuminate\Foundation\Facades\Cache',
127-
'Config' => 'Illuminate\Foundation\Facades\Config',
128-
'Controller' => 'Illuminate\Routing\Controllers\Controller',
129-
'Cookie' => 'Illuminate\Foundation\Facades\Cookie',
130-
'Crypt' => 'Illuminate\Foundation\Facades\Crypt',
131-
'Crypt' => 'Illuminate\Foundation\Facades\Crypt',
132-
'DB' => 'Illuminate\Foundation\Facades\DB',
133-
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
134-
'Event' => 'Illuminate\Foundation\Facades\Event',
135-
'File' => 'Illuminate\Foundation\Facades\File',
136-
'Hash' => 'Illuminate\Foundation\Facades\Hash',
137-
'Input' => 'Illuminate\Foundation\Facades\Input',
138-
'Lang' => 'Illuminate\Foundation\Facades\Lang',
139-
'Log' => 'Illuminate\Foundation\Facades\Log',
140-
'Mail' => 'Illuminate\Foundation\Facades\Mail',
141-
'Paginator' => 'Illuminate\Foundation\Facades\Paginator',
142-
'Redirect' => 'Illuminate\Foundation\Facades\Redirect',
143-
'Redis' => 'Illuminate\Foundation\Facades\Redis',
144-
'Request' => 'Illuminate\Foundation\Facades\Request',
145-
'Response' => 'Illuminate\Foundation\Facades\Response',
146-
'Route' => 'Illuminate\Foundation\Facades\Route',
147-
'Schema' => 'Illuminate\Foundation\Facades\Schema',
148-
'Session' => 'Illuminate\Foundation\Facades\Session',
149-
'URL' => 'Illuminate\Foundation\Facades\URL',
150-
'Validator' => 'Illuminate\Foundation\Facades\Validator',
151-
'View' => 'Illuminate\Foundation\Facades\View',
123+
'App' => 'Illuminate\Foundation\Facades\App',
124+
'Artisan' => 'Illuminate\Foundation\Facades\Artisan',
125+
'Auth' => 'Illuminate\Foundation\Facades\Auth',
126+
'Basset' => 'Basset\Facades\Basset',
127+
'Cache' => 'Illuminate\Foundation\Facades\Cache',
128+
'Config' => 'Illuminate\Foundation\Facades\Config',
129+
'Controller' => 'Illuminate\Routing\Controllers\Controller',
130+
'Cookie' => 'Illuminate\Foundation\Facades\Cookie',
131+
'Crypt' => 'Illuminate\Foundation\Facades\Crypt',
132+
'Crypt' => 'Illuminate\Foundation\Facades\Crypt',
133+
'DB' => 'Illuminate\Foundation\Facades\DB',
134+
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
135+
'Event' => 'Illuminate\Foundation\Facades\Event',
136+
'Feather\Extension' => 'Feather\Facades\Extension',
137+
'Feather\Presenter' => 'Feather\Facades\Presenter',
138+
'File' => 'Illuminate\Foundation\Facades\File',
139+
'Hash' => 'Illuminate\Foundation\Facades\Hash',
140+
'Input' => 'Illuminate\Foundation\Facades\Input',
141+
'Lang' => 'Illuminate\Foundation\Facades\Lang',
142+
'Log' => 'Illuminate\Foundation\Facades\Log',
143+
'Mail' => 'Illuminate\Foundation\Facades\Mail',
144+
'Paginator' => 'Illuminate\Foundation\Facades\Paginator',
145+
'Redirect' => 'Illuminate\Foundation\Facades\Redirect',
146+
'Redis' => 'Illuminate\Foundation\Facades\Redis',
147+
'Request' => 'Illuminate\Foundation\Facades\Request',
148+
'Response' => 'Illuminate\Foundation\Facades\Response',
149+
'Route' => 'Illuminate\Foundation\Facades\Route',
150+
'Schema' => 'Illuminate\Foundation\Facades\Schema',
151+
'Session' => 'Illuminate\Foundation\Facades\Session',
152+
'URL' => 'Illuminate\Foundation\Facades\URL',
153+
'Validator' => 'Illuminate\Foundation\Facades\Validator',
154+
'View' => 'Illuminate\Foundation\Facades\View',
152155

153156
),
154157

app/start/artisan.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313

1414
$artisan->resolveCommands(array(
1515
'command.feather',
16-
'command.feather.publish'
16+
'command.feather.publish',
17+
'command.feather.install'
1718
));

app/start/console.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,19 @@
2727
$app['command.feather.publish'] = $app->share(function($app)
2828
{
2929
return new Console\PublishCommand($app['asset.publisher'], $app['path.themes'], $app['path.extensions']);
30+
});
31+
32+
/*
33+
|--------------------------------------------------------------------------
34+
| Install Command
35+
|--------------------------------------------------------------------------
36+
|
37+
| The install command is responsible for installing Feather in the current
38+
| location.
39+
|
40+
*/
41+
42+
$app['command.feather.install'] = $app->share(function($app)
43+
{
44+
return new Console\InstallCommand;
3045
});

app/start/facades.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace Feather;
1+
<?php namespace Feather\Facades;
22

33
use Illuminate\Support\Facade;
44

app/start/global.php

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
|
1010
*/
1111

12-
define('FEATHER_VERSION', '1.0.0');
12+
if (!defined('FEATHER_VERSION'))
13+
{
14+
define('FEATHER_VERSION', '1.0.0');
15+
}
1316

1417
/*
1518
|--------------------------------------------------------------------------
@@ -20,8 +23,8 @@
2023
|
2124
*/
2225

23-
$app['path.extensions'] = $app['path.base'].'/extensions';
24-
$app['path.themes'] = $app['path.base'].'/themes';
26+
$app['path.extensions'] = $app['path'].'/extensions';
27+
$app['path.themes'] = $app['path'].'/themes';
2528

2629
/*
2730
|--------------------------------------------------------------------------
@@ -62,57 +65,57 @@
6265

6366
foreach ($providers as $provider)
6467
{
65-
$app->register(new $provider);
68+
$app->register(new $provider($app));
6669
}
6770

6871
/*
6972
|--------------------------------------------------------------------------
70-
| Prepare Feather Presenter
73+
| Require The Facades File
7174
|--------------------------------------------------------------------------
7275
|
73-
| Presenter is responsible for Feather's views. We'll prepare the presenter
74-
| now, which will start the theme and set some view paths.
76+
| We'll now register some facades to easily access some of Feather's
77+
| components statically.
7578
|
7679
*/
7780

78-
$app['feather.presenter']->prepare();
81+
require_once __DIR__.'/facades.php';
7982

8083
/*
8184
|--------------------------------------------------------------------------
82-
| Feather Extensions
85+
| Require The Console File
8386
|--------------------------------------------------------------------------
8487
|
85-
| Register the activated extensions with Feather.
88+
| Commands are registered with the application container and when Artisan
89+
| is run they are resolved from the Artisan start file.
8690
|
8791
*/
8892

89-
$extensions = new Models\Extension;
90-
91-
$app['feather.extensions']->registerExtensions($extensions->getActivated());
93+
require __DIR__.'/console.php';
9294

9395
/*
9496
|--------------------------------------------------------------------------
95-
| Require The Facades File
97+
| Prepare Feather Presenter
9698
|--------------------------------------------------------------------------
9799
|
98-
| We'll now register some facades to easily access some of Feather's
99-
| components statically.
100+
| Presenter is responsible for Feather's views. We'll prepare the presenter
101+
| now, which will start the theme and set some view paths.
100102
|
101103
*/
102104

103-
require __DIR__.'/facades.php';
105+
$app['feather.presenter']->prepare();
104106

105107
/*
106108
|--------------------------------------------------------------------------
107-
| Require The Console File
109+
| Feather Extensions
108110
|--------------------------------------------------------------------------
109111
|
110-
| Commands are registered with the application container and when Artisan
111-
| is run they are resolved from the Artisan start file.
112+
| Register the activated extensions with Feather.
112113
|
113114
*/
114115

115-
require __DIR__.'/console.php';
116+
$extensions = new Models\Extension;
117+
118+
$app['feather.extensions']->registerExtensions($extensions->getActivated());
116119

117120
/*
118121
|--------------------------------------------------------------------------

composer.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
"illuminate/foundation": ">=1.0.0",
44
"jasonlewis/basset": "*"
55
},
6+
"require-dev": {
7+
"mockery/mockery": "0.7.*"
8+
},
69
"autoload": {
710
"classmap": [
8-
"feather/extensions",
9-
"feather/presenter",
10-
"feather/database",
11-
"feather/console",
11+
"feather/Auth",
12+
"feather/Console",
13+
"feather/Database",
14+
"feather/Extensions",
15+
"feather/Migrator",
16+
"feather/Presenter",
1217
"app/controllers",
1318
"app/models",
19+
"app/extensions",
1420
"app/database/migrations",
15-
"tests/TestCase.php",
16-
"extensions"
21+
"tests/TestCase.php"
1722
]
1823
},
1924
"minimum-stability": "dev"

feather/auth/AuthServiceProvider.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@ class AuthServiceProvider extends ServiceProvider {
99
/**
1010
* Register the service provider.
1111
*
12-
* @param Illuminate\Foundation\Application $app
1312
* @return void
1413
*/
15-
public function register($app)
14+
public function register()
1615
{
17-
$app['auth']->extend('feather', function($app)
16+
$this->app['auth']->extend('feather', function($app)
1817
{
1918
$provider = new FeatherUserProvider($app['hash'], $app['feather']['migrator']);
2019

2120
return new Guard($provider, $app['session']);
2221
});
2322

24-
$app['config']->set('auth.driver', 'feather');
23+
$this->app['config']->set('auth.driver', 'feather');
2524
}
2625

2726
}

feather/console/PublishCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class PublishCommand extends Command {
2020
*
2121
* @var string
2222
*/
23-
protected $description = 'Publish extensions or themes';
23+
protected $description = 'Publish extension or theme assets';
2424

2525
/**
2626
* Asset publisher instance.

feather/extensions/Dispatcher.php

Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ public function registerExtensions($extensions)
7373
}
7474
}
7575

76+
/**
77+
* Get the started extensions.
78+
*
79+
* @return array
80+
*/
81+
public function getStarted()
82+
{
83+
return $this->started;
84+
}
85+
7686
/**
7787
* Register an extension with the dispatcher.
7888
*
@@ -100,25 +110,47 @@ public function register(ExtensionModel $extension)
100110
}
101111
}
102112

113+
/**
114+
* Determine if an extension is regisetered.
115+
*
116+
* @param string $identifier
117+
* @return bool
118+
*/
119+
public function isRegistered($identifier)
120+
{
121+
return isset($this["extension.{$identifier}"]);
122+
}
123+
124+
/**
125+
* Determine if an extension is started.
126+
*
127+
* @param string $identifier
128+
* @return bool
129+
*/
130+
public function isStarted($identifier)
131+
{
132+
return in_array($identifier, $this->started);
133+
}
134+
103135
/**
104136
* Start an extension.
105137
*
106-
* @param string $extension
138+
* @param string $identifier
107139
* @return void
108140
*/
109-
public function start($extension)
141+
public function start($identifier)
110142
{
111-
if (in_array($extension, $this->started) or ! isset($this["extension.{$extension}"]))
143+
if ($this->isStarted($identifier) or ! $this->isRegistered($identifier))
112144
{
113145
return;
114146
}
115-
116-
$extension = $this["extension.{$extension}"];
117147

118-
foreach (new FilesystemIterator($extension->path) as $file)
148+
$extension = $this["extension.{$identifier}"];
149+
150+
foreach ($this->findExtensions($extension->path) as $file)
119151
{
120152
$name = $file->getBasename(".{$file->getExtension()}");
121-
153+
122154
if (ends_with($name, 'Extension'))
123155
{
124156
$location = str_replace('/', '\\', $extension->location);
@@ -127,16 +159,36 @@ public function start($extension)
127159

128160
// Instantiate the new extension class and assign it to the extensions loaded classes. The class
129161
// receives an instance of the Laravel application.
130-
$extension->loaded = array_merge($extension->loaded, array($class => new $class($this->app)));
131-
132-
// If the extension has the start method we'll fire it, this is a great place for extensions
133-
// to do any bootstrapping or listening to events without having to override the constructor.
134-
if (method_exists($extension->loaded[$class], 'start'))
135-
{
136-
$extension->loaded[$class]->start($this->app);
137-
}
162+
$extension->loaded = array_merge($extension->loaded, array($class => $this->loadExtension($class)));
163+
164+
$extension->loaded[$class]->start($this->app);
138165
}
139166
}
167+
168+
// Add the extension to the array of started extensions.
169+
$this->started[] = $identifier;
170+
}
171+
172+
/**
173+
* Get a FilesystemIterator to find the extensions within a path.
174+
*
175+
* @param string $path
176+
* @return FilesystemIterator
177+
*/
178+
public function findExtensions($path)
179+
{
180+
return new FilesystemIterator($path);
181+
}
182+
183+
/**
184+
* Create a new extension instance.
185+
*
186+
* @param string $class
187+
* @return Feather\Extensions\Extension
188+
*/
189+
public function loadExtension($class)
190+
{
191+
return new $class($this->app);
140192
}
141193

142194
public function fire()

0 commit comments

Comments
 (0)