Skip to content

Commit

Permalink
isLumen() fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Szekeres Bálint committed Feb 20, 2018
1 parent e183ebb commit 7f058a8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Concerns/Shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private function parseClassShortcodes(ShortcodeFacade $facade)
*/
private function parseConfigShortcodes(ShortcodeFacade $facade)
{
if (Corcel::isLaravel()) {
if (Corcel::isLaravel() || Corcel::isLumen()) {
$shortcodes = config('corcel.shortcodes', []);
foreach ($shortcodes as $tag => $class) {
$facade->addHandler($tag, [new $class, 'render']);
Expand Down
3 changes: 2 additions & 1 deletion src/Corcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static function isLaravel()
*/
public static function isLumen()
{
return preg_match('/Lumen', app()->version()) === 1;
return function_exists('app') &&
preg_match('/^Lumen/', app()->version()) === 1;
}
}
4 changes: 2 additions & 2 deletions src/Laravel/CorcelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function boot()
$this->registerAuthProvider();
$this->registerMorphMaps();
}

/**
* @return void
*/
Expand All @@ -46,7 +46,7 @@ private function publishConfigFile()
*/
private function registerAuthProvider()
{
if (Corcel::isLaravel()) {
if (Corcel::isLaravel() || Corcel::isLumen()) {
Auth::provider('corcel', function ($app, array $config) {
return new AuthUserProvider($config);
});
Expand Down
2 changes: 1 addition & 1 deletion src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected function setRelationConnection($model)
*/
public function getConnectionName()
{
if (!isset($this->connection) && Corcel::isLaravel()) {
if (!isset($this->connection) && (Corcel::isLaravel() || Corcel::isLumen())) {
if ($connection = config('corcel.connection')) {
$this->connection = $connection;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected function getPostInstance(array $attributes)
if (isset($attributes['post_type']) && $attributes['post_type']) {
if (isset(static::$postTypes[$attributes['post_type']])) {
$class = static::$postTypes[$attributes['post_type']];
} elseif (Corcel::isLaravel()) {
} elseif (Corcel::isLaravel() || Corcel::isLumen()) {
$postTypes = config('corcel.post_types');
if (is_array($postTypes) && isset($postTypes[$attributes['post_type']])) {
$class = $postTypes[$attributes['post_type']];
Expand Down

0 comments on commit 7f058a8

Please sign in to comment.