Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fuel Core : comprehension/analysis - Config
  • Hello, I'm more and more into Fuel and when reading the code I was wondering when the lines 94-112 from the config.php file are necessary:
    https://github.com/fuel/core/blob/develop/classes/config.php#L94 Isn't Fuel::find_file already checking the namespace and looking through the appropriate directory?
    If yes, why looking twice?
    If no, which case didn't I think about where this code would be useful? Thanks in advance for the answer.
    Julian.
  • Not sure that you mean by path fallback. At first, this was only possible when passing a FQFN, which will be returned by find_file() unaltered. But as you can have multiple module locations, and you don't know where a module is installed, this notation allows you to access the modules files without knowing (in code) the path of the module.
  • Notice the use of a static operator "::", if you were truly calling a namespace it would be Namespace\Class::method(). The operator is just a visual way to specify the namespace... Could have used >> if they wanted to...
  • Yes, I get that. That was not my question. The namespace check is already existing in the Fuel::find_file method, see here:
    https://github.com/fuel/core/blob/develop/classes/fuel.php#L245 I was wondering why it was also existing in the Config class. But I realize just now that it's in the save method. So the file possibly don't exists just yet and we need to create it and compute the path. I feel stupid sometimes.
  • By default config files are saved in app/config if no existing file is found. This code allows you to specify 'module::filename' to create a new config file in a module config directory.
  • Yup, I understand now. The code structure just doesn't seems natural. I would have put all the path fallback in the same place.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion