-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved oxygen/theme into this repo, fixed more phpstan errors
- Loading branch information
Showing
20 changed files
with
522 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace spec\Oxygen\Core\Theme; | ||
|
||
use Oxygen\Core\Theme\CurrentThemeLoader; | ||
use Oxygen\Core\Theme\Theme; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
|
||
class ThemeManagerSpec extends ObjectBehavior { | ||
|
||
function let(\Oxygen\Core\Theme\CurrentThemeLoader $loader) { | ||
$this->beConstructedWith($loader); | ||
} | ||
|
||
function it_is_initializable() { | ||
$this->shouldHaveType('Oxygen\Core\Theme\ThemeManager'); | ||
} | ||
|
||
function it_can_store_themes(\Oxygen\Core\Theme\Theme $theme) { | ||
$theme->getKey()->willReturn('foo'); | ||
$this->register($theme); | ||
$this->all()->shouldReturn(['foo' => $theme]); | ||
} | ||
|
||
function it_can_make_themes() { | ||
$this->make([ | ||
'key' => 'fantasticTheme', | ||
'name' => 'FANTASTIC Theme', | ||
'provides' => [ | ||
'foo' => 'bar' | ||
] | ||
]); | ||
$this->all()->shouldHaveCount(1); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace spec\Oxygen\Core\Theme; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
|
||
class ThemeSpec extends ObjectBehavior { | ||
|
||
function let() { | ||
$this->beConstructedWith('testTheme'); | ||
} | ||
|
||
function it_is_initializable() { | ||
$this->shouldHaveType('Oxygen\Core\Theme\Theme'); | ||
} | ||
|
||
function it_has_a_key() { | ||
$this->getKey()->shouldReturn('testTheme'); | ||
} | ||
|
||
function it_has_a_name() { | ||
$this->setName('Test Theme'); | ||
$this->getName()->shouldReturn('Test Theme'); | ||
} | ||
|
||
function it_can_provide_things() { | ||
$this->getProvides()->shouldHaveCount(0); | ||
$this->provides('foo', 'bar'); | ||
$this->getProvides()->shouldBe(['foo' => 'bar']); | ||
} | ||
|
||
function it_can_have_an_image() { | ||
$this->hasImage()->shouldReturn(false); | ||
$this->setImage('image'); | ||
$this->getImage()->shouldReturn('image'); | ||
$this->hasImage()->shouldReturn(true); | ||
} | ||
|
||
function it_can_be_filled_from_an_array() { | ||
$this->fillFromArray([ | ||
'name' => 'Other Theme', | ||
'provides' => [ | ||
'other' => 'option' | ||
] | ||
]); | ||
$this->getName()->shouldReturn('Other Theme'); | ||
$this->getProvides()->shouldReturn(['other' => 'option']); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
namespace Oxygen\Core\Html; | ||
|
||
use Exception; | ||
|
||
interface RenderableInterface { | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Oxygen\Core\Theme; | ||
|
||
use Closure; | ||
|
||
class BootThemeMiddleware { | ||
|
||
/** | ||
* The theme manager. | ||
* | ||
* @var ThemeManager | ||
*/ | ||
protected $themeManager; | ||
|
||
/** | ||
* Create a new filter instance. | ||
* | ||
* @param ThemeManager $themes | ||
*/ | ||
public function __construct(ThemeManager $themes) { | ||
$this->themeManager = $themes; | ||
} | ||
|
||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param mixed $request | ||
* @param \Closure $next | ||
* @return mixed | ||
*/ | ||
public function handle($request, Closure $next) { | ||
try { | ||
$currentTheme = $this->themeManager->current(); | ||
$currentTheme->boot(); | ||
} catch(ThemeNotFoundException $e) { | ||
// no theme to boot | ||
} | ||
|
||
return $next($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Oxygen\Core\Theme; | ||
|
||
interface CurrentThemeLoader { | ||
|
||
/** | ||
* Returns the current theme. | ||
* | ||
* @return string | ||
*/ | ||
public function getCurrentTheme(): string; | ||
|
||
/** | ||
* Changes the current theme. | ||
* | ||
* @param string $theme the name of the new theme | ||
*/ | ||
public function setCurrentTheme(string $theme); | ||
|
||
} |
Oops, something went wrong.