Comments (12)
So would the basic thought on this be that in cases where the Factory::getXXXXXX method is just a wrapper for specific getInstance()
(as in the case of Database\Driver
) that we just drop it in favor of the getInstance
method for that class?
The only downside of that approach is in the case of Database\Driver::getInstance()
it requires you to pass it a config, which is handled by Factory. So, currently there is no dependency within the Driver::getInstance()
method, but if we switch to doing it as described above, then we create a Config
dependency.
Not sure what to do.
from joomla-framework.
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 loadDatabase
. Does that make sense?
from joomla-framework.
After @mbabker 's patch, Packages using JLanguage::getInstance()
like Text::_('TRANSLATE')
are always falling back to default language.
There's no place where current language is stored (was Factory::$language
before).
I described the problem at the Framework group but have no idea how to handle this.
from joomla-framework.
I did a search, and of the remaining methods in Factory
, only these usages remain:
// 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
from joomla-framework.
Oops, forgot about Factory::getStream()
(it's not been removed, yet)
src/Joomla/Archive/Bzip2.php
src/Joomla/Archive/Gzip.php
from joomla-framework.
Once #238 is merged, we can check off Form.
from joomla-framework.
Once #239 is merged, we can check off Language.
from joomla-framework.
Once #241 is merged, we can check off Session.
from joomla-framework.
Once #244 is merged, we can check off Oauth 1 & 2.
from joomla-framework.
Once #242 is merged, we can check off Log. And that will be the last of them.
from joomla-framework.
I think the solution for Text
is to set the Language
instance, otherwise it will always pull the default one.
(or convert it to instance and provide $language
in constructor)
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');
from joomla-framework.
That's a reasonable approach, @piotr-cz
from joomla-framework.
Related Issues (20)
- Move build process to Jenkins and document
- Document release procedure HOT 14
- Cache needs refactoring HOT 2
- Requiring joomla/application is installing the entire framework
- [DI] Use alias will create shared object twice HOT 2
- DatabaseQuery lacks dateAdd() and unionAll() HOT 1
- Problem with permission Guest HOT 1
- Error in Path::canChmod HOT 4
- Support for PSR-4 autoloading HOT 4
- Missing processor in Joomla\Application\Cli\Output\Stdout HOT 2
- Fatal error: Call to a member function get() on a non-object in Joomla/Http/Transport/Stream.php on line 126 HOT 1
- Error in Language::__construct HOT 1
- phpdoc build error when use composer HOT 2
- Is this a bug? HOT 1
- Update Composer package HOT 2
- Error menu association version 3.4 HOT 2
- JTwitterObject: This server has exceed the Twitter API rate limit for the given period. HOT 3
- JForm -> Showon does not work if field has multiple=true HOT 3
- Joomla\String\String conflicts with PHP 7 HOT 2
- Issue with cached login-redirect HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from joomla-framework.