Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Changing the Input
  • When making a request from one controller to another, how do I change the Input values? I originally assumed that Request->execute would assign the request parameters to Input, but it does not.

    I am also interested if there is another way of doing this that might work better.

    Thanks!

  • Short answer is: you can't.

    One of the big problems with the current codebase is the use of static class methods, which make everything global.

    At the time of design it was assumed that you either call a controller method from the URL, or internally, but not both, so this issue was never addressed. Also, the assumption was made that params should be passed through the URI, and not using GET variables. Both URI params and data passed to execute() will be passed to the controller method called as arguments.

    Obviously, this doesn't really work in the "WEB API age" we live in now, 5 years later.

    I'll see if I can have another go at this issue without breaking BC.
  • HarroHarro
    Accepted Answer
    Pushed experimental support for this to 1.9/develop: https://github.com/fuel/core/commit/614c196dfbe0810b8b7d657d1fc1d1089fa47cf7

    This allows you to do:

    Request->forge('some/url')
       ->set_method('post')
       ->set_post('postvar', 'value')
       ->set_get(array('getvar1' => 'value', 'getvar2' => 'value'))
       ->execute();

    You can continue to the current Input method like Input::post(), they are now request aware.
  • Exciting!  And thank you.  I am going to try this right away.

  • I won't be able to test it today.  Having trouble with the log file. The changes to fuel/core in commit c4fe3b4caec74a55631a82bf092d46ca66b44cef prevent the log directory and file from being created.

  • That is odd, what exactly is the problem?
  • Unfortunately I won't be able to give you specifics until another week, as its now the start of a national holiday. But basically, the create_dir method was being passed the full log destination path rather than the log root path. Since the "base_path" did not already exist, the create_dir method threw an exception. The log filename ("10.php") was being passed to create_dir as the part to be added onto the base.

    If I created the path in advance and re-ran the script then create_dir would pass OK, but then the actual log file itself could not be created by another function (which I did not investigate).

    If you can wait, I will have time to go over it in detail next week.

  • That should be the case, create_dir() can recursively create the directories that are needed. The old code could not, therefore there were two mkdir() calls, one for the rootpath, and one for the basepath.

    I just tested it with this app config:

        'log_threshold'    => Fuel::L_ERROR,
        'log_path'         => '/tmp/this/is/a/path/that/does/not exist',
        'log_date_format'  => 'Y-m-d H:i:s',

    and that works fine, it creates the entire path in /tmp, followed by 2016/08/10.php.

    I'm curious to see what your issues are, let me know when you finished partying. ;-)
  • Shoot, forget it, I was testing it in an app that someone had overloaded the Log class in, so I was testing the wrong code.

    I can reproduce it, thanks for reporting it.
  • Found it, should be fixed now.

Howdy, Stranger!

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

In this Discussion