Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Director::addRules() bug?

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1436 Views
  • UncleCheese
    Avatar
    4085 Posts

    Director::addRules() bug? Link to this post

    I think I may have found a bug in the Director.php code. Correct me if I'm wrong.

    If I use Director::addRules() to specify a custom controller for a URL like this:

    Director::addRules(50, array ('myurl/$Action/$Class' => 'My_Controller'));

    The getControllerForURL() function in the Director class will parse that array and get the name of the controller as a string ("$controller"), and it will instantiate the "My_Controller" object like this:

    $controllerObj = new $controller();

    However, every descendant of the Controller class expects a "$dataRecord" variable to be passed into it. Silverstripe errors out when I use anything but "Controller " as my custom controller because the __construct() method is missing argument 1.

    Am I missing something? Seems crazy!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Director::addRules() bug? Link to this post

    Hmm.. Never mind. It seems the only accepted custom controller you can use is a subclass of Controller.

    1436 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.