Gdn::installationSecret PHP Method

installationSecret() public static method

Gets/Sets the Garden Installation Secret
public static installationSecret ( string $SetInstallationSecret = null ) : string
$SetInstallationSecret string
return string Installation Secret or NULL
    public static function installationSecret($SetInstallationSecret = null)
    {
        static $InstallationSecret = false;
        if (!is_null($SetInstallationSecret)) {
            if ($SetInstallationSecret !== false) {
                SaveToConfig('Garden.InstallationSecret', $SetInstallationSecret);
            } else {
                RemoveFromConfig('Garden.InstallationSecret');
            }
            $InstallationSecret = $SetInstallationSecret;
        }
        if ($InstallationSecret === false) {
            $InstallationSecret = c('Garden.InstallationSecret', null);
        }
        return $InstallationSecret;
    }

Usage Example

 /**
  * Statistics setup & configuration.
  *
  * @since 2.0.17
  * @access public
  */
 public function index()
 {
     $this->permission('Garden.Settings.Manage');
     $this->addSideMenu('dashboard/statistics');
     //$this->addJsFile('statistics.js');
     $this->title(t('Vanilla Statistics'));
     $this->enableSlicing($this);
     if ($this->Form->authenticatedPostBack()) {
         $Flow = true;
         if ($Flow && $this->Form->getFormValue('Reregister')) {
             Gdn::Statistics()->register();
         }
         if ($Flow && $this->Form->getFormValue('Save')) {
             Gdn::installationID($this->Form->getFormValue('InstallationID'));
             Gdn::installationSecret($this->Form->getFormValue('InstallationSecret'));
             $this->informMessage(t("Your settings have been saved."));
         }
         if ($Flow && $this->Form->getFormValue('AllowLocal')) {
             saveToConfig('Garden.Analytics.AllowLocal', true);
         }
         if ($Flow && $this->Form->getFormValue('Allow')) {
             saveToConfig('Garden.Analytics.Enabled', true);
         }
         if ($Flow && $this->Form->getFormValue('ClearCredentials')) {
             Gdn::installationID(false);
             Gdn::installationSecret(false);
             Gdn::statistics()->Tick();
             $Flow = false;
         }
     } else {
         $this->Form->setValue('InstallationID', Gdn::installationID());
         $this->Form->setValue('InstallationSecret', Gdn::installationSecret());
     }
     $AnalyticsEnabled = Gdn_Statistics::checkIsEnabled();
     if ($AnalyticsEnabled) {
         $ConfFile = Gdn::config()->defaultPath();
         $this->setData('ConfWritable', $ConfWritable = is_writable($ConfFile));
         if (!$ConfWritable) {
             $AnalyticsEnabled = false;
         }
     }
     $this->setData('AnalyticsEnabled', $AnalyticsEnabled);
     $NotifyMessage = Gdn::get('Garden.Analytics.Notify', false);
     $this->setData('NotifyMessage', $NotifyMessage);
     if ($NotifyMessage !== false) {
         Gdn::set('Garden.Analytics.Notify', null);
     }
     $this->render();
 }
All Usage Examples Of Gdn::installationSecret