Coder Social home page Coder Social logo

Comments (12)

dongilbert avatar dongilbert commented on June 14, 2024

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.

eddieajau avatar eddieajau commented on June 14, 2024

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.

piotr-cz avatar piotr-cz commented on June 14, 2024

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.

dongilbert avatar dongilbert commented on June 14, 2024

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.

dongilbert avatar dongilbert commented on June 14, 2024

Oops, forgot about Factory::getStream() (it's not been removed, yet)

src/Joomla/Archive/Bzip2.php
src/Joomla/Archive/Gzip.php

from joomla-framework.

dongilbert avatar dongilbert commented on June 14, 2024

Once #238 is merged, we can check off Form.

from joomla-framework.

dongilbert avatar dongilbert commented on June 14, 2024

Once #239 is merged, we can check off Language.

from joomla-framework.

dongilbert avatar dongilbert commented on June 14, 2024

Once #241 is merged, we can check off Session.

from joomla-framework.

dongilbert avatar dongilbert commented on June 14, 2024

Once #244 is merged, we can check off Oauth 1 & 2.

from joomla-framework.

dongilbert avatar dongilbert commented on June 14, 2024

Once #242 is merged, we can check off Log. And that will be the last of them.

from joomla-framework.

piotr-cz avatar piotr-cz commented on June 14, 2024

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.

dongilbert avatar dongilbert commented on June 14, 2024

That's a reasonable approach, @piotr-cz

from joomla-framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.