Scalr::config PHP Method

config() public static method

Gets config value
public static config ( string $name ) : mixed
$name string An option name
return mixed Returns configuration value for the specified key
    public static function config($name)
    {
        //This is only working with yaml config.
        //If you get error here looks like "Call to a member function get() on a non-object",
        //you probably have not migrated your config.ini to config.yml.
        //Please run php app/bin/upgrade_20130624_migrate_config.php
        return Container::getInstance()->config->get($name);
    }

Usage Example

Exemplo n.º 1
0
 public function defaultAction()
 {
     if ($this->user->getType() == Scalr_Account_User::TYPE_SCALR_ADMIN) {
         $this->response->page('ui/dashboard/admin.js');
     } else {
         if ($this->user->getType() == Scalr_Account_User::TYPE_FIN_ADMIN) {
             self::loadController('Dashboard', 'Scalr_UI_Controller_Admin_Analytics')->defaultAction();
         } else {
             $loadJs = array('ui/dashboard/columns.js');
             $scope = $this->request->getScope();
             $cloudynEnabled = \Scalr::config('scalr.cloudyn.master_email') ? true : false;
             $billingEnabled = \Scalr::config('scalr.billing.enabled') ? true : false;
             $panel = $this->user->getDashboard($this->getEnvironmentId(true));
             if (empty($panel['configuration'])) {
                 // default configurations
                 $client = Client::Load($this->user->getAccountId());
                 if ($client->GetSettingValue(CLIENT_SETTINGS::DATE_FARM_CREATED)) {
                     // old customer
                     if ($scope == 'account') {
                         $panel['configuration'] = array(array(array('name' => 'dashboard.announcement', 'params' => array('newsCount' => 5))), array(array('name' => 'dashboard.environments')));
                         if ($this->user->getType() == Scalr_Account_User::TYPE_ACCOUNT_OWNER && $billingEnabled) {
                             array_unshift($panel['configuration'], array(array('name' => 'dashboard.billing')));
                         }
                     } else {
                         $panel['configuration'] = array(array(array('name' => 'dashboard.status'), array('name' => 'dashboard.addfarm')), array(array('name' => 'dashboard.announcement', 'params' => array('newsCount' => 5))), array(array('name' => 'dashboard.lasterrors', 'params' => array('errorCount' => 10))));
                     }
                 } else {
                     if ($scope == 'account') {
                         // new customer
                         $panel['configuration'] = array(array(array('name' => 'dashboard.newuser')), array(array('name' => 'dashboard.announcement', 'params' => array('newsCount' => 5))));
                         if ($this->user->getType() == Scalr_Account_User::TYPE_ACCOUNT_OWNER && $billingEnabled) {
                             array_unshift($panel['configuration'][1], array('name' => 'dashboard.billing'));
                         }
                     } else {
                         // new customer
                         $panel['configuration'] = array(array(array('name' => 'dashboard.addfarm')), array(array('name' => 'dashboard.newuser')), array(array('name' => 'dashboard.announcement', 'params' => array('newsCount' => 5))));
                     }
                 }
                 $this->user->setDashboard($this->getEnvironmentId(true), $panel);
                 $panel = $this->user->getDashboard($this->getEnvironmentId(true));
             }
             // section for adding required widgets
             if ($scope == 'environment') {
                 if ($cloudynEnabled && !in_array('cloudynInstalled', $panel['flags']) && !in_array('dashboard.cloudyn', $panel['widgets']) && !!$this->environment->isPlatformEnabled(SERVER_PLATFORMS::EC2)) {
                     if (!isset($panel['configuration'][0])) {
                         $panel['configuration'][0] = array();
                     }
                     array_unshift($panel['configuration'][0], array('name' => 'dashboard.cloudyn'));
                     $panel['flags'][] = 'cloudynInstalled';
                     $this->user->setDashboard($this->getEnvironmentId(), $panel);
                     $panel = $this->user->getDashboard($this->getEnvironmentId());
                 }
             }
             $panel = $this->fillDash($panel);
             $conf = $this->getContainer()->config->get('scalr.load_statistics.connections.plotter');
             $monitoringUrl = "{$conf['scheme']}://{$conf['host']}:{$conf['port']}";
             $this->response->page('ui/dashboard/view.js', array('panel' => $panel, 'flags' => array('cloudynEnabled' => $cloudynEnabled, 'billingEnabled' => $billingEnabled), 'params' => array('monitoringUrl' => $monitoringUrl)), $loadJs, array('ui/dashboard/view.css', 'ui/analytics/analytics.css'));
         }
     }
 }
All Usage Examples Of Scalr::config