diff options
| author | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2026-07-12 15:51:52 +0300 |
|---|---|---|
| committer | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2026-07-12 15:51:52 +0300 |
| commit | 02608271bb2a9f3a65ed536984d306ee14b48e34 (patch) | |
| tree | 3f23ec48a694ec014e845c4f70d9b5f1c065403c /tests/code/proxy.php | |
| download | kalassa-02608271bb2a9f3a65ed536984d306ee14b48e34.tar.gz kalassa-02608271bb2a9f3a65ed536984d306ee14b48e34.tar.bz2 kalassa-02608271bb2a9f3a65ed536984d306ee14b48e34.zip | |
Diffstat (limited to 'tests/code/proxy.php')
| -rwxr-xr-x | 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 100755 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 +); + |
