-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the
Features
functionality from Foundation to Support
- Loading branch information
1 parent
d0804b8
commit b62feae
Showing
4 changed files
with
127 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Contains the Features class. | ||
* | ||
* @copyright Copyright (c) 2023 Vanilo UG | ||
* @author Attila Fulop | ||
* @license MIT | ||
* @since 2023-09-07 | ||
* | ||
*/ | ||
|
||
namespace Vanilo\Support; | ||
|
||
use Vanilo\Support\Features\MultiChannel; | ||
use Vanilo\Support\Features\Pricing; | ||
|
||
class Features | ||
{ | ||
private static ?MultiChannel $multiChannel = null; | ||
|
||
private static ?Pricing $pricing = null; | ||
|
||
public static function multichannel(): MultiChannel | ||
{ | ||
return self::$multiChannel ?: (self::$multiChannel = new MultiChannel()); | ||
} | ||
|
||
public static function pricing(): Pricing | ||
{ | ||
return self::$pricing ?: (self::$pricing = new Pricing()); | ||
} | ||
|
||
public static function isMultiChannelEnabled(): bool | ||
{ | ||
return self::multichannel()->isEnabled(); | ||
} | ||
|
||
public static function isMultiChannelDisabled(): bool | ||
{ | ||
return self::multichannel()->isDisabled(); | ||
} | ||
|
||
public static function isPricingEnabled(): bool | ||
{ | ||
return self::pricing()->isEnabled(); | ||
} | ||
|
||
public static function isPricingDisabled(): bool | ||
{ | ||
return self::pricing()->isDisabled(); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Contains the MultiChannel class. | ||
* | ||
* @copyright Copyright (c) 2023 Vanilo UG | ||
* @author Attila Fulop | ||
* @license MIT | ||
* @since 2023-09-07 | ||
* | ||
*/ | ||
|
||
namespace Vanilo\Support\Features; | ||
|
||
use Vanilo\Contracts\Feature; | ||
|
||
class MultiChannel implements Feature | ||
{ | ||
public function isEnabled(): bool | ||
{ | ||
return (bool) config('vanilo.features.multi_channel.is_enabled', false); | ||
} | ||
|
||
public function isDisabled(): bool | ||
{ | ||
return !$this->isEnabled(); | ||
} | ||
|
||
public function configuration(): array | ||
{ | ||
return config('vanilo.foundation.features.multi_channel', []); | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Contains the Pricing class. | ||
* | ||
* @copyright Copyright (c) 2024 Vanilo UG | ||
* @author Attila Fulop | ||
* @license MIT | ||
* @since 2024-01-18 | ||
* | ||
*/ | ||
|
||
namespace Vanilo\Support\Features; | ||
|
||
use Vanilo\Contracts\Feature; | ||
|
||
class Pricing implements Feature | ||
{ | ||
public function isEnabled(): bool | ||
{ | ||
return config('vanilo.foundation.features.pricing.is_enabled', false) | ||
&& null !== concord()->module('vanilo.pricing'); | ||
} | ||
|
||
public function isDisabled(): bool | ||
{ | ||
return !$this->isEnabled(); | ||
} | ||
|
||
public function configuration(): array | ||
{ | ||
return config('vanilo.foundation.features.pricing', []); | ||
} | ||
} |