Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Modules 1.1-RC1 - cannot get rid of warnings - example required
  • In the good old days, before Fuel 1.1 RC1, the modules did not return any errors or warnings. I have tried without success to RTFM and understand the info, changed existing code, Googled, searched forums, etc and still get the following warnings.
    Warning - 2011-10-29 21:47:11 --> Fuel\Core\Request::execute - The Topbox\Controller_Topbox::after() method should accept and return the Controller's response, empty return for the after() method is deprecated.
    
    Warning - 2011-10-29 21:47:11 --> Fuel\Core\Request::execute - The Topbox\Controller_Topbox controller should return a string or a Response object, support for the $controller->response object is deprecated.
    
    The module is very simple:
    <?php
    namespace Topinfo;
    
    //=================================
    class Controller_Topinfo extends \Controller&#123;
    
    // public $response;
    
    //=================================
    public function action_index()
    &#123;
     return 'action_index()';
    }
    
    //=================================================
    public function after($response)
    &#123;
     return $response;
    }
    
    }
    

    I would be grateful for a working example or a link of a module that does not produce any warnings.
  • CRACKED IT
    <?php
    namespace Topbox;
    
    //=================================================
    Class Controller_Topbox extends \Controller&#123;
    
    //=================================================
    public function action_index()
    &#123;
        $this->render('_topbox');
    }
    
    //=================================================
    public function after($response)
    &#123;
     return $this->response;
    }
    
    }
    

    // Notes:
    1. function action_index() does not require a return value. 2. function after($response) essential, $response parameter can have any name and always has a NULL value. 3. function after($response) return value must be $this-response Hope to have code online soon: http://fuel.johns-jokes.com/
  • Not sure what is happening but all that is not true: 1. Action methods must have a return value that is either a Response, View or ViewModel instance or a string. Not having that is only supported for backwards compatibility. 2. The Controller::after() method must take the return value of the action method (the $response) and return it - changed or unchanged. If you don't change it there's little reason to add the method btw. 3. Both Controller::render() and $this->response are only supported for backwards compatibility. And something I noticed about your original post: your errors are about a module Topbox and you code is about Topinfo - so you may have been looking for the mistakes in the wrong place before ending up with these conclusions. [edit: said Request where I meant Response]
  • Jelmer Schreuder wrote on Sunday 30th of October 2011:
    Not sure what is happening but all that is not true: Hi Jelmer, Many thanks for your response. http://fuel.johns-jokes.com/modules/single/topinfo.html I am trying to build the above app to take full advantage of Modules. The application above uses Fuel 1.1 Dev As you may see from the Topinfo module the size of the log file is zero bytes. The bottom of the displayed page shows the source for Module Topinfo. The update to Fuel 1.1 RC1 has not been easy. The old code produced numerous errors and warnings. I am gradually working my way clearing the log file. The source provided does actually work for all Modules Topbox, Topinfo, Menuvert, etc and does not produce any errors or warnings. I appreciate your comments about "all that is not true" and would be grateful if you could supply the following using the latest Fuel Version 1.1 RC1 1. instantiate a Module in a Class
    2. create the Module and Module View
    3. call the Module in a Class View By the way I previously tried using Request, View and ViewModel and they all produced errors.
  • What is your definition of a "Module"? Module is a FuelPHP development concept, and as such, it can not be instantiated or called.
  • One correction I also made in my post above: where I said Request I meant Response instance for action returns. Errors of this type are mostly the result of a partial upgrade, or something went wrong with pulling the core because you had made changes to your local repo, or the app hadn't fully been upgraded to v1.1. If that's not the case I don't know how you can get those errors as your code example above looks fine to me, I even tested the provided code completely unaltered in v1.1 and got no such debug logs. As to your questions: 1. You don't instantiate a Module, so I'm not sure what you mean? A Module is basicly an app sub-namespace that provides additional functionality for finding files (config/lang/views) and classes in that namespace. There's nothing to instantiate about it. 2. The above looks fine for creating a module controller, and as I said I tested it without any of the debug warnings you gave. 3. Calling a module class? If you mean outside the module you need to have the module loaded as described in the docs. Within the module you can just call it like any other class and leave out the namespace as it'll load any non-prefixed classnames from the current namespace (PHP namespaces 101).
  • Hi Jelmer, It is now quite late here so tomorrow I will download and install a fresh copy of Fuel 1.1 RC1 and gradually build my app again. What I meant by instantiate was to set the paths, my bad choice of words.

Howdy, Stranger!

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

In this Discussion