joomla / joomla-framework

[READ-ONLY] This repo is no longer in active development. Please see https://github.com/joomla-framework for the individual Framework packages.
http://framework.joomla.org
GNU General Public License v2.0
189 stars 140 forks source link

[RFC] decoupling hard to test methods #333

Closed ghost closed 10 years ago

ghost commented 10 years ago

A first pass on setting up a Runtime Registry to be used to retrieve settings from the runtime environment in the same manner that Registry retrieves settings from an application environment.

As such, the Runtime Registry is a subclass of Registry with added functional logic to check for the existence of PHP Classes, Functions, and Extensions.

Committing early for feedback on naming convention, documentation, etc.

If other packages make Registry a required dependency, then current calls such as:

static public function isSupported() { return extension_loaded('someextension'); }

Can be written as static public function isSupported($runtime = null) { if ($runtime === null) { $runtime = self::getRuntime(CLASS); } return $runtime->extensionExists('someextension'); }

If instead it is a recommended package, then such a test would be written as:

Can be written as static public function isSupported($runtime = null) {

if class_exists('Joomla\Registry\Runtime', true) { if ($runtime === null) { $runtime = self::getRuntime(CLASS); } return $runtime->extensionExists('someextension'); } }

return self::isSuportedFallback(); }

static public function isSupportedFallback() { // Log a warning message that the Runtime Registry did not exist return extension_loaded('someextension'); }

ghost commented 10 years ago

Needs work