File tree Expand file tree Collapse file tree 6 files changed +39
-7
lines changed
Expand file tree Collapse file tree 6 files changed +39
-7
lines changed Original file line number Diff line number Diff line change @@ -88,12 +88,16 @@ public function templateData(Arguments $arguments): array
8888 $ suffix = 'Table ' ;
8989 }
9090
91+ $ imports = [];
9192 $ className = $ data ['namespace ' ] . '\\' . $ name ;
9293 if ($ type === 'table ' ) {
9394 $ className = "{$ data ['namespace ' ]}\Model \\Table \\{$ name }{$ suffix }" ;
95+ $ imports [] = 'Cake\ORM\SelectQuery ' ;
9496 } elseif ($ type === 'entity ' ) {
9597 $ className = "{$ data ['namespace ' ]}\Model \\Entity \\{$ name }" ;
98+ $ imports [] = $ className ;
9699 }
100+ $ imports [] = 'Authorization \\IdentityInterface ' ;
97101
98102 $ variable = Inflector::variable ($ name );
99103 if ($ variable === 'user ' ) {
@@ -106,6 +110,7 @@ public function templateData(Arguments $arguments): array
106110 'suffix ' => $ suffix ,
107111 'variable_name ' => $ variable ,
108112 'classname ' => $ className ,
113+ 'imports ' => $ imports ,
109114 ];
110115
111116 return $ vars + $ data ;
Original file line number Diff line number Diff line change 1+ /**
2+ * Apply user access controls to a query for index actions
3+ *
4+ * @param \Authorization\IdentityInterface $user The user.
5+ * @param \Cake\ORM\SelectQuery $query The query to apply authorization conditions to.
6+ * @return bool
7+ */
8+ public function scopeIndex(IdentityInterface $user, SelectQuery $query): SelectQuery
9+ {
10+ }
Original file line number Diff line number Diff line change @@ -18,10 +18,6 @@ declare(strict_types=1);
1818
1919namespace {{ namespace }}\Policy ;
2020
21- {% set imports = [
22- ' Authorization\\ IdentityInterface' ,
23- classname ,
24- ] % }
2521{% for import in imports | sort % }
2622use {{ import }};
2723{% endfor % }
@@ -33,5 +29,7 @@ class {{ name }}{{ suffix }}Policy
3329{
3430{% if type == ' entity' % }
3531 {{- _view . element(' Authorization.entity_methods' ) - }}
32+ {% elseif type == ' table' % }
33+ {{- _view . element(' Authorization.table_methods' ) - }}
3634{% endif % }
3735}
Original file line number Diff line number Diff line change 44namespace TestApp \Policy ;
55
66use Authorization \IdentityInterface ;
7- use TestApp \ Model \ Table \ BookmarksTable ;
7+ use Cake \ ORM \ SelectQuery ;
88
99/**
1010 * Bookmarks policy
1111 */
1212class BookmarksTablePolicy
1313{
14+ /**
15+ * Apply user access controls to a query for index actions
16+ *
17+ * @param \Authorization\IdentityInterface $user The user.
18+ * @param \Cake\ORM\SelectQuery $query The query to apply authorization conditions to.
19+ * @return bool
20+ */
21+ public function scopeIndex (IdentityInterface $ user , SelectQuery $ query ): SelectQuery
22+ {
23+ }
1424}
Original file line number Diff line number Diff line change 44namespace TestPlugin \Policy ;
55
66use Authorization \IdentityInterface ;
7- use TestPlugin \ Model \ Table \ UsersTable ;
7+ use Cake \ ORM \ SelectQuery ;
88
99/**
1010 * Users policy
1111 */
1212class UsersTablePolicy
1313{
14+ /**
15+ * Apply user access controls to a query for index actions
16+ *
17+ * @param \Authorization\IdentityInterface $user The user.
18+ * @param \Cake\ORM\SelectQuery $query The query to apply authorization conditions to.
19+ * @return bool
20+ */
21+ public function scopeIndex (IdentityInterface $ user , SelectQuery $ query ): SelectQuery
22+ {
23+ }
1424}
Original file line number Diff line number Diff line change 44namespace TestApp \Policy ;
55
66use Authorization \IdentityInterface ;
7- use TestApp \Thing ;
87
98/**
109 * Thing policy
You can’t perform that action at this time.
0 commit comments