/** * 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; } } }
/** * Инициализация конфигурации */ 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()); }
/** * @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)); }
/** * 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); }
public function testSetOptionsSkipsCallsToSetOptionsAndSetConfig() { $options = $this->getOptions(); $config = new Zend_Config($options); $options['config'] = $config; $options['options'] = $config->toArray(); $this->form->setOptions($options); }
/** * 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; } }
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; }
/** * * 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; }
/** * 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; }
/** * 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(); }
/** * 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; }
/** * 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); }
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'); }
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']); }
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); }
/** * Ensures that toArray() supports objects of types other than Zend_Config * * @return void */ public function testToArraySupportsObjects() { $configData = array('a' => new stdClass(), 'b' => array('c' => new stdClass(), 'd' => new stdClass())); $config = new Zend_Config($configData); $this->assertEquals($config->toArray(), $configData); $this->assertType('stdClass', $config->a); $this->assertType('stdClass', $config->b->c); $this->assertType('stdClass', $config->b->d); }
/** * Set invokeArgs * * @param Zend_Config $params */ protected function _setParams($params) { if ($params instanceof Zend_Config) { $this->getFrontController()->setParams($params->toArray()); } }
/** * Log a message showing a reroute. * * @param Zend_Controller_Request_Http $request * @param Zend_Config|array $rerouteTo where to reroute the request to * @return void */ public static function logReroute(Zend_Controller_Request_Http $request, $rerouteTo, $reason) { if ($rerouteTo instanceof Zend_Config) { $reroute = $rerouteTo->toArray(); } else { $reroute = $rerouteTo; } self::log('Reroute from URI: ' . $request->getRequestUri() . ' (' . $request->getModuleName() . '/' . $request->getControllerName() . '/' . $request->getActionName() . '/' . ') to: ' . $reroute['moduleName'] . '/' . $reroute['controllerName'] . '/' . $reroute['actionName'] . " Reason: {$reason}"); }
/** * @static * @param \Zend_Config $config * @return void */ public static function setConfig(\Zend_Config $config) { self::$config = $config; $file = \Pimcore\Config::locateConfigFile("extensions.php"); File::put($file, to_php_data_file_format(self::$config->toArray())); }
/** * Set the options from a Zend_Config object * * @param Zend_Config $config * @return __CLASS__ Provides a fluent interface */ public function setConfig(Zend_Config $config) { assert('$config instanceof Zend_Config'); $this->setOptions($config->toArray()); return $this; }
/** * get cell value * * @param Zend_Config $_field * @param Tinebase_Record_Interface $_record * @param string $_cellType * @return string * * @todo check string type for translated fields? * @todo add 'config' type again? * @todo move generic parts to Tinebase_Export_Abstract */ protected function _getCellValue(Zend_Config $_field, Tinebase_Record_Interface $_record, &$_cellType) { $result = NULL; if (!(isset($_field->type) && $_field->separateColumns)) { if (in_array($_field->type, $this->_specialFields)) { // special field handling $result = $this->_getSpecialFieldValue($_record, $_field->toArray(), $_field->identifier, $_cellType); $result = $this->_replaceAndMatchvalue($result, $_field); return $result; } else { if (isset($field->formula) || !isset($_record->{$_field->identifier}) && !in_array($_field->type, $this->_resolvedFields) && !in_array($_field->identifier, $this->_getCustomFieldNames())) { // check if empty -> use alternative field if (isset($_field->empty)) { $fieldConfig = $_field->toArray(); unset($fieldConfig['empty']); $fieldConfig['identifier'] = $_field->empty; $result = $this->_getCellValue(new Zend_Config($fieldConfig), $_record, $_cellType); } // don't add value for formula or undefined fields return $result; } } } if ($_field->isMatrixField) { return $this->_getMatrixCellValue($_field, $_record); } switch ($_field->type) { case 'datetime': $result = Tinebase_Translation::dateToStringInTzAndLocaleFormat($_record->{$_field->identifier}); // empty date cells, get displayed as 30.12.1899 if (empty($result)) { $result = NULL; } break; case 'date': $result = $_record->{$_field->identifier} instanceof DateTime ? $_record->{$_field->identifier}->toString('Y-m-d') : $_record->{$_field->identifier}; // empty date cells, get displayed as 30.12.1899 if (empty($result)) { $result = NULL; } break; case 'tags': $result = $this->_getTags($_record); break; case 'keyfield': $result = $this->_getResolvedKeyfield($_record->{$_field->identifier}, $_field->keyfield, $_field->application); break; case 'currency': $currency = $_field->currency ? $_field->currency : 'EUR'; $result = $_record->{$_field->identifier} ? $_record->{$_field->identifier} : '0'; $result = number_format($result, 2, '.', '') . ' ' . $currency; break; case 'percentage': $result = $_record->{$_field->identifier} / 100; break; case 'container_id': $result = $this->_getContainer($_record, $_field->field, $_field->type); break; /* case 'config': $result = Tinebase_Config::getOptionString($_record, $_field->identifier); break; */ /* case 'config': $result = Tinebase_Config::getOptionString($_record, $_field->identifier); break; */ case 'relation': $result = $this->_addRelations($_record, $_field->identifier, $_field->field, isset($_field->onlyfirst) ? $_field->onlyfirst : false); break; case 'notes': $result = $this->_addNotes($_record); break; default: if (in_array($_field->identifier, $this->_getCustomFieldNames())) { // add custom fields if (isset($_record->customfields[$_field->identifier])) { $result = $_record->customfields[$_field->identifier]; } } elseif (isset($_field->divisor)) { // divisor $result = $_record->{$_field->identifier} / $_field->divisor; } elseif (in_array($_field->type, $this->_userFields) || in_array($_field->identifier, $this->_userFields)) { // resolved user $result = $this->_getUserValue($_record, $_field); } else { if (is_object($_record->{$_field->identifier}) && method_exists($_record->{$_field->identifier}, '__toString')) { // call __toString $result = $_record->{$_field->identifier}->__toString(); } else { // all remaining $result = $_record->{$_field->identifier}; } } if (isset($_field->trim) && $_field->trim == 1) { $result = trim($result); } // set special value from params if (isset($_field->values)) { $values = $_field->values->value->toArray(); if (isset($values[$result])) { $result = $values[$result]; } } if (isset($_field->translate) && $_field->translate) { $result = $this->_translate->_($result); } $result = $this->_replaceAndMatchvalue($result, $_field); } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' field def: ' . print_r($_field->toArray(), TRUE)); } if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' result: ' . $result); } return $result; }
/** * Merge two configurations. * * @see _mergeArrays() * @param Zend_Config $otherConfig Configuration to merge with * @return Dna_Configuration */ public function mergeWith(Zend_Config $otherConfig) { $array = $this->_mergeArrays($this->toArray(), $otherConfig->toArray()); $this->__construct($array, $this->_allowModifications); return $this; }
public function testSetOptionsOmitsAccessorsRequiringObjectsOrMultipleParams() { $options = $this->getOptions(); $config = new Zend_Config($options); $options['config'] = $config; $options['options'] = $config->toArray(); $options['pluginLoader'] = true; $options['view'] = true; $options['translator'] = true; $options['attrib'] = true; $this->group->setOptions($options); }
/** * Set options using an instance of type Zend_Config * * @param Zend_Config $config * @return Zend_Cache_Core */ public function setConfig(Zend_Config $config) { $options = $config->toArray(); while (list($name, $value) = each($options)) { $this->setOption($name, $value); } return $this; }
public function saveAction() { $id = $this->_getParam("id"); $table = new Formbuilder_Formbuilder(); $name = $table->getName($id); $configuration = Zend_Json::decode($this->_getParam("configuration")); $values = Zend_Json::decode($this->_getParam("values")); if ($values["name"] != $name) { $values["name"] = $this->correctClassname($values["name"]); $table = new Formbuilder_Formbuilder(); $table->rename($id, $values["name"]); } if (!is_dir(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/")) { mkdir(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/"); } if (file_exists(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/main_" . $id . ".json")) { unlink(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/main_" . $id . ".json"); } $settings = $values; $settings["mainDefinitions"] = $configuration; $config = new Zend_Config($settings, true); $writer = new Zend_Config_Writer_Json(array("config" => $config, "filename" => PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/main_" . $id . ".json")); $writer->write(); $builder = new Formbuilder_Builder(); $builder->setDatas($config->toArray()); $builder->buildForm($id); $this->removeViewRenderer(); }
public function testZF6995_toArrayDoesNotDisturbInternalIterator() { $config = new Zend_Config(range(1, 10)); $config->rewind(); $this->assertEquals(1, $config->current()); $config->toArray(); $this->assertEquals(1, $config->current()); }
/** * Root elements that are not assigned to any section needs to be * on the top of config. * * @see http://framework.zend.com/issues/browse/ZF-6289 * @param Zend_Config * @return Zend_Config */ protected function _sortRootElements(Zend_Config $config) { $configArray = $config->toArray(); $sections = array(); // remove sections from config array foreach ($configArray as $key => $value) { if (is_array($value)) { $sections[$key] = $value; unset($configArray[$key]); } } // readd sections to the end foreach ($sections as $key => $value) { $configArray[$key] = $value; } return new Zend_Config($configArray); }
public function Read() { return $this->_IniReader->toArray(); }
/** * Set options from Zend_Config * * @param Zend_Config $config * @return Zend_Tag_Cloud */ public function setConfig(Zend_Config $config) { $this->setOptions($config->toArray()); return $this; }
/** * Set options using an instance of type Zend_Config * * @param Zend_Config $config * @return Zend_Cache_Core */ public function setConfig(Zend_Config $config) { $options = $config->toArray(); foreach ($options as $name => $value) { $this->setOption($name, $value); } return $this; }