Remove coupling to JFactory #32
Comments
So would the basic thought on this be that in cases where the Factory::getXXXXXX method is just a wrapper for specific The only downside of that approach is in the case of Not sure what to do. |
So I think in the case of JFactory::getDbo we replace that with the database factory where we know we have the configuration for the database. If we can't guarantee that we will have configuration, then we should rely only on dependancy injection. Application handles configuration so I think we require a node and a format for the database credentials and from there we can safely support |
Removes Factory and simplifies the package by using more DI. Refs #32
Removes Factory and simplifies the package by using more DI. Refs #32
After @mbabker 's patch, Packages using There's no place where current language is stored (was |
I did a search, and of the remaining methods in // Places that reference: Factory::getDbo()
docs/coding-standards/php.md
src/Joomla/Database/README.md
src/Joomla/Form/Field/Sql.php
src/Joomla/Form/Rule/Email.php
src/Joomla/Language/LanguageHelper.php
src/Joomla/Log/Logger/Database.php
src/Joomla/Session/Storage/Database.php
// Places that reference: Factory::getConfig()
src/Joomla/Form/Field/Timezone.php
src/Joomla/Form/Form.php
src/Joomla/Form/Tests/JFormTest.php
src/Joomla/Log/Logger/Formattedtext.php
src/Joomla/Session/Session.php
src/Joomla/Session/Storage/Memcache.php
src/Joomla/Session/Storage/Memcached.php
// Places that reference: Factory::getsession()
src/Joomla/Oauth1/Client.php
src/Joomla/Session/Session.php
// Places that reference: Factory::$application
src/Joomla/Oauth2/Client.php
src/Joomla/Session/_Tests/JSessionTest.php |
Oops, forgot about
|
Once #238 is merged, we can check off Form. |
Once #239 is merged, we can check off Language. |
Once #241 is merged, we can check off Session. |
Once #244 is merged, we can check off Oauth 1 & 2. |
Once #242 is merged, we can check off Log. And that will be the last of them. |
I think the solution for class Text
{
protected static $lang;
public static function setLanguage(Language $lang)
{
static::$lang = $lang;
}
public static function _($string, $jsSafe = false, $interpretBackSlashes = true, $script = false)
{
$lang = self::$lang;
//...
}
} and then // In application
$language = Language::getInstance('pl-PL');
Text::setLanguage($lang);
// Later on
echo Text::_('HELLO_WORLD'); |
That's a reasonable approach, @piotr-cz |
We need to remove the coupling to the old JFactory, now \Joomla\Factory.
The text was updated successfully, but these errors were encountered: