/** * Return search specs * * @param string $filename config file name * * @return array */ public function get($filename) { // Load data if it is not already in the object's cache: if (!isset($this->searchSpecs[$filename])) { // Connect to searchspecs cache: $sm = $this->getServiceLocator(); $cache = is_object($sm) && $sm->has('CacheManager') ? $sm->get('CacheManager')->getCache('searchspecs') : false; // Determine full configuration file path: $fullpath = Reader::getBaseConfigPath($filename); $local = Reader::getLocalConfigPath($filename); // Generate cache key: $key = $filename . '-' . filemtime($fullpath); if (!empty($local)) { $key .= '-local-' . filemtime($local); } $key = md5($key); // Generate data if not found in cache: if (!$cache || !($results = $cache->getItem($key))) { $results = Yaml::load(file_get_contents($fullpath)); if (!empty($local)) { $localResults = Yaml::load(file_get_contents($local)); foreach ($localResults as $key => $value) { $results[$key] = $value; } } if ($cache) { $cache->setItem($key, $results); } } $this->searchSpecs[$filename] = $results; } return $this->searchSpecs[$filename]; }
protected function conditionalInclude($definition, &$value, $key) { $parsed = $this->parse($definition); $yamlFile = $parsed[0]; if (count($parsed) == 1) { $result = true; } else { if (count($parsed) == 2) { $leftValue = $parsed[1]; $operation = 'eq'; $rightValue = $parsed[2]; } else { $leftValue = $parsed[1]; $operation = $parsed[2]; $rightValue = $parsed[3]; } $result = $this->checkCondition($operation, $leftValue, $rightValue); } if ($result) { $yaml = Horde_Yaml::load(file_get_contents($this->props['path'] . '/' . $yamlFile)); if (is_array($yaml) && count($yaml) == 1 && array_key_exists($key, $yaml)) { $value = $yaml[$key]; } else { $value = $yaml; } } return $result; }
public function run() { $options = $this->_config->getOptions(); if (!empty($options['no_tree'])) { print Horde_Yaml::dump($this->_config->getComponent()->getDependencies()); } else { $this->_dependencies->listTree($this->_config->getComponent(), $options); } }
/** * @dataProvider includeDataProvider */ public function testInclude($yamlFile, $yamlResultFile) { $yamlString = file_get_contents($this->fixtures . $yamlFile); $yaml = Horde_Yaml::load($yamlString); $yamlResultString = file_get_contents($this->fixtures . $yamlResultFile); $yamlResult = Horde_Yaml::load($yamlResultString); $this->directives->process($yaml); $this->assertEquals(json_encode($yamlResult), json_encode($yaml)); }
function getData() { if ($this->data) { return $this->data; } $defaults = array('preserve' => 'n', 'guards' => array()); $data = array_merge($defaults, $this->obj->getData()); foreach ($data['guards'] as &$guard) { if (is_string($guard[2])) { $guard[2] = reset(Horde_Yaml::load("- " . $guard[2])); } } $data = Tiki_Profile::convertYesNo($data); return $this->data = $data; }
/** * Load language file * * @param string $language - if left empty loads saved language selection (from cookie) or default language * @return bool success */ function i18n_load_language($language = NULL) { global $i18n_lang, $i18n_current_language; if ($language == NULL) { $language = $_COOKIE["i18n_language"]; if (!$language) { $language = getDefaultLanguage(); } } $i18n_current_language = $language; if ($i18n_lang = Horde_Yaml::loadFile("../languages/{$language}.yaml")) { return true; } else { return false; } }
/** * Pass the error and environment data on to Hoptoad * * @package default * @author Rich Cavanaugh */ public static function notifyHoptoad($api_key, $message, $file, $line, $trace, $error_class = null) { $req =& new HTTP_Request("http://hoptoadapp.com/notices/", array("method" => "POST", "timeout" => 2)); $req->addHeader('Accept', 'text/xml, application/xml'); $req->addHeader('Content-type', 'application/x-yaml'); array_unshift($trace, "{$file}:{$line}"); if (isset($_SESSION)) { $session = array('key' => session_id(), 'data' => $_SESSION); } else { $session = array(); } $url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; $body = array('api_key' => $api_key, 'error_class' => $error_class, 'error_message' => $message, 'backtrace' => $trace, 'request' => array("params" => $_REQUEST, "url" => $url), 'session' => $session, 'environment' => $_SERVER); $req->setBody(Horde_Yaml::dump(array("notice" => $body))); $req->sendRequest(); }
private function _yamlOutput($cli, $id, $output) { $output = $this->_convertDates($output); if (class_exists('Horde_Yaml')) { $this->_messageOutput($cli, $id, Horde_Yaml::dump($output)); } else { $this->_messageOutput($cli, $id, print_r($output, true)); } }
/** * Establishes the connection to the database. Accepts a hash as input where * the :adapter key must be specified with the name of a database adapter (in lower-case) * * Example for regular databases (MySQL, Postgresql, etc): * <code> * Mad_Model_Base::establishConnection(array( * "adapter" => "mysql", * "host" => "localhost", * "username" => "myuser", * "password" => "mypass", * "database" => "somedatabase" * )); * </code> * * Example for SQLite database: * <code> * Mad_Model_Base::establishConnection(array( * "adapter" => "sqlite", * "database" => "path/to/dbfile" * )); * </code> * * The exceptions AdapterNotSpecified, AdapterNotFound and ArgumentError * may be returned on an error. * * @param array $spec * @return Connection */ public static function establishConnection($spec = null) { // $spec is empty: $spec defaults to MAD_ENV string like "development" // keep going to read YAML for this environment string if (empty($spec)) { if (!defined('MAD_ENV') || !MAD_ENV) { throw new Mad_Model_Exception('Adapter Not Specified'); } $spec = MAD_ENV; } // $spec is string: read YAML config for environment named by string // keep going to process the resulting array if (is_string($spec)) { $config = Horde_Yaml::loadFile(MAD_ROOT . '/config/database.yml'); $spec = $config[$spec]; } // $spec is an associative array if (is_array($spec)) { // validation of array is handled by horde_db self::$_connectionSpec = $spec; } else { throw new Mad_Model_Exception("Invalid Connection Specification"); } }
/** * Parse the content of a YAML file into a Horde_Push element. * * @param string $argument A single command line argument (without the scheme argument). * @param array $conf The configuration. * * @return Horde_Push The element to be pushed. */ private function _parseYaml($argument, $conf) { if (!class_exists('Horde_Yaml')) { throw new Horde_Push_Exception('The Horde_Yaml package is missing!'); } if (!file_exists($argument)) { throw new Horde_Push_Exception(sprintf('Invalid file path: "%s"!', $argument)); } return $this->_createFromData(Horde_Yaml::loadFile($argument)); }
$assigned_modules_for_export = $modlib->getModulesForExport(); $smarty->assign('modules_for_export', $assigned_modules_for_export); if (!isset($_REQUEST['export_type'])) { $_REQUEST['export_type'] = 'prefs'; } $smarty->assign('export_type', $_REQUEST['export_type']); if (isset($_REQUEST['export'])) { if ($_REQUEST['export_type'] === 'prefs') { $export_yaml = Horde_Yaml::dump(array('preferences' => $_REQUEST['prefs_to_export']), array('indent' => 1, 'wordwrap' => 0)); } else { if ($_REQUEST['export_type'] === 'modules') { $modules_to_export = array(); foreach ($_REQUEST['modules_to_export'] as $k => $v) { $modules_to_export[] = $assigned_modules_for_export[$k]; } $export_yaml = Horde_Yaml::dump(array('objects' => $modules_to_export), array('indent' => 1, 'wordwrap' => 0)); } else { $export_yaml = ''; // something went wrong? } } $export_yaml = preg_replace('/^---\\n/', '', $export_yaml); $export_yaml = "{CODE(caption=>YAML,wrap=>0)}\n" . $export_yaml . "{CODE}\n"; include_once 'lib/wiki-plugins/wikiplugin_code.php'; $export_yaml = wikiplugin_code($export_yaml, array('caption' => 'Wiki markup', 'colors' => 'tiki'), null, array()); $export_yaml = preg_replace('/~[\\/]?np~/', '', $export_yaml); $smarty->assign('export_yaml', $export_yaml); $smarty->assign('prefs_to_export', $_REQUEST['prefs_to_export']); $smarty->assign('modules_to_export', $_REQUEST['modules_to_export']); } ask_ticket('admin-inc-profiles');
<?php /** * @package Yaml */ require_once dirname(dirname(__DIR__)) . '/Yaml/__autoload.php'; $file = __DIR__ . '/example.yaml'; echo "{$file} loaded into PHP:\n"; var_dump(Horde_Yaml::loadFile($file));
public function parseYaml($yaml, $entity = null) { if (empty($yaml)) { return null; } return Horde_Yaml::load($yaml); }
<?php require_once 'Horde/Autoloader/Default.php'; $g = new Horde_Service_Gravatar(); print Horde_Yaml::dump($g->getProfile('*****@*****.**'));
/** * Given a php structure, returns a valid YAML string representation. * * @param mixed PHP data * @return string YAML equivalent. */ public static function dump($phpData) { if (function_exists('yaml_emit')) { return yaml_emit($phpData); } else { if (function_exists('syck_dump')) { // php-lib-c version, much faster! return syck_dump($phpData); } else { // php version return Horde_Yaml::dump($phpData); } } }
* routes */ // create a request mapper object to regex-match the URI to a Route $request = new Mapper(); // add a new Route $request->connect('static/:staticresource', array('requirements' => array('[A-Za-z0-9_.]+'))); // load static-file-cache and debug aspects //include $GLOBALS['PATH']['plugins'] . 'renderer.php'; // this doesn't do anything because the aspect-filter was deleted XXX //$request->routematch(); $request->connect('admin', array('action' => 'index', 'resource' => 'admin')); /** * read the configuration file */ include $GLOBALS['PATH']['library'] . 'yaml.php'; $loader = new Horde_Yaml(); if (file_exists($app . 'config.yml')) { extract($loader->load(file_get_contents($app . 'config.yml'))); extract(${$env}['enable_db']); } else { $env = array('app_folder' => 'app'); } // if app folder exists, re-config for the app if (is_dir($env['app_folder'])) { $app = $env['app_folder'] . DIRECTORY_SEPARATOR; $appdir = $app; if (file_exists($app . 'config' . DIRECTORY_SEPARATOR . 'config.yml')) { extract($loader->load(file_get_contents($app . 'config' . DIRECTORY_SEPARATOR . 'config.yml'))); extract(${$env}['enable_db']); if (isset($env['boot'])) { $appdir = $app . $env['boot'] . DIRECTORY_SEPARATOR;
function dump() { $clone = clone $this; $clone->clean(); return Horde_Yaml::dump($clone->data); }
/** * Parse the fixture data from the given array. This will * take the yaml file and validate and set the records/options. */ private function _parseYml($ymlName, $fixturesPath) { // only parse if not in cache if (!isset(self::$_ymlCache[$ymlName])) { $fixtureFile = "{$fixturesPath}/{$ymlName}.yml"; // Parse yml file if (!file_exists($fixtureFile)) { throw new Mad_Test_Exception('The fixture file: "' . $fixtureFile . '" does not exist.'); } // dynamic fixtures ob_start(); include "madview://{$fixtureFile}"; $fixtureData = ob_get_clean(); $records = Horde_Yaml::load($fixtureData); // Parse options $options = isset($records['options']) ? $records['options'] : array(); $valid = array('table' => $ymlName, 'log' => null, 'requires' => array(), 'before' => array(), 'after' => array(), 'teardown' => array()); $options = Mad_Support_Base::assertValidKeys($options, $valid); unset($records['options']); self::$_ymlCache[$ymlName] = array('records' => $records, 'options' => $options); } $this->_records = self::$_ymlCache[$ymlName]['records']; $this->_options = self::$_ymlCache[$ymlName]['options']; // Parse required fixtures for this load foreach ($this->_options['requires'] as $required) { $this->_required[] = new Mad_Test_Fixture_Base($this->_connection, $required); } }
function getContent() { $builder = clone $this; foreach (array_keys($this->groups) as $group) { foreach (array_keys($this->groups) as $peer) { if ($group == $this->managingGroup) { $builder->setPermissions($group, 'group', $peer, array('group_view', 'group_view_members', 'group_add_member', 'group_remove_member')); } else { $builder->setPermissions($group, 'group', $peer, array('group_view', 'group_view_members')); } } } $data = array(); if (count($builder->objects)) { $data['objects'] = $builder->objects; } if ($builder->groups) { $data['mappings'] = array(); $data['permissions'] = array(); foreach ($builder->groups as $internal => $full) { $groupDefinition = array('description' => $full); if ($this->autojoin[$internal]) { $groupDefinition['autojoin'] = 'y'; } if (isset($builder->permissions[$internal])) { $groupDefinition['objects'] = $builder->permissions[$internal]['objects']; } $data['mappings'][$internal] = $full; $data['permissions'][$internal] = $groupDefinition; } } $self = $this; array_walk_recursive($data, function (&$entry) use($self) { if (is_string($entry)) { $entry = preg_replace_callback('/\\{(\\w+)\\}/', function ($matches) use($self) { return $self->user($matches[1]); }, $entry); } }); $yaml = Horde_Yaml::dump($data); return <<<SYNTAX ^The following profile was auto-generated. It may hurt your eyes when you try reading it.^ {CODE(caption="YAML")} {$yaml} {CODE} SYNTAX; }
<?php require '../kernel/setup_inc.php'; $foo = Horde_Yaml::loadFile('/home/consulting/live/clients/bw/energymeasures/games.yaml'); vd($foo);
/** * Support method for _getSearchSpecs() -- load the specs from cache or disk. * * @return void * @access private */ private function _loadSearchSpecs() { // Generate cache key: $key = md5(basename($this->searchSpecsFile) . '-' . filemtime($this->searchSpecsFile)); // Load cache manager: $cache = new VuFindCache($this->_specCache, 'searchspecs'); // Generate data if not found in cache: if (!($results = $cache->load($key))) { $results = Horde_Yaml::load(file_get_contents($this->searchSpecsFile)); $cache->save($results, $key); } $this->_searchSpecs = $results; }
/** * Will process the output by serializing in the best way possible based on the request's accept headers. * To output as an RSS/Atom feed, a descriptor may be provided to map the array data to the feed's properties * and to supply additional information. The descriptor must contain the following keys: * [feedTitle] Feed's title, static value * [feedDescription] Feed's description, static value * [entryTitleKey] Key to lookup for each entry to find the title * [entryUrlKey] Key to lookup to find the URL of each entry * [entryModificationKey] Key to lookup to find the modification date * [entryObjectDescriptors] Optional. Array containing two key names, object key and object type to lookup missing information (url and title) */ function output_serialized($data, $feed_descriptor = null) { foreach ($this->get_accept_types(!is_null($feed_descriptor)) as $name => $full) { switch ($name) { case 'json': header("Content-Type: {$full}"); $data = json_encode($data); if ($data === false) { $error = ''; switch (json_last_error()) { case JSON_ERROR_NONE: $error = 'json_encode - No errors'; break; case JSON_ERROR_DEPTH: $error = 'json_encode - Maximum stack depth exceeded'; break; case JSON_ERROR_STATE_MISMATCH: $error = 'json_encode - Underflow or the modes mismatch'; break; case JSON_ERROR_CTRL_CHAR: $error = 'json_encode - Unexpected control character found'; break; case JSON_ERROR_SYNTAX: $error = 'json_encode - Syntax error, malformed JSON'; break; case JSON_ERROR_UTF8: $error = 'json_encode - Malformed UTF-8 characters, possibly incorrectly encoded'; break; default: $error = 'json_encode - Unknown error'; break; } throw new Exception($error); } if (isset($_REQUEST['callback'])) { $data = $_REQUEST['callback'] . '(' . $data . ')'; } echo $data; return; case 'yaml': header("Content-Type: {$full}"); echo Horde_Yaml::dump($data); return; case 'rss': $rsslib = TikiLib::lib('rss'); $writer = $rsslib->generate_feed_from_data($data, $feed_descriptor); $writer->setFeedLink($this->tikiUrl($_SERVER['REQUEST_URI']), 'rss'); header('Content-Type: application/rss+xml'); echo $writer->export('rss'); return; case 'atom': $rsslib = TikiLib::lib('rss'); $writer = $rsslib->generate_feed_from_data($data, $feed_descriptor); $writer->setFeedLink($this->tikiUrl($_SERVER['REQUEST_URI']), 'atom'); header('Content-Type: application/atom+xml'); echo $writer->export('atom'); return; case 'html': header("Content-Type: {$full}"); echo $data; return; } } }
private function loadYaml($content) { $this->pageContent = $content; $pos = 0; $this->data = array(); $matches = WikiParser_PluginMatcher::match($content); $parser = new WikiParser_PluginArgumentParser(); foreach ($matches as $match) { $arguments = $parser->parse($match->getArguments()); if ($match->getName() == 'code' && isset($arguments['caption']) && $arguments['caption'] == 'YAML' || $match->getName() == 'profile') { $yaml = $match->getBody(); $data = Horde_Yaml::load($yaml); foreach ($data as $key => $value) { if (array_key_exists($key, $this->data)) { $this->data[$key] = $this->mergeData($this->data[$key], $value); } else { $this->data[$key] = $value; } } } } $this->fetchExternals(); $this->getObjects(); }
public function testShouldNotWrapStringsWithCommentDelimiterForFoldedStrings() { // stringWithHash: 'string # this is part of the string, not a comment' $value = array('foo' => 'string # this is not a comment but it is a long string that gets folded', 'bar' => 2); $expected = "---\n" . "foo: >\n" . " string # this is not a comment but it is\n" . " a long string that gets folded\n" . "bar: 2\n"; $actual = $this->dumper->dump($value); $this->assertEquals($expected, $actual); // round-trip assert $this->assertEquals($value, Horde_Yaml::load($actual), "Error: expected: " . print_r($value, true) . ", actual: " . print_r(Horde_Yaml::load($actual), true) . ", from: >" . $actual . "<"); // fails presently due to bug in loader which causes an extra "\n" at end of string }
$openSources = 0; foreach ($sources as $key => $source) { if ($source['status'] == 'open') { $openSources++; } } if ($openSources == count($sources)) { $smarty->assign('openSources', 'all'); } elseif ($openSources > 0 && $openSources < count($sources)) { $smarty->assign('openSources', 'some'); } else { $smarty->assign('openSources', 'none'); } $smarty->assign('tikiMajorVersion', substr($TWV->version, 0, 2)); $modified = $prefslib->getModifiedPrefsForExport(!empty($_REQUEST['export_show_added']) ? true : false); $smarty->assign('modified_list', $modified); if (!isset($_REQUEST['export_type'])) { $_REQUEST['export_type'] = 'prefs'; } $smarty->assign('export_type', $_REQUEST['export_type']); if (isset($_REQUEST['export']) && $_REQUEST['export_type'] === 'prefs') { $export_yaml = Horde_Yaml::dump(array('preferences' => $_REQUEST['prefs_to_export']), array('indent' => 1, 'wordwrap' => 0)); $export_yaml = preg_replace('/^---\\n/', '', $export_yaml); $export_yaml = "{CODE(caption=>YAML,wrap=>0)}\n" . $export_yaml . "{CODE}\n"; include_once 'lib/wiki-plugins/wikiplugin_code.php'; $export_yaml = wikiplugin_code($export_yaml, array('caption' => 'Wiki markup', 'colors' => 'tikiwiki')); $export_yaml = preg_replace('/~[\\/]?np~/', '', $export_yaml); $smarty->assign('export_yaml', $export_yaml); $smarty->assign('prefs_to_export', $_REQUEST['prefs_to_export']); } ask_ticket('admin-inc-profiles');
/** * Will process the output by serializing in the best way possible based on the request's accept headers. * To output as an RSS/Atom feed, a descriptor may be provided to map the array data to the feed's properties * and to supply additional information. The descriptor must contain the following keys: * [feedTitle] Feed's title, static value * [feedDescription] Feed's description, static value * [entryTitleKey] Key to lookup for each entry to find the title * [entryUrlKey] Key to lookup to find the URL of each entry * [entryModificationKey] Key to lookup to find the modification date * [entryObjectDescriptors] Optional. Array containing two key names, object key and object type to lookup missing information (url and title) */ function output_serialized($data, $feed_descriptor = null) { foreach ($this->get_accept_types(!is_null($feed_descriptor)) as $name => $full) { switch ($name) { case 'json': header("Content-Type: {$full}"); $data = json_encode($data); if (isset($_REQUEST['callback'])) { $data = $_REQUEST['callback'] . '(' . $data . ')'; } echo $data; return; case 'yaml': header("Content-Type: {$full}"); echo Horde_Yaml::dump($data); return; case 'rss': $rsslib = TikiLib::lib('rss'); $writer = $rsslib->generate_feed_from_data($data, $feed_descriptor); $writer->setFeedLink($this->tikiUrl($_SERVER['REQUEST_URI']), 'rss'); header('Content-Type: application/rss+xml'); echo $writer->export('rss'); return; case 'atom': $rsslib = TikiLib::lib('rss'); $writer = $rsslib->generate_feed_from_data($data, $feed_descriptor); $writer->setFeedLink($this->tikiUrl($_SERVER['REQUEST_URI']), 'atom'); header('Content-Type: application/atom+xml'); echo $writer->export('atom'); return; case 'html': header("Content-Type: {$full}"); echo $data; return; } } }
/** * Run the module. * * @param Horde_Cli $cli The CLI handler. * @param mixed $options An array of options. * @param mixed $arguments An array of arguments. * @param array &$world A list of initialized dependencies. * * @return NULL */ public function run($cli, $options, $arguments, &$world) { if (!isset($arguments[1])) { $action = 'read'; } else { $action = $arguments[1]; } switch ($action) { case 'read': $parser = $world['format']->create('Xml', $arguments[2]); if (empty($arguments[4])) { if (file_exists($arguments[3])) { $contents = file_get_contents($arguments[3]); $data = $parser->load($contents); $id = $arguments[3]; } else { $cli->message(sprintf(Horde_Kolab_Cli_Translation::t('%s is no local file!'), $arguments[3]), 'cli.error'); } } else { $ks_data = $world['storage']->getData($arguments[3]); $part = $ks_data->fetchPart($arguments[4], $arguments[5]); rewind($part); $xml = quoted_printable_decode(stream_get_contents($part)); $data = $parser->load($xml); $id = $arguments[3] . ':' . $arguments[4] . '[' . $arguments[5] . ']'; } if (class_exists('Horde_Yaml')) { $this->_formatOutput($cli, $id, Horde_Yaml::dump($data)); } else { $this->_formatOutput($cli, $id, print_r($data, true)); } break; default: $cli->message(sprintf(Horde_Kolab_Cli_Translation::t('Action %s not supported!'), $action), 'cli.error'); break; } }
public function testUnliteralizing() { $parsed = Horde_Yaml::loadFile($this->fixture('basic')); $expected = "Line #1\nLine #2"; $this->assertEquals($expected, $parsed['literalStringTest']); }
function unserialize($type, $data) { $parts = explode(';', $type); $type = trim($parts[0]); if (empty($data)) { return null; } switch ($type) { case 'application/json': case 'text/javascript': if ($out = json_decode($data, true)) { return $out; } // Handle invalid JSON too... $fixed = preg_replace('/(\\w+):/', '"$1":', $data); $out = json_decode($fixed, true); return $out; case 'text/x-yaml': require_once 'Horde/Yaml.php'; require_once 'Horde/Yaml/Loader.php'; require_once 'Horde/Yaml/Node.php'; return Horde_Yaml::load($data); default: // Attempt anything... if ($out = $this->unserialize('application/json', $data)) { return $out; } if ($out = $this->unserialize('text/x-yaml', $data)) { return $out; } } }
/** * Handle PHP serialized data. * * @param string &$data Data to check for serialized PHP types. */ protected function _unserialize(&$data) { if (substr($data, 0, 5) != '!php/') { return; } $first_space = strpos($data, ' '); $type = substr($data, 5, $first_space - 5); $class = null; if (strpos($type, '::') !== false) { list($type, $class) = explode('::', $type); if (!in_array($class, Horde_Yaml::$allowedClasses)) { throw new Horde_Yaml_Exception("{$class} is not in the list of allowed classes"); } } switch ($type) { case 'object': if (!class_exists($class)) { throw new Horde_Yaml_Exception("{$class} is not defined"); } $reflector = new ReflectionClass($class); if (!$reflector->implementsInterface('Serializable')) { throw new Horde_Yaml_Exception("{$class} does not implement Serializable"); } $class_data = substr($data, $first_space + 1); $serialized = 'C:' . strlen($class) . ':"' . $class . '":' . strlen($class_data) . ':{' . $class_data . '}'; $data = unserialize($serialized); break; case 'array': case 'hash': $array_data = substr($data, $first_space + 1); $array_data = Horde_Yaml::load('a: ' . $array_data); if (is_null($class)) { $data = $array_data['a']; } else { if (!class_exists($class)) { throw new Horde_Yaml_Exception("{$class} is not defined"); } $array = new $class(); if (!$array instanceof ArrayAccess) { throw new Horde_Yaml_Exception("{$class} does not implement ArrayAccess"); } foreach ($array_data['a'] as $key => $val) { $array[$key] = $val; } $data = $array; } break; } }