diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-12 07:16:23 +0200 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-12 07:16:23 +0200 |
| commit | 7076343338ae3439f3c86f01144818abe8c31978 (patch) | |
| tree | 794abb1e6b8f821091fd095341885496b6dad51d /tests/code/proxy.php | |
| parent | 47cbb529f5723b246125ae083a193e11481b89ef (diff) | |
| download | classroom-7076343338ae3439f3c86f01144818abe8c31978.tar.gz classroom-7076343338ae3439f3c86f01144818abe8c31978.tar.bz2 classroom-7076343338ae3439f3c86f01144818abe8c31978.zip | |
add container helpers; constuct public directory-tree
Diffstat (limited to 'tests/code/proxy.php')
| -rw-r--r-- | tests/code/proxy.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/code/proxy.php b/tests/code/proxy.php new file mode 100644 index 0000000..c249c46 --- /dev/null +++ b/tests/code/proxy.php @@ -0,0 +1,38 @@ +<?php +/** + * @param class: needs to be a valid (full if namespaced) class + * @param method: method to call + * @param args (array): an array of passed arguments into method call + * @param ttl (int): will be used in some cache service + */ +function proxy($class, $method, $args, $ttl) +{ + // ksort($args); // is not recursive, won't sort category keys + $key = $class .':'. $method .':'. json_encode( + $args, + JSON_UNESCAPED_LINE_TERMINATORS|JSON_UNESCAPED_UNICODE + ); + $data = call_user_func_array([$class, $method], $args); + reply_json([ + 'key' => $key, + 'cache' => sha1($key), + 'data' => $data + ]); +} + +# proxy('app\models\market\ProductCategories_model','categoryProducts', +# [ +# [ 'id'=>10100, 'Hierarchy' => '.10.10100' ], // pass category (needs Hierarchy) +# 904 // pas store +# ], +# 100 // ttl +# ); + +proxy(app\models\market\ProductCategories_model::class,'categoryProducts', + [ + [ 'id'=>10100, 'Hierarchy' => '.10.10100' ], // pass category (needs Hierarchy) + 904 // pas store + ], + 100 // ttl +); + |
