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


PHP Config::inst方法代码示例

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


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

示例1: create

 /**
  * Create member account from data array.
  * Data must contain unique identifier.
  *
  * @throws ValidationException
  * @param $data - map of member data
  * @return Member|boolean - new member (not saved to db), or false if there is an error.
  */
 public function create($data)
 {
     $result = new ValidationResult();
     if (!Checkout::member_creation_enabled()) {
         $result->error(_t("Checkout.MEMBERSHIPSNOTALLOWED", "Creating new memberships is not allowed"));
         throw new ValidationException($result);
     }
     $idfield = Config::inst()->get('Member', 'unique_identifier_field');
     if (!isset($data[$idfield]) || empty($data[$idfield])) {
         $result->error(sprintf(_t("Checkout.IDFIELDNOTFOUND", "Required field not found: %s"), $idfield));
         throw new ValidationException($result);
     }
     if (!isset($data['Password']) || empty($data['Password'])) {
         $result->error(_t("Checkout.PASSWORDREQUIRED", "A password is required"));
         throw new ValidationException($result);
     }
     $idval = $data[$idfield];
     if (ShopMember::get_by_identifier($idval)) {
         $result->error(sprintf(_t("Checkout.MEMBEREXISTS", "A member already exists with the %s %s"), _t("Member." . $idfield, $idfield), $idval));
         throw new ValidationException($result);
     }
     $member = new Member(Convert::raw2sql($data));
     $validation = $member->validate();
     if (!$validation->valid()) {
         //TODO need to handle i18n here?
         $result->error($validation->message());
     }
     if (!$result->valid()) {
         throw new ValidationException($result);
     }
     return $member;
 }
开发者ID:renskorswagen,项目名称:silverstripe-shop,代码行数:40,代码来源:ShopMemberFactory.php

示例2: set_default_quality

 /**
  * set_default_quality
  *
  * @deprecated 4.0 Use the "ImagickBackend.default_quality" config setting instead
  * @param int $quality
  * @return void
  */
 public static function set_default_quality($quality)
 {
     Deprecation::notice('4.0', 'Use the "ImagickBackend.default_quality" config setting instead');
     if (is_numeric($quality) && (int) $quality >= 0 && (int) $quality <= 100) {
         Config::inst()->update('ImagickBackend', 'default_quality', (int) $quality);
     }
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:14,代码来源:ImagickBackend.php

示例3: sendMessage

 public function sendMessage($source, $message, $recipients, $arguments = array())
 {
     $from = empty($arguments['from']) ? Config::inst()->get(get_class($this), 'default_from') : $arguments['from'];
     $subject = empty($arguments['subject']) ? Config::inst()->get(get_class($this), 'default_subject') : $arguments['subject'];
     // Split users and send individually
     $this->sendIndividualMessages($source, $message, $recipients, $from, $subject);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-deploynaut,代码行数:7,代码来源:EmailMessagingService.php

示例4: preRequest

 public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model)
 {
     if (!$this->testSessionEnvironment->isRunningTests()) {
         return;
     }
     $testState = $this->testSessionEnvironment->getState();
     // Date and time
     if (isset($testState->datetime)) {
         SS_Datetime::set_mock_now($testState->datetime);
     }
     // Register mailer
     if (isset($testState->mailer)) {
         $mailer = $testState->mailer;
         Email::set_mailer(new $mailer());
         Config::inst()->update("Email", "send_all_emails_to", null);
     }
     // Allows inclusion of a PHP file, usually with procedural commands
     // to set up required test state. The file can be generated
     // through {@link TestSessionStubCodeWriter}, and the session state
     // set through {@link TestSessionController->set()} and the
     // 'testsession.stubfile' state parameter.
     if (isset($testState->stubfile)) {
         $file = $testState->stubfile;
         if (!Director::isLive() && $file && file_exists($file)) {
             // Connect to the database so the included code can interact with it
             global $databaseConfig;
             if ($databaseConfig) {
                 DB::connect($databaseConfig);
             }
             include_once $file;
         }
     }
 }
开发者ID:jeffreyguo,项目名称:silverstripe-testsession,代码行数:33,代码来源:TestSessionRequestFilter.php

示例5: testRequestProtocolReflectedInGetOembedFromUrl

 public function testRequestProtocolReflectedInGetOembedFromUrl()
 {
     Config::inst()->update('Oembed', 'providers', array('http://*.silverstripe.com/watch*' => array('http' => 'http://www.silverstripe.com/oembed/', 'https' => 'https://www.silverstripe.com/oembed/?scheme=https'), 'https://*.silverstripe.com/watch*' => array('http' => 'http://www.silverstripe.com/oembed/', 'https' => 'https://www.silverstripe.com/oembed/?scheme=https')));
     Config::inst()->update('Director', 'alternate_protocol', 'http');
     foreach (array('http', 'https') as $protocol) {
         $url = $protocol . '://www.silverstripe.com/watch12345';
         $result = Oembed::get_oembed_from_url($url);
         $this->assertInstanceOf('Oembed_Result', $result);
         $this->assertEquals($result->getOembedURL(), 'http://www.silverstripe.com/oembed/?format=json&url=' . urlencode($url), 'Returns http based URLs when request is over http, regardless of source URL');
     }
     Config::inst()->update('Director', 'alternate_protocol', 'https');
     foreach (array('http', 'https') as $protocol) {
         $url = $protocol . '://www.silverstripe.com/watch12345';
         $result = Oembed::get_oembed_from_url($url);
         $this->assertInstanceOf('Oembed_Result', $result);
         $this->assertEquals($result->getOembedURL(), 'https://www.silverstripe.com/oembed/?scheme=https&format=json&url=' . urlencode($url), 'Returns https based URLs when request is over https, regardless of source URL');
     }
     Config::inst()->update('Director', 'alternate_protocol', 'foo');
     foreach (array('http', 'https') as $protocol) {
         $url = $protocol . '://www.silverstripe.com/watch12345';
         $result = Oembed::get_oembed_from_url($url);
         $this->assertInstanceOf('Oembed_Result', $result);
         $this->assertEquals($result->getOembedURL(), 'http://www.silverstripe.com/oembed/?format=json&url=' . urlencode($url), 'When request protocol doesn\'t have specific handler, fall back to first option');
     }
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:25,代码来源:OembedTest.php

示例6: bulkLoadUsers

 /**
  * Bulk load a set of members using the same meta-data rules as if they were to log in
  * @param SS_List $members A list of members
  * @return IntercomBulkJob
  */
 public function bulkLoadUsers(SS_List $members)
 {
     $userFields = Config::inst()->get('Intercom', 'user_fields');
     $companyFields = Config::inst()->get('Intercom', 'company_fields');
     $scriptTags = new IntercomScriptTags();
     // Build the batch API submission
     foreach ($members as $member) {
         $settings = $scriptTags->getIntercomSettings($member);
         unset($settings['app_id']);
         unset($settings['user_hash']);
         foreach ($settings as $k => $v) {
             if (!in_array($k, $userFields)) {
                 $settings['custom_attributes'][$k] = $v;
                 unset($settings[$k]);
             }
         }
         if (isset($settings['company'])) {
             foreach ($settings['company'] as $k => $v) {
                 if (!in_array($k, $companyFields)) {
                     $settings['company']['custom_attributes'][$k] = $v;
                     unset($settings['company'][$k]);
                 }
             }
         }
         $items[] = ['data_type' => 'user', 'method' => 'post', 'data' => $settings];
     }
     $result = $this->getClient()->bulkUsers(['items' => $items]);
     return $this->getBulkJob($result->get('id'));
 }
开发者ID:helpfulrobot,项目名称:sminnee-silverstripe-intercom,代码行数:34,代码来源:Intercom.php

示例7: testEnablePluginsByArrayWithPaths

 public function testEnablePluginsByArrayWithPaths()
 {
     Config::inst()->update('Director', 'alternate_base_url', 'http://mysite.com/subdir');
     $c = new TinyMCEConfig();
     $c->setTheme('modern');
     $c->setOption('language', 'es');
     $c->disablePlugins('table', 'emoticons', 'paste', 'code', 'link', 'importcss');
     $c->enablePlugins(array('plugin1' => 'mypath/plugin1.js', 'plugin2' => '/anotherbase/mypath/plugin2.js', 'plugin3' => 'https://www.google.com/plugin.js', 'plugin4' => null, 'plugin5' => null));
     $attributes = $c->getAttributes();
     $config = Convert::json2array($attributes['data-config']);
     $plugins = $config['external_plugins'];
     $this->assertNotEmpty($plugins);
     // Plugin specified via relative url
     $this->assertContains('plugin1', array_keys($plugins));
     $this->assertEquals('http://mysite.com/subdir/mypath/plugin1.js', $plugins['plugin1']);
     // Plugin specified via root-relative url
     $this->assertContains('plugin2', array_keys($plugins));
     $this->assertEquals('http://mysite.com/anotherbase/mypath/plugin2.js', $plugins['plugin2']);
     // Plugin specified with absolute url
     $this->assertContains('plugin3', array_keys($plugins));
     $this->assertEquals('https://www.google.com/plugin.js', $plugins['plugin3']);
     // Plugin specified with standard location
     $this->assertContains('plugin4', array_keys($plugins));
     $this->assertEquals('http://mysite.com/subdir/framework/thirdparty/tinymce/plugins/plugin4/plugin.min.js', $plugins['plugin4']);
     // Check that internal plugins are extractable separately
     $this->assertEquals(['plugin4', 'plugin5'], $c->getInternalPlugins());
     // Test plugins included via gzip compresser
     Config::inst()->update('HTMLEditorField', 'use_gzip', true);
     $this->assertEquals('framework/thirdparty/tinymce/tiny_mce_gzip.php?js=1&plugins=plugin4,plugin5&themes=modern&languages=es&diskcache=true&src=true', $c->getScriptURL());
     // If gzip is disabled only the core plugin is loaded
     Config::inst()->remove('HTMLEditorField', 'use_gzip');
     $this->assertEquals('framework/thirdparty/tinymce/tinymce.min.js', $c->getScriptURL());
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:33,代码来源:HTMLEditorConfigTest.php

示例8: setUp

 public function setUp()
 {
     parent::setUp();
     Config::nest();
     Config::inst()->update('HtmlEditorField_Toolbar', 'fileurl_scheme_whitelist', array('http'));
     Config::inst()->update('HtmlEditorField_Toolbar', 'fileurl_domain_whitelist', array('example.com'));
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:7,代码来源:HtmlEditorFieldToolbarTest.php

示例9: MetaTags

 /**
  * Return the title, description, keywords and language metatags.
  * 
  * @todo Move <title> tag in separate getter for easier customization and more obvious usage
  * 
  * @param boolean|string $includeTitle Show default <title>-tag, set to false for custom templating
  * @return string The XHTML metatags
  */
 public function MetaTags($includeTitle = true)
 {
     $tags = "";
     if ($includeTitle === true || $includeTitle == 'true') {
         $tags .= "<title>" . Convert::raw2xml($this->Title) . "</title>\n";
     }
     $generator = trim(Config::inst()->get('SiteTree', 'meta_generator'));
     if (!empty($generator)) {
         $tags .= "<meta name=\"generator\" content=\"" . Convert::raw2att($generator) . "\" />\n";
     }
     $charset = Config::inst()->get('ContentNegotiator', 'encoding');
     $tags .= "<meta http-equiv=\"Content-type\" content=\"text/html; charset={$charset}\" />\n";
     if ($this->MetaDescription) {
         $tags .= "<meta name=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
     }
     if ($this->ExtraMeta) {
         $tags .= $this->ExtraMeta . "\n";
     }
     if (Permission::check('CMS_ACCESS_CMSMain') && in_array('CMSPreviewable', class_implements($this)) && !$this instanceof ErrorPage) {
         $tags .= "<meta name=\"x-page-id\" content=\"{$this->ID}\" />\n";
         $tags .= "<meta name=\"x-cms-edit-link\" content=\"" . $this->CMSEditLink() . "\" />\n";
     }
     $this->extend('MetaTags', $tags);
     return $tags;
 }
开发者ID:i-lateral,项目名称:silverstripe-catalogue,代码行数:33,代码来源:CatalogueController.php

示例10: __construct

 /**
  * __construct
  *
  * @param string $filename = null
  * @return void
  */
 public function __construct($filename = null)
 {
     if (is_string($filename)) {
         parent::__construct($filename);
     }
     $this->setQuality(Config::inst()->get('ImagickBackend', 'default_quality'));
 }
开发者ID:8secs,项目名称:cocina,代码行数:13,代码来源:ImagickBackend.php

示例11: __construct

    /**
     * Constructor.
     *
     * @param Controller $controller
     * @param string $name method on the $controller
     * @param FieldList $fields
     * @param FieldList $actions
     * @param bool $checkCurrentUser - show logout button if logged in
     */
    public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
    {
        parent::__construct($controller, $name, $fields, $actions, $checkCurrentUser);
        // will be used to get correct Link()
        $this->ldapSecController = Injector::inst()->create('LDAPSecurityController');
        $usernameField = new TextField('Username', _t('Member.USERNAME', 'Username'), null, null, $this);
        $this->Fields()->replaceField('Email', $usernameField);
        $this->setValidator(new RequiredFields('Username', 'Password'));
        if (Security::config()->remember_username) {
            $usernameField->setValue(Session::get('SessionForms.MemberLoginForm.Email'));
        } else {
            // Some browsers won't respect this attribute unless it's added to the form
            $this->setAttribute('autocomplete', 'off');
            $usernameField->setAttribute('autocomplete', 'off');
        }
        // Users can't change passwords unless appropriate a LDAP user with write permissions is
        // configured the LDAP connection binding
        $this->Actions()->remove($this->Actions()->fieldByName('forgotPassword'));
        $allowPasswordChange = Config::inst()->get('LDAPService', 'allow_password_change');
        if ($allowPasswordChange && $name != 'LostPasswordForm' && !Member::currentUser()) {
            $forgotPasswordLink = sprintf('<p id="ForgotPassword"><a href="%s">%s</a></p>', $this->ldapSecController->Link('lostpassword'), _t('Member.BUTTONLOSTPASSWORD', "I've lost my password"));
            $forgotPassword = new LiteralField('forgotPassword', $forgotPasswordLink);
            $this->Actions()->add($forgotPassword);
        }
        // Focus on the Username field when the page is loaded
        Requirements::block('MemberLoginFormFieldFocus');
        $js = <<<JS
\t\t\t(function() {
\t\t\t\tvar el = document.getElementById("Username");
\t\t\t\tif(el && el.focus && (typeof jQuery == 'undefined' || jQuery(el).is(':visible'))) el.focus();
\t\t\t})();
JS;
        Requirements::customScript($js, 'LDAPLoginFormFieldFocus');
    }
开发者ID:andrewandante,项目名称:silverstripe-activedirectory,代码行数:43,代码来源:LDAPLoginForm.php

示例12: requireTable

 /**
  * Allows for hooking in to modify the table of the snippet class for the search engine
  */
 public static function requireTable()
 {
     //Add fulltext searchable extension
     Snippet::add_extension("FulltextSearchable('Title,Description,Tags')");
     //Change to MyISAM for the engine for snippet tables
     Config::inst()->update('Snippet', 'create_table_options', array('MySQLDatabase' => 'ENGINE=MyISAM'));
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:10,代码来源:DefaultCodeBankSearchEngine.php

示例13: testNice

 public function testNice()
 {
     $time = DBField::create_field('Time', '17:15:55');
     $this->assertEquals('5:15pm', $time->Nice());
     Config::inst()->update('Time', 'nice_format', 'H:i:s');
     $this->assertEquals('17:15:55', $time->Nice());
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:7,代码来源:TimeTest.php

示例14: GlobalNav

 /**
  * @param   $key The nav key, e.g. "doc", "userhelp"
  * @return HTMLText
  */
 public static function GlobalNav($key)
 {
     $baseURL = GlobalNavSiteTreeExtension::get_toolbar_baseurl();
     Requirements::css(Controller::join_links($baseURL, Config::inst()->get('GlobalNav', 'css_path')));
     // If this method haven't been called before, get the toolbar and cache it
     if (self::$global_nav_html === null) {
         // Set the default to empty
         self::$global_nav_html = '';
         // Prevent recursion from happening
         if (empty($_GET['globaltoolbar'])) {
             $host = GlobalNavSiteTreeExtension::get_toolbar_hostname();
             $path = Director::makeRelative(GlobalNavSiteTreeExtension::get_navbar_filename($key));
             if (Config::inst()->get('GlobalNav', 'use_localhost')) {
                 self::$global_nav_html = file_get_contents(BASE_PATH . $path);
             } else {
                 $url = Controller::join_links($baseURL, $path, '?globaltoolbar=true');
                 $connectionTimeout = Config::inst()->get('GlobalNavTemplateProvider', 'connection_timeout');
                 $transferTimeout = Config::inst()->get('GlobalNavTemplateProvider', 'transfer_timeout');
                 // Get the HTML and cache it
                 self::$global_nav_html = self::curl_call($url, $connectionTimeout, $transferTimeout);
             }
         }
     }
     $html = DBField::create_field('HTMLText', self::$global_nav_html);
     $html->setOptions(array('shortcodes' => false));
     return $html;
 }
开发者ID:newleeland,项目名称:silverstripe-globaltoolbar,代码行数:31,代码来源:GlobalNavTemplateProvider.php

示例15: filter_backtrace

 /**
  * Filter a backtrace so that it doesn't show the calls to the
  * debugging system, which is useless information.
  *
  * @param array $bt Backtrace to filter
  * @param null|array $ignoredFunctions List of extra functions to filter out
  * @return array
  */
 public static function filter_backtrace($bt, $ignoredFunctions = null)
 {
     $defaultIgnoredFunctions = array('SS_Log::log', 'SS_Backtrace::backtrace', 'SS_Backtrace::filtered_backtrace', 'Zend_Log_Writer_Abstract->write', 'Zend_Log->log', 'Zend_Log->__call', 'Zend_Log->err', 'DebugView->writeTrace', 'CliDebugView->writeTrace', 'Debug::emailError', 'Debug::warningHandler', 'Debug::noticeHandler', 'Debug::fatalHandler', 'errorHandler', 'Debug::showError', 'Debug::backtrace', 'exceptionHandler');
     if ($ignoredFunctions) {
         foreach ($ignoredFunctions as $ignoredFunction) {
             $defaultIgnoredFunctions[] = $ignoredFunction;
         }
     }
     while ($bt && in_array(self::full_func_name($bt[0]), $defaultIgnoredFunctions)) {
         array_shift($bt);
     }
     $ignoredArgs = Config::inst()->get('SS_Backtrace', 'ignore_function_args');
     // Filter out arguments
     foreach ($bt as $i => $frame) {
         $match = false;
         if (!empty($bt[$i]['class'])) {
             foreach ($ignoredArgs as $fnSpec) {
                 if (is_array($fnSpec) && $bt[$i]['class'] == $fnSpec[0] && $bt[$i]['function'] == $fnSpec[1]) {
                     $match = true;
                 }
             }
         } else {
             if (in_array($bt[$i]['function'], $ignoredArgs)) {
                 $match = true;
             }
         }
         if ($match) {
             foreach ($bt[$i]['args'] as $j => $arg) {
                 $bt[$i]['args'][$j] = '<filtered>';
             }
         }
     }
     return $bt;
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:42,代码来源:Backtrace.php


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