<?php
// an idea about how to setup routes....
$route->set('/question/submit/','Script/submit.php');
// $route->set('/question/submit/','Public/question/submit.php'); // this route is created automatically
$route->set('/question/submit/',\Question\Route::class);
$route->set('/question/submit/',[\Question\Route::class,'submit']);
///
// This is a prototype of the integrated routes/sitemap PLUS response
if ($event->type=='Route'){
$routes =
[
[
'office'=>[
]
]
];
$rdbLookups = [
'office' => ['office','slug LIKE :office_slug']
//this will yield $office = \RDB::findOne('office','slug LIKE :office',[':office'=$submitted_office_id])
,'candi' => ['candi','JOIN office on candi.office_id=office.id WHERE candi.slug LIKE :candi_slug AND office.slug LIKE :office_slug']
// will get candis with the given slug where the office slug is also matched
];
//there won't be many lookups... so it might be reasonable to store the lookup code
//but I can't store lookup code, like raw code... on the computer...
// which means if
return $routes;
} else if ($event->type=='Lookup'){
$office = ...
$candi = ...
return ['office'=>$office,'candi'=>$candi]
} else if ($event->type=='Validate'){
//return true if route is matched
//return false if route is not matched
} else if ($event->type=='deliver'){
}
if ($candi==null
&&is_object($office)))[
]
/*
* Another idea i have is a more opinionated & object-oriented approach
It would pass objects with some special handling to specify what values are acceptable
*/
?>
This script would receive the three objects:
$route
$office_slug
$candi_slug
Each of these would be an instanceof \RouteParamater
$route would specify the file path, the regex, fileExt, compoRootDir, compoObj? and any other paramaters that are attached to a a route
(How does the $route object get created? What if I want to use different route object than the default?... NOting that each route could have multiple regex matches (unless each route has one regex, thus one file has multiple routes)
$office_slug specifies the regex which is valid.
None of these objects need to be returned... Yeah??
We just call their setup methods to save options.
<?php
if ($event->type=='Route'){
$route->deleteRegexMatch('...');//here you might specify a reg-match to remove from the route
$office_slug->canBeAny("SELECT office.slug FROM office");
foreach ($office_slug->options as $slug){
$candi_slug
->with($office_slug, '=', $slug);
->canBeAny("SELECT candi.slug JOIN office ON candi.office_id = office.id WHERE office.slug LIKE :office_slug",[':office_slug'=>$slug]);
}
$office_slug
->yieldOneSQL('office', 'SELECT office.* FROM office WHERE office.slug LIKE :office_slug')
->passTo(['RDB','importArray','office']);
// the query would be executed, returning a row & storing it in the $office variable
// passTo uses one paramater, which is a bindable callable - that is, it receives the first two args like a normal callable, and any additional args are passed as paramaters
// only raw datatypes are allowed in any of these, because that makes it cacheable & storeable
// so routes never have to be generated on request.
// routes get generated, then they're very easily executed
//then RDB::importArray('office', $office) would be called
return;
}
$office = \RDB::find('office','office_slug LIKE ?',[$office_slug]);