11<?php
22namespace App \Classes \Controllers ;
3- use App \Classes \Data as AppClasses ;
4- use Core \Classes as Core ;
53
6- class DynamicRepoController extends Core \AbstractController {
7- private $ dynamicRepo ;
4+ class DynamicRepoController extends AppController {
5+ private $ dynamicRepo ;
86
9- protected function configure () {
10- $ this ->dynamicRepo = $ this ->getSite ()->getDataRepository ("DynamicRepoExample " );
7+ protected function configure () {
8+ $ this ->dynamicRepo = $ this ->getSite ()->getDataRepository ("DynamicRepoExample " );
119
12- $ this ->getPage ()->setTitle ("Manage Dynamic Repo Example Entries " );
13- $ this ->getPage ()->setOptions (array (
14- array ("name " =>"list " ),
15- array ("name " =>"add " ,"action " =>"add " ,"modal " =>true )));
16- $ this ->getPage ()->setIsSearchable (true );
17- }
10+ $ this ->getPage ()->setTitle ("Manage Dynamic Repo Example Entries " );
11+ $ this ->getPage ()->setOptions (array (
12+ array ("name " =>"list " ),
13+ array ("name " =>"add " ,"action " =>"add " ,"modal " =>true )));
14+ $ this ->getPage ()->setIsSearchable (true );
15+ }
1816
19- protected function remove () {
20- $ data = $ this ->getSite ()->getSanitizedInputData ();
21- if (isset ($ data ['id ' ]) && is_numeric ($ data ['id ' ]) && $ this ->dynamicRepo ->removeById ($ data ['id ' ])) {
22- $ this ->getSite ()->addSystemMessage ('Repo entry removed ' );
23- } else {
24- $ this ->getSite ()->addSystemError ('Error removing repo entry ' );
25- }
26- }
17+ protected function remove () {
18+ $ data = $ this ->getSite ()->getSanitizedInputData ();
19+ if (isset ($ data ['id ' ]) && is_numeric ($ data ['id ' ]) && $ this ->dynamicRepo ->removeById ($ data ['id ' ])) {
20+ $ this ->getSite ()->addSystemMessage ('Repo entry removed ' );
21+ } else {
22+ $ this ->getSite ()->addSystemError ('Error removing repo entry ' );
23+ }
24+ }
2725
28- protected function insert () {
29- $ data = $ this ->getSite ()->getSanitizedInputData ();
30- if (isset ($ data ['entry ' ]) && $ this ->dynamicRepo ->add ($ data ['entry ' ])) {
31- $ this ->getSite ()->addSystemMessage ('Repo entry added ' );
32- } else {
33- $ this ->getSite ()->addSystemError ('Error adding repo entry ' );
34- }
35- }
26+ protected function insert () {
27+ $ data = $ this ->getSite ()->getSanitizedInputData ();
28+ if (isset ($ data ['entry ' ]) && $ this ->dynamicRepo ->add ($ data ['entry ' ])) {
29+ $ this ->getSite ()->addSystemMessage ('Repo entry added ' );
30+ } else {
31+ $ this ->getSite ()->addSystemError ('Error adding repo entry ' );
32+ }
33+ }
3634
37- protected function add () {
38- $ this ->getPage ()->setSubTitle ('New Repo Entry ' );
39- $ this ->setViewName ('entries.add ' );
40- }
35+ protected function add () {
36+ $ this ->getPage ()->setSubTitle ('New Repo Entry ' );
37+ $ this ->setViewName ('entries.add ' );
38+ }
4139
42- protected function update () {
43- $ data = $ this ->getSite ()->getSanitizedInputData ();
44- if (isset ($ data ['entry ' ]) && (isset ($ data ['id ' ]) && is_numeric ($ data ['id ' ])) && $ this ->dynamicRepo ->update ($ data ['id ' ],$ data ['entry ' ])) {
45- $ this ->getSite ()->addSystemMessage ('Entry updated ' );
46- } else {
47- $ this ->getSite ()->addSystemError ('Error updating entry ' );
48- }
49- }
40+ protected function update () {
41+ $ data = $ this ->getSite ()->getSanitizedInputData ();
42+ if (isset ($ data ['entry ' ]) && (isset ($ data ['id ' ]) && is_numeric ($ data ['id ' ])) && $ this ->dynamicRepo ->update ($ data ['id ' ],$ data ['entry ' ])) {
43+ $ this ->getSite ()->addSystemMessage ('Entry updated ' );
44+ } else {
45+ $ this ->getSite ()->addSystemError ('Error updating entry ' );
46+ }
47+ }
5048
51- protected function edit () {
52- $ this ->getPage ()->setSubTitle ('Update Entry ' );
53- $ data = $ this ->getSite ()->getSanitizedInputData ();
54- if (isset ($ data ['id ' ]) && is_numeric ($ data ['id ' ]) && ($ entry = $ this ->dynamicRepo ->getById ($ data ['id ' ]))) {
55- $ this ->getSite ()->getViewRenderer ()->registerViewVariable ("entry " ,$ entry );
56- $ this ->setViewName ('entries.edit ' );
57- }
58- }
49+ protected function edit () {
50+ $ this ->getPage ()->setSubTitle ('Update Entry ' );
51+ $ data = $ this ->getSite ()->getSanitizedInputData ();
52+ if (isset ($ data ['id ' ]) && is_numeric ($ data ['id ' ]) && ($ entry = $ this ->dynamicRepo ->getById ($ data ['id ' ]))) {
53+ $ this ->getSite ()->getViewRenderer ()->registerViewVariable ("entry " ,$ entry );
54+ $ this ->setViewName ('entries.edit ' );
55+ }
56+ }
5957
60- protected function search () {
61- $ data = $ this ->getSite ()->getSanitizedInputData ();
62- if (isset ($ data ['term ' ])) {
63- $ this ->getSite ()->getViewRenderer ()->registerViewVariable ("entries " ,$ this ->dynamicRepo ->search ($ data ['term ' ]));
64- $ this ->setViewName ("entries.list " );
65- } else {
66- $ site ->addSystemError ('There was an error with the search ' );
67- }
68- }
58+ protected function search () {
59+ $ data = $ this ->getSite ()->getSanitizedInputData ();
60+ if (isset ($ data ['term ' ])) {
61+ $ this ->getSite ()->getViewRenderer ()->registerViewVariable ("entries " ,$ this ->dynamicRepo ->search ($ data ['term ' ]));
62+ $ this ->setViewName ("entries.list " );
63+ } else {
64+ $ site ->addSystemError ('There was an error with the search ' );
65+ }
66+ }
6967
70- protected function loadDefault () {
71- $ this ->getPage ()->setSubTitle ('Repo Entries ' );
72- $ this ->getSite ()->getViewRenderer ()->registerViewVariable ("entries " , $ this ->dynamicRepo ->get ());
73- $ this ->setViewName ('entries.list ' );
74- }
75- }
68+ protected function loadDefault () {
69+ $ this ->getPage ()->setSubTitle ('Repo Entries ' );
70+ $ this ->getSite ()->getViewRenderer ()->registerViewVariable ("entries " , $ this ->dynamicRepo ->get ());
71+ $ this ->setViewName ('entries.list ' );
72+ }
73+ }
0 commit comments