Skip to content

Commit

Permalink
Replace the Platform version of the Registry package with the Framewo…
Browse files Browse the repository at this point in the history
…rk's
  • Loading branch information
mbabker committed Mar 26, 2014

Verified

This commit was signed with the committer’s verified signature.
frapell Franco Pellegrini
1 parent d3d2c3c commit fd24759
Showing 19 changed files with 350 additions and 190 deletions.
14 changes: 14 additions & 0 deletions libraries/classmap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/**
* @package Joomla.Libraries
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

JLoader::registerAlias('JRegistry', '\\Joomla\\Registry\\Registry');
JLoader::registerAlias('JRegistryFormat', '\\Joomla\\Registry\\AbstractRegistryFormat');
JLoader::registerAlias('JRegistryFormatINI', '\\Joomla\\Registry\\Format\\Ini');
JLoader::registerAlias('JRegistryFormatJSON', '\\Joomla\\Registry\\Format\\Json');
JLoader::registerAlias('JRegistryFormatPHP', '\\Joomla\\Registry\\Format\\Php');
JLoader::registerAlias('JRegistryFormatXML', '\\Joomla\\Registry\\Format\\Xml');
6 changes: 6 additions & 0 deletions libraries/cms.php
Original file line number Diff line number Diff line change
@@ -29,6 +29,12 @@
// Register the library base path for CMS libraries.
JLoader::registerPrefix('J', JPATH_PLATFORM . '/cms', false, true);

// Register the framework namespace
JLoader::registerNamespace('Joomla', JPATH_PLATFORM . '/framework');

// Register the class aliases for Framework classes that have replaced their Platform equivilents
require_once __DIR__ . '/classmap.php';

// Register a handler for uncaught exceptions that shows a pretty error page when possible
set_exception_handler(array('JErrorPage', 'render'));

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
<?php
/**
* @package Joomla.Platform
* @subpackage Registry
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

defined('JPATH_PLATFORM') or die;
namespace Joomla\Registry;

/**
* Abstract Format for JRegistry
* Abstract Format for Registry
*
* @package Joomla.Platform
* @subpackage Registry
* @since 11.1
* @since 1.0
*/
abstract class JRegistryFormat
abstract class AbstractRegistryFormat
{
/**
* @var array JRegistryFormat instances container.
* @since 11.3
* @var array Format instances container.
* @since 1.0
*/
protected static $instances = array();

@@ -30,10 +27,10 @@ abstract class JRegistryFormat
*
* @param string $type The format to load
*
* @return JRegistryFormat Registry format handler
* @return AbstractRegistryFormat Registry format handler
*
* @since 11.1
* @throws InvalidArgumentException
* @since 1.0
* @throws \InvalidArgumentException
*/
public static function getInstance($type)
{
@@ -43,21 +40,11 @@ public static function getInstance($type)
// Only instantiate the object if it doesn't already exist.
if (!isset(self::$instances[$type]))
{
// Only load the file if the class does not exist.
$class = 'JRegistryFormat' . $type;
$class = '\\Joomla\\Registry\\Format\\' . ucfirst($type);

if (!class_exists($class))
{
$path = __DIR__ . '/format/' . $type . '.php';

if (is_file($path))
{
include_once $path;
}
else
{
throw new InvalidArgumentException('Unable to load format class.', 500);
}
throw new \InvalidArgumentException('Unable to load format class.', 500);
}

self::$instances[$type] = new $class;
@@ -74,7 +61,7 @@ public static function getInstance($type)
*
* @return string Formatted string.
*
* @since 11.1
* @since 1.0
*/
abstract public function objectToString($object, $options = null);

@@ -86,7 +73,7 @@ abstract public function objectToString($object, $options = null);
*
* @return object Data Object
*
* @since 11.1
* @since 1.0
*/
abstract public function stringToObject($data, array $options = array());
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<?php
/**
* @package Joomla.Platform
* @subpackage Registry
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

defined('JPATH_PLATFORM') or die;
namespace Joomla\Registry\Format;

use Joomla\Registry\AbstractRegistryFormat;
use stdClass;

/**
* INI format handler for JRegistry.
* INI format handler for Registry.
*
* @package Joomla.Platform
* @subpackage Registry
* @since 11.1
* @since 1.0
*/
class JRegistryFormatINI extends JRegistryFormat
class Ini extends AbstractRegistryFormat
{
/**
* Cache of processed data
* A cache used by stringToobject.
*
* @var array
* @since 11.1
* @since 1.0
*/
protected static $cache = array();

/**
* Converts an object into an INI formatted string
* - Unfortunately, there is no way to have ini values nested further than two
* - Unfortunately, there is no way to have ini values nested further than two
* levels deep. Therefore we will only go through the first two levels of
* the object.
*
@@ -37,7 +37,7 @@ class JRegistryFormatINI extends JRegistryFormat
*
* @return string INI formatted string.
*
* @since 11.1
* @since 1.0
*/
public function objectToString($object, $options = array())
{
@@ -74,11 +74,11 @@ public function objectToString($object, $options = array())
* Parse an INI formatted string and convert it into an object.
*
* @param string $data INI formatted string to convert.
* @param mixed $options An array of options used by the formatter, or a boolean setting to process sections.
* @param array $options An array of options used by the formatter, or a boolean setting to process sections.
*
* @return object Data object.
*
* @since 11.1
* @since 1.0
*/
public function stringToObject($data, array $options = array())
{
@@ -166,13 +166,13 @@ public function stringToObject($data, array $options = array())
{
$value = false;
}
// If the value is 'true' assume boolean true.
elseif ($value == 'true')
// If the value is 'true' assume boolean true.
{
$value = true;
}
// If the value is numeric than it is either a float or int.
elseif (is_numeric($value))
// If the value is numeric than it is either a float or int.
{
// If there is a period then we assume a float.
if (strpos($value, '.') !== false)
@@ -210,7 +210,7 @@ public function stringToObject($data, array $options = array())
*
* @return string The value in INI format.
*
* @since 11.1
* @since 1.0
*/
protected function getValueAsINI($value)
{
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<?php
/**
* @package Joomla.Platform
* @subpackage Registry
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

defined('JPATH_PLATFORM') or die;
namespace Joomla\Registry\Format;

use Joomla\Registry\AbstractRegistryFormat;

/**
* JSON format handler for JRegistry.
* JSON format handler for Registry.
*
* @package Joomla.Platform
* @subpackage Registry
* @since 11.1
* @since 1.0
*/
class JRegistryFormatJSON extends JRegistryFormat
class Json extends AbstractRegistryFormat
{
/**
* Converts an object into a JSON formatted string.
@@ -26,7 +25,7 @@ class JRegistryFormatJSON extends JRegistryFormat
*
* @return string JSON formatted string.
*
* @since 11.1
* @since 1.0
*/
public function objectToString($object, $options = array())
{
@@ -43,15 +42,15 @@ public function objectToString($object, $options = array())
*
* @return object Data object.
*
* @since 11.1
* @since 1.0
*/
public function stringToObject($data, array $options = array('processSections' => false))
{
$data = trim($data);

if ((substr($data, 0, 1) != '{') && (substr($data, -1, 1) != '}'))
{
$ini = JRegistryFormat::getInstance('INI');
$ini = AbstractRegistryFormat::getInstance('Ini');
$obj = $ini->stringToObject($data, $options);
}
else
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<?php
/**
* @package Joomla.Platform
* @subpackage Registry
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

defined('JPATH_PLATFORM') or die;
namespace Joomla\Registry\Format;

use Joomla\Registry\AbstractRegistryFormat;

/**
* PHP class format handler for JRegistry
* PHP class format handler for Registry
*
* @package Joomla.Platform
* @subpackage Registry
* @since 11.1
* @since 1.0
*/
class JRegistryFormatPHP extends JRegistryFormat
class Php extends AbstractRegistryFormat
{
/**
* Converts an object into a php class string.
@@ -27,7 +26,7 @@ class JRegistryFormatPHP extends JRegistryFormat
*
* @return string Config class formatted string
*
* @since 11.1
* @since 1.0
*/
public function objectToString($object, $params = array())
{
@@ -67,7 +66,7 @@ public function objectToString($object, $params = array())
*
* @return object Data object.
*
* @since 11.1
* @since 1.0
*/
public function stringToObject($data, array $options = array())
{
@@ -81,7 +80,7 @@ public function stringToObject($data, array $options = array())
*
* @return array
*
* @since 11.1
* @since 1.0
*/
protected function getArrayString($a)
{
Loading

0 comments on commit fd24759

Please sign in to comment.