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


PHP Container::clear方法代码示例

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


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

示例1: loadLanguageSettings

 /**
  * Load language settings
  *
  * @access public
  * @param void
  * @throws DirDnxError If language dir does not exists
  * @throws FileDnxError If language settings file for this local settings
  *   does not exists in lanuage dir
  */
 private function loadLanguageSettings()
 {
     // Check dir...
     if (!is_dir($this->getLanguageDirPath())) {
         throw new DirDnxError($this->getLanguageDirPath());
     }
     // if
     // Get settings file path and include it
     $settings_file = $this->getLanguageDirPath() . '/' . $this->getLocale() . '.php';
     if (is_file($settings_file)) {
         include $settings_file;
     } else {
         throw new FileDnxError($settings_file, "Failed to find language settings file. Expected location: '{$settings_file}'.");
     }
     // if
     // Clear langs
     $this->langs->clear();
     // Get langs dir
     $langs_dir = $this->getLanguageDirPath() . '/' . $this->getLocale();
     if (is_dir($langs_dir)) {
         $files = get_files($langs_dir, 'php');
         // Loop through files and add langs
         if (is_array($files)) {
             sort($files);
             foreach ($files as $file) {
                 $langs = (include $file);
                 if (is_array($langs)) {
                     $this->langs->append($langs);
                 }
             }
             // foreach
         }
         // if
         //Load plugin langs after fengoffice default langs
         $plugins_dir = $langs_dir . '/plugins';
         if (is_dir($plugins_dir)) {
             sort($files);
             $files = get_files($plugins_dir, 'php');
             // Loop through files and add langs
             if (is_array($files)) {
                 foreach ($files as $file) {
                     $langs = (include $file);
                     if (is_array($langs)) {
                         $this->langs->append($langs);
                     }
                 }
                 // foreach
             }
             // if
         }
         // if
     } else {
         throw new DirDnxError($langs_dir);
     }
     // if
     // Done!
     return true;
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:67,代码来源:Localization.class.php

示例2: loadLanguageSettings

 /**
  * Load language settings
  *
  * @param void
  * @throws DirDnxError If language dir does not exists
  * @throws FileDnxError If language settings file for this local settings
  *   does not exists in lanuage dir
  */
 private function loadLanguageSettings()
 {
     trace(__FILE__, 'loadLanguageSettings()');
     // Check dir...
     $language_dir = $this->getLanguageDirPath();
     if (!is_dir($language_dir)) {
         throw new DirDnxError($language_dir);
     }
     // if
     $locale = $this->getLocale();
     $locale_dir = $language_dir . '/' . $locale;
     if (!is_dir($locale_dir)) {
         throw new DirDnxError($locale_dir);
     }
     // if
     // Get settings file path and include it
     $settings_file = $locale_dir . '/' . $locale . '.php';
     if (!is_file($settings_file)) {
         trace(__FILE__, 'loadLanguageSettings()');
         throw new FileDnxError($settings_file, "Failed to find language settings file" . $settings_file);
     }
     trace(__FILE__, 'loadLanguageSettings():include_once ' . $settings_file);
     include_once $settings_file;
     // Clear langs
     $this->langs->clear();
     // Load core language files
     $this->loadLanguageFiles($locale_dir);
     // load every plugin language files
     $dirs = get_dirs(PLUGINS_DIR, false);
     foreach ($dirs as $plugin_dir) {
         if (plugin_active($plugin_dir)) {
             // plugin_dir is same as plugin name
             $locale_dir = PLUGINS_DIR . '/' . $plugin_dir . '/language/' . $locale;
             if (is_dir($locale_dir)) {
                 $this->loadLanguageFiles($locale_dir);
             } else {
                 //$locale_dir = PLUGINS_DIR.'/'.$plugin_dir.'/language/en_us';
                 if (is_dir($locale_dir)) {
                     $this->loadLanguageFiles($locale_dir);
                 }
                 // if
             }
             // if
         }
         // if
     }
     // foreach
     // Done!
     return true;
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:58,代码来源:Localization.class.php

示例3: Container

<?php

error_reporting(E_ALL | E_STRICT);
require_once '../anewt.lib.php';
/* Test constructor */
$c = new Container(array('foo' => 'bar'));
assert('$c->get("foo") === "bar"');
/* Test clear() */
$c = new Container();
$c->set('foo', 'foo_value');
$c->set('bar', 'bar_value');
$c->clear();
/* Test custom getters and setters */
class TestContainer extends Container
{
    function get_foo()
    {
        return 'foo_value';
    }
    function get_baz($param = 'default')
    {
        return 'baz_value_' . $param;
    }
}
$test = new TestContainer();
$test->set('bar', 'bar_value');
/* Test keys() */
$keys = $test->keys();
assert('array_has_value($keys, "bar") === true');
assert('array_has_value($keys, "foo") === true');
assert('array_has_value($keys, "baz") === true');
开发者ID:jijkoun,项目名称:ssscrape,代码行数:31,代码来源:container.test.php

示例4: loadLanguageSettings

 /**
  * Load language settings
  *
  * @access public
  * @param void
  * @throws DirDnxError If language dir does not exists
  * @throws FileDnxError If language settings file for this local settings
  * does not exists in lanuage dir
  */
 private function loadLanguageSettings()
 {
     // Check dir...
     if (!is_dir($this->getLanguageDirPath())) {
         throw new DirDnxError($this->getLanguageDirPath());
     }
     // if
     // Get settings file path and include it
     $settings_file = $this->getLanguageDirPath() . '/' . $this->getLocale() . '.php';
     if (is_file($settings_file)) {
         include $settings_file;
     } else {
         $base_settings = $this->getLanguageDirPath() . '/default.php';
         if (is_file($base_settings)) {
             include $base_settings;
         } else {
             throw new FileDnxError($settings_file, "Failed to find language settings file. Expected location: '{$settings_file}'.");
         }
     }
     // Clear langs
     $this->langs->clear();
     // Get langs dir - ONLY PHP langs !
     $langs_dir = $this->getLanguageDirPath() . '/' . $this->getLocale();
     if (is_dir($langs_dir)) {
         $files = get_files($langs_dir, 'php');
         // Loop through files and add langs
         if (is_array($files)) {
             sort($files);
             foreach ($files as $file) {
                 $langs = (include $file);
                 if (is_array($langs)) {
                     $this->langs->append($langs);
                 }
             }
         }
         // Plugins - Only PHP langs - include all installed plugins, no matter if they they have not been activated
         $plugins = Plugins::instance()->getAll();
         foreach ($plugins as $plugin) {
             /* @var $plugin Plugin */
             $plg_dir = $plugin->getLanguagePath() . "/" . $this->getLocale();
             if (is_dir($plg_dir)) {
                 $files = get_files($plg_dir, 'php');
                 // Loop through files and add langs
                 if (is_array($files)) {
                     sort($files);
                     foreach ($files as $file) {
                         $langs = (include $file);
                         if (is_array($langs)) {
                             $this->langs->append($langs);
                         }
                     }
                 }
             }
         }
     } else {
         throw new DirDnxError($langs_dir);
     }
     // if
     // Done!
     return true;
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:70,代码来源:Localization.class.php


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