当前位置: 首页>>代码示例>>PHP>>正文


PHP Director::get_environment_type方法代码示例

本文整理汇总了PHP中Director::get_environment_type方法的典型用法代码示例。如果您正苦于以下问题:PHP Director::get_environment_type方法的具体用法?PHP Director::get_environment_type怎么用?PHP Director::get_environment_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Director的用法示例。


在下文中一共展示了Director::get_environment_type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onAfterInit

 function onAfterInit()
 {
     if (in_array(Director::get_environment_type(), Config::inst()->get('FartScrollExtension', 'environmentTypes'))) {
         Requirements::javascript('http://code.onion.com/fartscroll.js');
         Requirements::customScript('fartscroll(' . Config::inst()->get('FartScrollExtension', 'speed') . ');', 'Fart');
     }
 }
开发者ID:helpfulrobot,项目名称:axyr-silverstripe-fartscroll,代码行数:7,代码来源:FartScrollExtension.php

示例2: BetterNavigator

 /**
  * Provides a front-end utility menu with administrative functions and developer tools
  * Relies on SilverStripeNavigator
  * 
  * @return string
  */
 public function BetterNavigator()
 {
     $isDev = Director::isDev();
     if ($isDev || Permission::check('CMS_ACCESS_CMSMain') || Permission::check('VIEW_DRAFT_CONTENT')) {
         if ($this->owner && $this->owner->dataRecord) {
             //Get SilverStripeNavigator links & stage info (CMS/Stage/Live/Archive)
             $nav = array();
             $navigator = new SilverStripeNavigator($this->owner->dataRecord);
             $items = $navigator->getItems();
             foreach ($items as $item) {
                 $nav[$item->getName()] = array('Link' => $item->getLink(), 'Active' => $item->isActive());
             }
             //Is the logged in member nominated as a developer?
             $member = Member::currentUser();
             $devs = Config::inst()->get('BetterNavigator', 'developers');
             $isDeveloper = $member && is_array($devs) ? in_array($member->Email, $devs) : false;
             //Add other data for template
             $nav = array_merge($nav, array('Member' => $member, 'Stage' => Versioned::current_stage(), 'LoginLink' => Config::inst()->get('Security', 'login_url'), 'Mode' => Director::get_environment_type(), 'IsDeveloper' => $isDeveloper));
             //Merge with page data, send to template and render
             $nav = new ArrayData($nav);
             $page = $this->owner->customise($nav);
             return $page->renderWith('BetterNavigator');
         }
     }
     return false;
 }
开发者ID:Tangdongle,项目名称:silverstripe-betternavigator,代码行数:32,代码来源:BetterNavigator.php

示例3: should_compile

 /**
  * Determines whether this environment should compile meta-languages
  *
  * @return bool
  */
 protected static function should_compile()
 {
     $config = Config::inst()->forClass("MetaLanguages");
     if (!$config->enable_compiling) {
         return false;
     }
     return in_array(Director::get_environment_type(), $config->environments) || in_array($_SERVER['HTTP_HOST'], $config->environments);
 }
开发者ID:helpfulrobot,项目名称:unclecheese-meta-languages,代码行数:13,代码来源:MetaLanguages.php

示例4: get_environment

 /**
  * Get the payment environment.
  * The environment is retrieved from the config yaml file.
  * If no environment is specified, assume SilverStripe's environment.
  */
 public static function get_environment()
 {
     if (Config::inst()->get('PaymentGateway', 'environment')) {
         return Config::inst()->get('PaymentGateway', 'environment');
     } else {
         return Director::get_environment_type();
     }
 }
开发者ID:vinstah,项目名称:body,代码行数:13,代码来源:PaymentGateway.php

示例5: setUp

 function setUp()
 {
     parent::setUp();
     TestDataController::$data_dir = 'testdata/tests';
     $this->envType = Director::get_environment_type();
     Director::set_environment_type('test');
     TestDataController::$quiet = true;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-testdata,代码行数:8,代码来源:TestDataTest.php

示例6: setUp

 function setUp()
 {
     parent::setUp();
     $this->orig['ErrorPage_staticfilepath'] = ErrorPage::get_static_filepath();
     $this->tmpAssetsPath = sprintf('%s/_tmp_assets_%s', TEMP_FOLDER, rand());
     Filesystem::makeFolder($this->tmpAssetsPath . '/ErrorPageTest');
     ErrorPage::set_static_filepath($this->tmpAssetsPath . '/ErrorPageTest');
     $this->orig['Director_environmenttype'] = Director::get_environment_type();
     Director::set_environment_type('live');
 }
开发者ID:rixrix,项目名称:silverstripe-cms,代码行数:10,代码来源:ErrorPageTest.php

示例7: ContactInformations

 /**
  * @return DataObject
  */
 public function ContactInformations()
 {
     // 	checks for the active environment type, to load minified css and js files if in live mode
     if (Director::get_environment_type() == "dev" || Director::get_environment_type() == "test") {
         Requirements::css("widget_Contact/css/contactwidget.css");
     } else {
         Requirements::css("widget_Contact/css/contactwidget.min.css");
     }
     return SiteConfig::get()->First();
 }
开发者ID:helpfulrobot,项目名称:denkfabrik-neue-medien-silverstripe-widget-contact,代码行数:13,代码来源:ContactWidget.php

示例8: init

 /**
  * (non-PHPdoc)
  * @see sapphire/core/control/ContentController#init()
  */
 public function init()
 {
     parent::init();
     // 	checks for the active environment type, to load minified css and js files if in live mode
     if (Director::get_environment_type() == "dev" || Director::get_environment_type() == "test") {
         Requirements::css("imprintpage/css/imprint.css");
     } else {
         Requirements::css("imprintpage/css/imprint.min.css");
     }
 }
开发者ID:helpfulrobot,项目名称:denkfabrik-neue-medien-silverstripe-imprintpage,代码行数:14,代码来源:ImprintPage.php

示例9: doBootstrap

 /**
  * @param \Session $session
  * @return void
  */
 public function doBootstrap(Session $session)
 {
     if ($this->container === null) {
         require_once HEYSTACK_BASE_PATH . '/config/container.php';
         $containerClassName = 'HeystackServiceContainer' . \Director::get_environment_type();
         $this->container = new $containerClassName();
     }
     \Injector::inst()->setObjectCreator(new HeystackInjectionCreator($this->container));
     $this->container->get(Services::BACKEND_SESSION)->setSession($session);
     $this->eventDispatcher = $this->container->get(Services::EVENT_DISPATCHER);
 }
开发者ID:helpfulrobot,项目名称:heystack-heystack,代码行数:15,代码来源:Bootstrap.php

示例10: canView

 function canView()
 {
     if (self::$trusted_envs && !in_array(Director::get_environment_type(), self::$trusted_envs)) {
         return false;
     }
     if (self::$trusted_ips && !in_array($_SERVER['REMOTE_ADDR'], self::$trusted_ips)) {
         return false;
     }
     if (!self::$activated) {
         return false;
     }
     return parent::canView();
 }
开发者ID:alapini,项目名称:silverstripe-dbplumber,代码行数:13,代码来源:DatabaseBrowser.php

示例11: BetterNavigator

 /**
  * Provides a front-end utility menu with administrative functions and developer tools
  * Relies on SilverStripeNavigator
  *
  * @return string
  */
 public function BetterNavigator()
 {
     // Make sure this is a page
     if (!($this->owner && $this->owner->dataRecord && $this->owner->dataRecord instanceof SiteTree && $this->owner->dataRecord->ID > 0)) {
         return false;
     }
     // Only show navigator to appropriate users
     $isDev = Director::isDev();
     $canViewDraft = Permission::check('VIEW_DRAFT_CONTENT') || Permission::check('CMS_ACCESS_CMSMain');
     if ($isDev || $canViewDraft) {
         // Get SilverStripeNavigator links & stage info (CMS/Stage/Live/Archive)
         $nav = array();
         $viewing = '';
         $navigator = new SilverStripeNavigator($this->owner->dataRecord);
         $items = $navigator->getItems();
         foreach ($items as $item) {
             $name = $item->getName();
             $active = $item->isActive();
             $nav[$name] = array('Link' => $item->getLink(), 'Active' => $active);
             if ($active) {
                 if ($name == 'LiveLink') {
                     $viewing = 'Live';
                 }
                 if ($name == 'StageLink') {
                     $viewing = 'Draft';
                 }
                 if ($name == 'ArchiveLink') {
                     $viewing = 'Archived';
                 }
             }
         }
         // Only show edit link if user has permission to edit this page
         $editLink = $this->owner->dataRecord->canEdit() && Permission::check('CMS_ACCESS_CMSMain') || $isDev ? $nav['CMSLink']['Link'] : false;
         // Is the logged in member nominated as a developer?
         $member = Member::currentUser();
         $devs = Config::inst()->get('BetterNavigator', 'developers');
         $identifierField = Member::config()->unique_identifier_field;
         $isDeveloper = $member && is_array($devs) ? in_array($member->{$identifierField}, $devs) : false;
         // Add other data for template
         $backURL = '?BackURL=' . urlencode($this->owner->Link());
         $bNData = array_merge($nav, array('Member' => $member, 'Stage' => Versioned::current_stage(), 'Viewing' => $viewing, 'LoginLink' => Config::inst()->get('Security', 'login_url') . $backURL, 'LogoutLink' => 'Security/logout' . $backURL, 'EditLink' => $editLink, 'Mode' => Director::get_environment_type(), 'IsDeveloper' => $isDeveloper));
         // Merge with page data, send to template and render
         $bNData = new ArrayData($bNData);
         $page = $this->owner->customise(array('BetterNavigator' => $bNData));
         return $page->renderWith('BetterNavigator');
     }
     return false;
 }
开发者ID:sb-relaxt-at,项目名称:silverstripe-betternavigator,代码行数:54,代码来源:BetterNavigator.php

示例12: execute

 /**
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return void
  * @throws \Exception
  */
 protected function execute(Input\InputInterface $input, Output\OutputInterface $output)
 {
     if ($input->getOption('dev-build')) {
         $output->writeln('Building database');
         $databaseAdmin = new \DatabaseAdmin();
         $databaseAdmin->doBuild(true);
         $output->writeln('Database built');
     }
     // Get mode
     if ($input->getOption('mode')) {
         $mode = $input->getOption('mode');
     } else {
         $mode = \Director::get_environment_type();
     }
     $container = $this->createContainer();
     $this->loadConfig($container, $mode);
     $output->writeln($this->dumpContainer($container, $mode, $input->getOption('debug')));
 }
开发者ID:helpfulrobot,项目名称:heystack-heystack,代码行数:24,代码来源:GenerateContainer.php

示例13: init_authenticator

 /**
  * Initialises the selected SSPAuthenticator class for SimpleSAMLphp authentication
  * @return SSPAuthenticator Active session for authentication
  */
 private static function init_authenticator()
 {
     $authenticators = SSPSecurity::config()->authenticators;
     if (!$authenticators || !is_array($authenticators)) {
         user_error("Expected array of authentication sources in SSPSecurity::authenticators", E_USER_ERROR);
     }
     $auth_source = '';
     //If set, override authentication sources in config
     if (isset($_GET['as'])) {
         $auth_source = $_GET['as'];
     } else {
         $default_auth = SSPSecurity::config()->default_authenticator;
         $env = Director::get_environment_type();
         if (is_string($default_auth)) {
             $auth_source = $default_auth;
         } else {
             if (is_array($default_auth) && array_key_exists($env, $default_auth)) {
                 $auth_source = $default_auth[$env];
             }
         }
     }
     //If no auth_source is found, default to the first authentication source
     if (empty($auth_source)) {
         $auth_source = key($authenticators);
     }
     if (!array_key_exists($auth_source, $authenticators)) {
         user_error("'{$auth_source}' does not exist in SSPSecurity::authenticators", E_USER_ERROR);
     }
     $class = $authenticators[$auth_source];
     if (!class_exists($class)) {
         user_error("{$class} does not exist", E_USER_ERROR);
     }
     if (!is_subclass_of($class, 'SSPAuthenticator')) {
         user_error("{$class} does not extend from SSPAuthenticator", E_USER_ERROR);
     }
     return self::create_authenticator($class, $auth_source);
 }
开发者ID:helpfulrobot,项目名称:antons-silverstripe-ssp,代码行数:41,代码来源:SSPAuthFactory.php

示例14: databaseError

 public function databaseError($msg, $errorLevel = E_USER_ERROR)
 {
     // try to extract and format query
     if (preg_match('/Couldn\'t run query: ([^\\|]*)\\|\\s*(.*)/', $msg, $matches)) {
         $formatter = new SQLFormatter();
         $msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
     }
     $connect_errno = $this->dbConn->connect_errno;
     $errno = $this->dbConn->errno;
     $sqlstate = $this->dbConn->sqlstate;
     $error = $this->dbConn->error;
     $connect_error = $msg;
     $msg = sprintf('connect_errno : %s - errno : %s - sqlstate : %s - error : %s - connect_error : %s', $connect_errno, $errno, $sqlstate, $error, $connect_error);
     SS_Log::log($msg, SS_Log::ERR);
     if (Director::get_environment_type() === "live") {
         ob_clean();
         $maintenance_page = file_get_contents(Director::baseFolder() . '/maintenance/index.html');
         echo $maintenance_page;
         header("HTTP/1.0 502 Bad Gateway");
         exit;
     } else {
         user_error($msg);
     }
 }
开发者ID:rbowen,项目名称:openstack-org,代码行数:24,代码来源:CustomMySQLDatabase.php

示例15: index

 /**
  * Display information when default route is viewed
  * Default routes is /dev/healthcheck
  */
 public function index()
 {
     $data = array('Title' => 'Health check', 'Content' => 'Health check content...', 'Environment' => Director::get_environment_type(), 'Mailer' => Email::mailer()->class, 'AdminEmail' => Config::inst()->get('Email', 'admin_email'), 'SendAllEmailsTo' => Config::inst()->get('Email', 'send_all_emails_to'), 'Nofollow' => $this->getRobotsMetaTag(), 'Logging' => $this->getLogWriters(), 'SiteMap' => $this->hasSiteMap(), 'LastCommit' => $this->getLastCommit());
     $this->extend('updateIndexData', $data);
     return $this->customise($data)->renderWith(array("HealthCheck"));
 }
开发者ID:platocreative,项目名称:silverstripe-healthcheck,代码行数:10,代码来源:HealthCheck_Controller.php


注:本文中的Director::get_environment_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。