The main issue with this module is still the migration to using entities.. this is indirectly a step in the right direction...
Much of the entity refactoring will unpick the tangle that is template_preprocess_simplereservation_week()
There is a no separation of concerns with lots of database queries mixed in with the preparation of prev/next links for the header/banner
Only entity logic will remain in the processing function ( for removal into entities as the next step)
I have broken the template rendering into two.
1) simplereservation-week-header.html.twig
2) simplereservation-week-html-twig
The first, the template for the prev/next links and displays the month on the week number correctly.
The bottom template the reservations.
This has one advantage, the header can be common to many users, as its only inputs are year and week number ( 1..52 )
and can be cached separately
I have simplified the formatting of the prev/next link by passing as a variable a DateTime Object for what was prev_4week etc
and now at the last moment the template takes care of the string conversion
see \Drupal\simplereservation\Controller\ReservationController::calc_prev_next_links()
I will post what I have in the next few days.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | interdiff-4-5.txt | 6.63 KB | martin107 |
| #5 | refactor-2335821-5.patch | 20.03 KB | martin107 |
| #4 | refactor-2335821-4.patch | 17.31 KB | martin107 |
| #4 | interdiff-3.4.txt | 1.26 KB | martin107 |
| #3 | interdiff-2-3.txt | 5.53 KB | martin107 |
Comments
Comment #1
martin107 commentedFirst iteration.
Comment #2
martin107 commentedrestored functionality when to display text "There are no items for reservation" by moving some logic in preprocess into the controller
default value of imgpath can be set and then forgotten about. reducing the preprocess function
Comment #3
martin107 commentedfirst action in simplereservation-week.html.twig was an access check!
if accessGranted
An inappropiate conditional check within a template file. In addition this was a needless duplicate of the existing check in the simplereservation.routing.yml file
Comment #4
martin107 commenteddate rate in reservation list now matches date range from banner.
Comment #5
martin107 commentedMany minor changes to preprocess function.
Putting sql related statements together.
There is no need to produce week_day array when the day ( Mon, Tue etc ) can be got from format call on the calendar[].
config array just contains a calendar array so removed config wrapper.
$day was being used as a dateTime object and a loop index, now using i for loop index.
Comment #6
martin107 commentedComment #9
martin107 commented