當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Config::toArray方法代碼示例

本文整理匯總了PHP中Zend_Config::toArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Config::toArray方法的具體用法?PHP Zend_Config::toArray怎麽用?PHP Zend_Config::toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Config的用法示例。


在下文中一共展示了Zend_Config::toArray方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _initConfig

 /**
  * Combine the static info found in application.ini with the
  * dynamic info found in the Info table.
  *
  * @return void
  */
 protected function _initConfig()
 {
     $this->bootstrap('db');
     $this->bootstrap('locale');
     if (!class_exists('Model_Info')) {
         return;
     }
     try {
         $staticConfig = Zend_Registry::get('config');
         $infoModel = $this->_getInfoModel();
         $dynamicConfig = $infoModel->fetchAsConfig(null, APPLICATION_ENV);
         // Very sneakily bypass 'readOnly'
         if ($staticConfig->readOnly()) {
             $staticConfig = new Zend_Config($staticConfig->toArray(), APPLICATION_ENV, true);
         }
         $staticConfig->merge($dynamicConfig);
         $staticConfig->setReadOnly();
         Zend_Registry::set('config', $staticConfig);
     } catch (Exception $e) {
         $msg = $e->getMessage();
         if (strpos($msg, 'Unknown database') === false && strpos($msg, "doesn't exist") === false) {
             throw $e;
         }
     }
 }
開發者ID:grrr-amsterdam,項目名稱:garp3,代碼行數:31,代碼來源:Bootstrap.php

示例2: _initConfig

 /**
  * Инициализация конфигурации
  */
 protected function _initConfig()
 {
     $path = APPLICATION_PATH . '/../library/Zkernel/Application/configs';
     $config = new Zend_Config(array(), true);
     $it = new DirectoryIterator($path);
     foreach ($it as $file) {
         if ($file->isFile()) {
             $fullpath = $path . '/' . $file;
             switch (substr(trim(strtolower($fullpath)), -3)) {
                 case 'ini':
                     $cfg = new Zend_Config_Ini($fullpath, $this->getEnvironment());
                     break;
                 case 'xml':
                     $cfg = new Zend_Config_Xml($fullpath, $this->getEnvironment());
                     break;
                 default:
                     throw new Zend_Config_Exception('Invalid format for config file');
                     break;
             }
             $config->merge($cfg);
         }
     }
     $config->merge(new Zend_Config($this->getOptions()));
     $this->setOptions($config->toArray());
 }
開發者ID:s-kalaus,項目名稱:zkernel,代碼行數:28,代碼來源:Bootstrap.php

示例3: config

 /**
  * @param array $config
  */
 public function config($config = [])
 {
     $settings = null;
     // check for an initial configuration template
     // used eg. by the demo installer
     $configTemplatePath = PIMCORE_CONFIGURATION_DIRECTORY . "/system.template.php";
     if (file_exists($configTemplatePath)) {
         try {
             $configTemplate = new \Zend_Config(include $configTemplatePath);
             if ($configTemplate->general) {
                 // check if the template contains a valid configuration
                 $settings = $configTemplate->toArray();
                 // unset database configuration
                 unset($settings["database"]["params"]["host"]);
                 unset($settings["database"]["params"]["port"]);
             }
         } catch (\Exception $e) {
         }
     }
     // set default configuration if no template is present
     if (!$settings) {
         // write configuration file
         $settings = ["general" => ["timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "debugloglevel" => "debug", "custom_php_logfile" => "1", "extjs6" => "1"], "database" => ["adapter" => "Mysqli", "params" => ["username" => "root", "password" => "", "dbname" => ""]], "documents" => ["versions" => ["steps" => "10"], "default_controller" => "default", "default_action" => "default", "error_pages" => ["default" => "/"], "createredirectwhenmoved" => "", "allowtrailingslash" => "no", "generatepreview" => "1"], "objects" => ["versions" => ["steps" => "10"]], "assets" => ["versions" => ["steps" => "10"]], "services" => [], "cache" => ["excludeCookie" => ""], "httpclient" => ["adapter" => "Zend_Http_Client_Adapter_Socket"]];
     }
     $settings = array_replace_recursive($settings, $config);
     // create initial /website/var folder structure
     // @TODO: should use values out of startup.php (Constants)
     $varFolders = ["areas", "assets", "backup", "cache", "classes", "config", "email", "log", "plugins", "recyclebin", "search", "system", "tmp", "versions", "webdav"];
     foreach ($varFolders as $folder) {
         \Pimcore\File::mkdir(PIMCORE_WEBSITE_VAR . "/" . $folder);
     }
     $configFile = \Pimcore\Config::locateConfigFile("system.php");
     File::putPhpFile($configFile, to_php_data_file_format($settings));
 }
開發者ID:pimcore,項目名稱:pimcore,代碼行數:37,代碼來源:Setup.php

示例4: getTransport

    /**
     * Get transport
     *
     * @param Zend_Config $config
     * @return Zend_Mail_Transport_Sendmail
     */
    public static function getTransport(Zend_Config $config = null)
    {
        $host        = isset($config->host) ? $config->get('host') : null;
        $otherConfig = ($config instanceof Zend_Config) ? $config->toArray() : null;

        return new Zend_Mail_Transport_Smtp($host, $otherConfig);
    }
開發者ID:BGCX262,項目名稱:zym-svn-to-git,代碼行數:13,代碼來源:Smtp.php

示例5: testSetOptionsSkipsCallsToSetOptionsAndSetConfig

 public function testSetOptionsSkipsCallsToSetOptionsAndSetConfig()
 {
     $options = $this->getOptions();
     $config = new Zend_Config($options);
     $options['config'] = $config;
     $options['options'] = $config->toArray();
     $this->form->setOptions($options);
 }
開發者ID:lortnus,項目名稱:zf1,代碼行數:8,代碼來源:FormTest.php

示例6: __construct

 /**
  * Sets filter options
  *
  * @param  string|array|Zend_Config $options
  * @return void
  */
 public function __construct($options = null)
 {
     if ($options instanceof Zend_Config) {
         $this->_options = $options->toArray();
     } else {
         $this->_options = (array) $options;
     }
 }
開發者ID:slkxmail,項目名稱:App,代碼行數:14,代碼來源:Url.php

示例7: createFromConfig

 public static function createFromConfig(Zend_Config $config)
 {
     if (!isset($config->host) || $config->host == '') {
         throw new EngineBlock_Exception('No Grouper Host specified! Please set "grouper.host" in your application configuration.');
     }
     $url = $config->protocol . '://' . $config->user . ':' . $config->password . '@' . $config->host . (isset($config->port) ? ':' . $config->port : '') . $config->path . '/' . $config->version . '/';
     $grouper = new self($url, $config->toArray());
     return $grouper;
 }
開發者ID:newlongwhitecloudy,項目名稱:OpenConext-engineblock,代碼行數:9,代碼來源:Rest.php

示例8: fromZendConfig

 /**
  * 
  * Creates a new test configuration from Zend_Config
  */
 public static function fromZendConfig(Zend_Config $config)
 {
     $newConfig = new KalturaTestConfig();
     $dataArray = $config->toArray();
     foreach ($dataArray as $key => $value) {
         $newConfig->{$key} = $value;
     }
     return $newConfig;
 }
開發者ID:EfncoPlugins,項目名稱:Media-Management-based-on-Kaltura,代碼行數:13,代碼來源:KalturaTestConfig.php

示例9: getPlugin

 /**
  * Return errorHandler
  *
  * @param  Zend_Config $config
  * @return Zym_Controller_Plugin_ErrorHandler
  */
 public function getPlugin(Zend_Config $config = null)
 {
     if ($config instanceof Zend_Config) {
         $options = $config->toArray();
     } else {
         $options = array();
     }
     $plugin = new Zym_Controller_Plugin_ErrorHandler($options);
     return $plugin;
 }
開發者ID:BGCX262,項目名稱:zym-svn-to-git,代碼行數:16,代碼來源:ErrorHandler.php

示例10: getXmlForConfig

 /**
  * Returns a SimpleXMLElement for the given config.
  * 
  * @see    Zend_Build_Resource_Interface
  * @param  Zend_Build_Resource_Interface Resource to convert to XML
  * @return string String in valid XML 1.0 format
  */
 public static function getXmlForConfig(Zend_Config $config)
 {
     // First create the empty XML element
     $xml = self::_arrayToXml($config->toArray(), new SimpleXMLElement('<' . self::CONFIG_XML_ROOT_ELEMENT . '/>'), true);
     // Format output for readable XML and save to $filename
     $dom = new DomDocument('1.0');
     $domnode = dom_import_simplexml($xml);
     $domnode = $dom->importNode($domnode, true);
     $domnode = $dom->appendChild($domnode);
     $dom->formatOutput = true;
     return $dom->saveXML();
 }
開發者ID:jon9872,項目名稱:zend-framework,代碼行數:19,代碼來源:ConfigXmlWriter.php

示例11: _handleConfig

 /**
  * Modify config for Zend_Layout
  *
  * @param Zend_Config $config
  * @return array
  */
 protected function _handleConfig(Zend_Config $config)
 {
     // Remove null items
     $inflectedConfig = $config->toArray();
     foreach ($inflectedConfig as $index => $var) {
         if (null === $var) {
             unset($inflectedConfig[$index]);
         }
     }
     // Change underscore items to camelcased
     $inflectedConfig = array_flip($inflectedConfig);
     $inflectedConfig = array_flip(array_map(array($this, '_inflectConfig'), $inflectedConfig));
     return $inflectedConfig;
 }
開發者ID:BGCX262,項目名稱:zym-svn-to-git,代碼行數:20,代碼來源:Layout.php

示例12: init

 /**
  * Init observers 
  *
  * @param Evil_Config $events
  * @param null $object
  * @return void
  */
 public function init(Evil_Config $events, $object = null)
 {
     foreach ($events->observers as $name => $body) {
         foreach ($body as $handler) {
             /// соединяем настройки по умолчанию с настройками текущего handler, в т.ч. src
             /// т.к. Zend_Config v1.11.4 не умеет рекурсивно мержить конфиги
             $handler = new Zend_Config(array_merge_recursive($events->handler->toArray(), $handler->toArray()));
             //                print_r($events->handler->toArray());
             //                print_r($handler->toArray());
             $this->addHandler(new Evil_Event_Slot($name, $handler, $object));
         }
     }
     //        var_dump($this->_handlers);
 }
開發者ID:nurikk,項目名稱:EvilRocketFramework,代碼行數:21,代碼來源:Observer.php

示例13: _initConfig

 public function _initConfig()
 {
     $config = new Zend_Config($this->getOptions(), true);
     $inifiles = array('app', 'cache', 'private');
     //TODO: only load cache.ini for models
     foreach ($inifiles as $file) {
         $inifile = APPLICATION_PATH . "/configs/{$file}.ini";
         if (is_readable($inifile)) {
             $config->merge(new Zend_Config_Ini($inifile));
         }
     }
     $config->setReadOnly();
     $this->setOptions($config->toArray());
     Zend_Registry::set('config', $config);
     define('DATE_DB', 'Y-m-d H:i:s');
 }
開發者ID:josmel,項目名稱:DevelEntretenimientoEntel,代碼行數:16,代碼來源:Bootstrap.php

示例14: testDefaultBehaviour

 public function testDefaultBehaviour()
 {
     $config = new Zend_Config($this->data, false, false);
     $this->assertEquals('1.2', $config->float);
     $this->assertEquals('1200', $config->integer);
     $this->assertEquals('0124', $config->pseudo_int);
     $this->assertEquals('foobar', $config->string);
     $this->assertEquals('true', $config->bool_true);
     $this->assertEquals('false', $config->bool_false);
     $array = $config->toArray();
     $this->assertEquals('1.2', $array['float']);
     $this->assertEquals('1200', $array['integer']);
     $this->assertEquals('0124', $array['pseudo_int']);
     $this->assertEquals('foobar', $array['string']);
     $this->assertEquals('true', $array['bool_true']);
     $this->assertEquals('false', $array['bool_false']);
 }
開發者ID:Tony133,項目名稱:zf-web,代碼行數:17,代碼來源:ConfigTest.php

示例15: _initBar

 protected function _initBar()
 {
     require_once 'Zend/Loader/Autoloader.php';
     $loader = Zend_Loader_Autoloader::getInstance();
     $loader->registerNamespace('Api_');
     $loader->registerNamespace(array('Api_'));
     $router = $this->setRouter();
     // Создание объекта front контроллера
     $front = Zend_Controller_Front::getInstance();
     // Настройка front контроллера, указание базового URL, правил маршрутизации
     $front->setRouter($router);
     $registry = Zend_Registry::getInstance();
     $registry->constants = new Zend_Config($this->getApplication()->getOption('constants'));
     //настройки почты
     $mail_const = new Zend_Config($this->getApplication()->getOption('mail'));
     $tr = new Zend_Mail_Transport_Smtp($mail_const->host, $mail_const->toArray());
     Zend_Mail::setDefaultTransport($tr);
 }
開發者ID:dyeshmuk,項目名稱:auto,代碼行數:18,代碼來源:Bootstrap.php


注:本文中的Zend_Config::toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。