Optional parameters for Route::register?
Permalink 1 user found helpful
I'm attempting to create a class extended from Controller in Concrete5 with optional parameters. I've attempted to scour both the Concrete5 and Symfony documentation, but either the answer is not there, or I'm daft when it comes to oop in PHP. So, I'm looking for a little hand-holding to get me through this process.
the tail of my application\bootstrap\app.php
results in any URI with parameters beyond end producing an error. e.g.
produces a 404 error. It will load if I leave off the /blah at the end (albeit without setting $var1=blah), assuming getplotdata.php exists in the appropriate directory and has these lines near the head.
If line "1" (in the first block) is modified to read
leaving the other lines (including 5) the same, I need to parameterize each. e.g. neither
nor work,
but does
so, how do I specify optional parameters (with or without default values [by exposing $defaults from Symfony?]), or is there a way to produce an "overloaded" class definition in Concrete5? Do I do something like
Cross-posted to http://stackoverflow.com/q/37174465/4228193...
the tail of my application\bootstrap\app.php
Route::register( '/plotdata/{start}/{end}' //1 below , 'Application\Controller\SinglePage\getplotdata::getData' //2 , NULL //3 , array() //4 , array('var1' <= NULL, 'var2' <= NULL, 'var3' <= NULL, 'var4' <= NULL) //5 //1 rtPath | path - start and end are required params /{var1}/{var2}/{var3}/{var4} are optional, //2 callback //3 rtHandle //4 requirements = array() see e.g. line below // array('start' => '[0-9]{4}(-[0-9]{2}){2} [ 0-2][0-9](:[0-5][0-9]){2}(.[0-9]{3})?' //5 options | additionalAttributes );
results in any URI with parameters beyond end producing an error. e.g.
plotdata/2015-02-01 00%3A00%3A00/2016-02-09 23%3A59%3A00/blah
produces a 404 error. It will load if I leave off the /blah at the end (albeit without setting $var1=blah), assuming getplotdata.php exists in the appropriate directory and has these lines near the head.
namespace Application\Controller\SinglePage; class getplotdata extends Controller {
If line "1" (in the first block) is modified to read
'/plotdata/{start}/{end}/{var1}/{var2}/{var3}/{var4}'leaving the other lines (including 5) the same, I need to parameterize each. e.g. neither
plotdata/2015-02-01 00%3A00%3A00/2016-02-09 23%3A59%3A00/blah
nor
plotdata/2015-02-01 00%3A00%3A00/2016-02-09 23%3A59%3A00
but
plotdata/2015-02-01 00%3A00%3A00/2016-02-09 23%3A59%3A00/1/2/3/4
so, how do I specify optional parameters (with or without default values [by exposing $defaults from Symfony?]), or is there a way to produce an "overloaded" class definition in Concrete5? Do I do something like
$bob = Route::register( '/plotdata/{start}/{end}' , 'Application\Controller\SinglePage\getplotdata::getData' ); //end $bob $bob->addDefaults(array('var1' <= NULL, 'var2' <= NULL, 'var3' <= NULL, 'var4' <= NULL));
Cross-posted to http://stackoverflow.com/q/37174465/4228193...
(tail of) app.php:
code to extract the optional parameters in getplotdata.php (in appropriate directory based on namespace, etc):
Please see Stack Overflow link for notes and more details.