is_enabled = false; } public function getCmsPageOptions() { if (!$theme = Theme::getEditTheme()) { throw new ApplicationException('Unable to find the active theme.'); } return Page::listInTheme($theme)->lists('fileName', 'fileName'); } /** * Ensure each theme has its own CMS page, store it inside a mapping array. * @return void */ public function beforeValidate() { if (!$theme = Theme::getEditTheme()) { throw new ApplicationException('Unable to find the active theme.'); } $themeMap = $this->getSettingsValue('theme_map', []); $themeMap[$theme->getDirName()] = $this->getSettingsValue('cms_page'); $this->setSettingsValue('theme_map', $themeMap); } /** * Restore the CMS page found in the mapping array, or disable the * maintenance mode. * @return void */ public function afterFetch() { if ( ($theme = Theme::getEditTheme()) && ($themeMap = array_get($this->attributes, 'theme_map')) && ($cmsPage = array_get($themeMap, $theme->getDirName())) ) { $this->cms_page = $cmsPage; } else { $this->is_enabled = false; } } /** * Check if the provided IP is in the allowed IP list. * * @param string $ip * @return bool */ public static function isAllowedIp(string $ip): bool { return IpUtils::checkIp($ip, Arr::pluck(static::get('allowed_ips', []), 'ip')); } }