Contao\Config::persist PHP Метод

persist() публичный статический Метод

Permanently set a configuration value
public static persist ( string $strKey, mixed $varValue )
$strKey string The short key or full variable name
$varValue mixed The configuration value
    public static function persist($strKey, $varValue)
    {
        $objConfig = static::getInstance();
        if (strncmp($strKey, '$GLOBALS', 8) !== 0) {
            $strKey = "\$GLOBALS['TL_CONFIG']['{$strKey}']";
        }
        $objConfig->add($strKey, $varValue);
    }

Usage Example

Пример #1
0
 /**
  * Initialize the controller
  *
  * 1. Import the user
  * 2. Call the parent constructor
  * 3. Authenticate the user
  * 4. Load the language files
  * DO NOT CHANGE THIS ORDER!
  */
 public function __construct()
 {
     $this->import('BackendUser', 'User');
     parent::__construct();
     $this->User->authenticate();
     // Password change required
     if ($this->User->pwChange) {
         /** @var SessionInterface $session */
         $session = \System::getContainer()->get('session');
         $objSession = $this->Database->prepare("SELECT su FROM tl_session WHERE sessionID=? AND pid=?")->execute($session->getId(), $this->User->id);
         if (!$objSession->su) {
             $this->redirect('contao/password.php');
         }
     }
     // Front end redirect
     if (\Input::get('do') == 'feRedirect') {
         $this->redirectToFrontendPage(\Input::get('page'), \Input::get('article'));
     }
     // Convenience functions
     if ($this->User->isAdmin) {
         // Maintenance mode off
         if (\Input::get('mmo')) {
             \Config::persist('maintenanceMode', false);
             $this->redirect($this->getReferer());
         }
         // Build internal cache
         if (\Input::get('bic')) {
             $this->import('Automator');
             $this->Automator->generateInternalCache();
             $this->redirect($this->getReferer());
         }
     }
     \System::loadLanguageFile('default');
     \System::loadLanguageFile('modules');
 }
All Usage Examples Of Contao\Config::persist