Skip to content

Commit

Permalink
Update to Registry 1.5 package
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Babker committed Oct 14, 2015
1 parent 546cf9c commit 79119b2
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 114 deletions.
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 56 additions & 56 deletions libraries/vendor/composer/installed.json
Expand Up @@ -319,62 +319,6 @@
"utilities"
]
},
{
"name": "joomla/registry",
"version": "1.4.5",
"version_normalized": "1.4.5.0",
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/registry.git",
"reference": "4f926ba961ca45eb95076a1598c3ae689cb02fc5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/registry/zipball/4f926ba961ca45eb95076a1598c3ae689cb02fc5",
"reference": "4f926ba961ca45eb95076a1598c3ae689cb02fc5",
"shasum": ""
},
"require": {
"joomla/compat": "~1.0",
"joomla/string": "~1.3",
"joomla/utilities": "~1.0",
"php": ">=5.3.10"
},
"require-dev": {
"joomla/test": "~1.0",
"phpunit/phpunit": "4.*",
"squizlabs/php_codesniffer": "1.*",
"symfony/yaml": "~2.0"
},
"suggest": {
"symfony/yaml": "Install 2.* if you require YAML support."
},
"time": "2015-03-28 17:54:38",
"type": "joomla-package",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Joomla\\Registry\\": "src/",
"Joomla\\Registry\\Tests\\": "Tests/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0+"
],
"description": "Joomla Registry Package",
"homepage": "https://github.com/joomla-framework/registry",
"keywords": [
"framework",
"joomla",
"registry"
]
},
{
"name": "joomla/event",
"version": "1.1.1",
Expand Down Expand Up @@ -766,5 +710,61 @@
"framework",
"joomla"
]
},
{
"name": "joomla/registry",
"version": "1.5.0",
"version_normalized": "1.5.0.0",
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/registry.git",
"reference": "db55cf426bd27524557affbe95b18d6a2f959657"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/registry/zipball/db55cf426bd27524557affbe95b18d6a2f959657",
"reference": "db55cf426bd27524557affbe95b18d6a2f959657",
"shasum": ""
},
"require": {
"joomla/compat": "~1.0",
"joomla/string": "~1.3",
"joomla/utilities": "~1.0",
"php": ">=5.3.10"
},
"require-dev": {
"joomla/test": "~1.0",
"phpunit/phpunit": "4.*",
"squizlabs/php_codesniffer": "1.*",
"symfony/yaml": "~2.0"
},
"suggest": {
"symfony/yaml": "Install 2.* if you require YAML support."
},
"time": "2015-10-14 17:01:46",
"type": "joomla-package",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Joomla\\Registry\\": "src/",
"Joomla\\Registry\\Tests\\": "Tests/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0+"
],
"description": "Joomla Registry Package",
"homepage": "https://github.com/joomla-framework/registry",
"keywords": [
"framework",
"joomla",
"registry"
]
}
]
56 changes: 10 additions & 46 deletions libraries/vendor/joomla/registry/src/AbstractRegistryFormat.php
Expand Up @@ -11,69 +11,33 @@
/**
* Abstract Format for Registry
*
* @since 1.0
* @since 1.0
* @deprecated 2.0 Format objects should directly implement the FormatInterface
*/
abstract class AbstractRegistryFormat
abstract class AbstractRegistryFormat implements FormatInterface
{
/**
* @var array Format instances container.
* @var AbstractRegistryFormat[] Format instances container.
* @since 1.0
* @deprecated 2.0 Object caching will no longer be supported
*/
protected static $instances = array();

/**
* Returns a reference to a Format object, only creating it
* if it doesn't already exist.
*
* @param string $type The format to load
* @param string $type The format to load
* @param array $options Additional options to configure the object
*
* @return AbstractRegistryFormat Registry format handler
*
* @deprecated 2.0 Use Factory::getFormat() instead
* @since 1.0
* @throws \InvalidArgumentException
*/
public static function getInstance($type)
public static function getInstance($type, array $options = array())
{
// Sanitize format type.
$type = strtolower(preg_replace('/[^A-Z0-9_]/i', '', $type));

// Only instantiate the object if it doesn't already exist.
if (!isset(self::$instances[$type]))
{
$class = '\\Joomla\\Registry\\Format\\' . ucfirst($type);

if (!class_exists($class))
{
throw new \InvalidArgumentException('Unable to load format class.', 500);
}

self::$instances[$type] = new $class;
}

return self::$instances[$type];
return Factory::getFormat($type, $options);
}

/**
* Converts an object into a formatted string.
*
* @param object $object Data Source Object.
* @param array $options An array of options for the formatter.
*
* @return string Formatted string.
*
* @since 1.0
*/
abstract public function objectToString($object, $options = null);

/**
* Converts a formatted string into an object.
*
* @param string $data Formatted string
* @param array $options An array of options for the formatter.
*
* @return object Data Object
*
* @since 1.0
*/
abstract public function stringToObject($data, array $options = array());
}
74 changes: 74 additions & 0 deletions libraries/vendor/joomla/registry/src/Factory.php
@@ -0,0 +1,74 @@
<?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\Registry;

/**
* Factory class to fetch Registry objects
*
* @since 1.5.0
*/
class Factory
{
/**
* Format instances container - for backward compatibility with AbstractRegistryFormat::getInstance().
*
* @var FormatInterface[]
* @since 1.5.0
* @deprecated 2.0 Object caching will no longer be supported
*/
protected static $formatInstances = array();

/**
* Returns a AbstractRegistryFormat object, only creating it if it doesn't already exist.
*
* @param string $type The format to load
* @param array $options Additional options to configure the object
*
* @return FormatInterface Registry format handler
*
* @since 1.5.0
* @throws \InvalidArgumentException
*/
public static function getFormat($type, array $options = array())
{
// Sanitize format type.
$type = strtolower(preg_replace('/[^A-Z0-9_]/i', '', $type));

/*
* Only instantiate the object if it doesn't already exist.
* @deprecated 2.0 Object caching will no longer be supported, a new instance will be returned every time
*/
if (!isset(self::$formatInstances[$type]))
{
$localNamespace = __NAMESPACE__ . '\\Format';
$namespace = isset($options['format_namespace']) ? $options['format_namespace'] : $localNamespace;
$class = $namespace . '\\' . ucfirst($type);

if (!class_exists($class))
{
// Were we given a custom namespace? If not, there's nothing else we can do
if ($namespace === $localNamespace)
{
throw new \InvalidArgumentException(sprintf('Unable to load format class for type "%s".', $type), 500);
}

$class = $localNamespace . '\\' . ucfirst($type);

if (!class_exists($class))
{
throw new \InvalidArgumentException(sprintf('Unable to load format class for type "%s".', $type), 500);
}
}

self::$formatInstances[$type] = new $class;
}

return self::$formatInstances[$type];
}
}
10 changes: 5 additions & 5 deletions libraries/vendor/joomla/registry/src/Format/Ini.php
Expand Up @@ -91,12 +91,12 @@ public function objectToString($object, $options = array())
foreach ($v as $array_key => $item)
{
$array_key = ($assoc) ? $array_key : '';
$local[] = $k . '[' . $array_key . ']=' . $this->getValueAsINI($item);
$local[] = $k . '[' . $array_key . ']=' . $this->getValueAsIni($item);
}
}
else
{
$local[] = $k . '=' . $this->getValueAsINI($v);
$local[] = $k . '=' . $this->getValueAsIni($v);
}
}

Expand All @@ -113,13 +113,13 @@ public function objectToString($object, $options = array())
foreach ($value as $array_key => $item)
{
$array_key = ($assoc) ? $array_key : '';
$global[] = $key . '[' . $array_key . ']=' . $this->getValueAsINI($item);
$global[] = $key . '[' . $array_key . ']=' . $this->getValueAsIni($item);
}
}
else
{
// Not in a section so add the property to the global array.
$global[] = $key . '=' . $this->getValueAsINI($value);
$global[] = $key . '=' . $this->getValueAsIni($value);
$in_section = false;
}
}
Expand Down Expand Up @@ -338,7 +338,7 @@ public function stringToObject($data, array $options = array())
*
* @since 1.0
*/
protected function getValueAsINI($value)
protected function getValueAsIni($value)
{
$string = '';

Expand Down
41 changes: 41 additions & 0 deletions libraries/vendor/joomla/registry/src/FormatInterface.php
@@ -0,0 +1,41 @@
<?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\Registry;

/**
* Interface defining a format object
*
* @since 1.5.0
*/
interface FormatInterface
{
/**
* Converts an object into a formatted string.
*
* @param object $object Data Source Object.
* @param array $options An array of options for the formatter.
*
* @return string Formatted string.
*
* @since 1.5.0
*/
public function objectToString($object, $options = null);

/**
* Converts a formatted string into an object.
*
* @param string $data Formatted string
* @param array $options An array of options for the formatter.
*
* @return object Data Object
*
* @since 1.5.0
*/
public function stringToObject($data, array $options = array());
}

0 comments on commit 79119b2

Please sign in to comment.