REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.16 KB
Close
/home/nshryvcy/himaltourism.com/wp-content/plugins/mailpoet/lib/Features/FeaturesController.php
Text
Base64
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\Features; if (!defined('ABSPATH')) exit; use MailPoetVendor\Doctrine\DBAL\Exception\TableNotFoundException; class FeaturesController { const LANDINGPAGE_AB_TEST_DEBUGGER = 'landingpage_ab_test_debugger'; // Define feature defaults in the array below in the following form: // self::FEATURE_NAME_OF_FEATURE => true, private $defaults = [ self::LANDINGPAGE_AB_TEST_DEBUGGER => false, ]; /** @var array|null */ private $flags; /** @var FeatureFlagsRepository */ private $featureFlagsRepository; public function __construct( FeatureFlagsRepository $featureFlagsRepository ) { $this->featureFlagsRepository = $featureFlagsRepository; } /** @return bool */ public function isSupported($feature) { if (!$this->exists($feature)) { throw new \RuntimeException("Unknown feature '$feature'"); } // ensure controller works even if used before migrator, return default value in such case try { $this->ensureFlagsLoaded(); } catch (TableNotFoundException $e) { return $this->defaults[$feature]; } return ($this->flags ?? [])[$feature]; } /** @return bool */ public function exists($feature) { return array_key_exists($feature, $this->defaults); } /** @return array */ public function getDefaults() { return $this->defaults; } /** @return array */ public function getAllFlags() { $this->ensureFlagsLoaded(); return $this->flags ?? []; } public function resetCache(): void { $this->flags = null; } private function ensureFlagsLoaded() { if ($this->flags !== null) { return; } $flagsMap = $this->getValueMap(); $this->flags = []; foreach ($this->defaults as $name => $default) { $this->flags[$name] = isset($flagsMap[$name]) ? $flagsMap[$name] : $default; } } private function getValueMap() { $features = $this->featureFlagsRepository->findAll(); $featuresMap = []; foreach ($features as $feature) { $featuresMap[$feature->getName()] = (bool)$feature->getValue(); } return $featuresMap; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 4
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
FeatureFlagsController.php
1.43 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
FeatureFlagsRepository.php
1.16 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
FeaturesController.php
2.16 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.php
0 B
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).