summaryrefslogtreecommitdiff
path: root/html/app/controllers/cli/CliContoller.php
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-17 12:12:22 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-17 12:12:22 +0300
commit68fc9e55e538e03f94509731ab41a0c8cf96710f (patch)
tree3edb1e81864ac3eb35ba0fe8087ed24da1b812bf /html/app/controllers/cli/CliContoller.php
parent84b2da85a1b452922dadb6a609533b9945afe51d (diff)
downloadclassroom-68fc9e55e538e03f94509731ab41a0c8cf96710f.tar.gz
classroom-68fc9e55e538e03f94509731ab41a0c8cf96710f.tar.bz2
classroom-68fc9e55e538e03f94509731ab41a0c8cf96710f.zip
setup a real server environment (apache DocumentRoot=/var/www/public)
Diffstat (limited to 'html/app/controllers/cli/CliContoller.php')
-rw-r--r--html/app/controllers/cli/CliContoller.php85
1 files changed, 0 insertions, 85 deletions
diff --git a/html/app/controllers/cli/CliContoller.php b/html/app/controllers/cli/CliContoller.php
deleted file mode 100644
index 310e2ae..0000000
--- a/html/app/controllers/cli/CliContoller.php
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-
-namespace app\controllers\cli;
-
-/** CliContoller
- *
- * Re-generate cashes of commonly used entities
- * like: product categories and trendy products
- * (proxy calls make use of PROXY_IGNORE_CACHE)
- *
- * CliController calls Model methods who create
- * cashed data with the exact same arguments as
- * when called from the web interface; this way
- * the Model::method(arguments) triplete creates
- * the same keys as via the web interface.
- *
- * NOTE: Only Cli interface is allowed
- * [if (php_sapi_name() != 'cli') return false;]
- *
- * The Cli-interfaced script can run manualy or
- * (most usual scenario) scheduled via a cron job
- * in order to refresh cashes befor expiration.
- *
- * ---------------------------------------------
- */
-class CliContoller
-{
-
-
- /** (re-) cacheCategoriesTree
- * regenerate cache for product_categories tree
- * @param (void)
- */
- public static function cacheCategoriesTree()
- {
- // Only Cli interface is allowed
- if (php_sapi_name() != 'cli') return false;
-
- # PROXY call:
- # MARKET \ ProductCategories_model::tree():
- # + Refresh Cache
- # --------------------------------------
- echo textColor("Creating category_products tree Cache ... ", \NORMAL);
- $reply = proxy(
- [\app\models\market\ProductCategories_model::class, 'tree'],
- [], \CACHE_ROOT_TTL,
- \PROXY_IGNORE_CACHE
- );
- echo ($reply == false) ? textColor("Failed\n", \FAIL) : textColor("Done!\n", \SUCCESS);
- }
-
-
-
- public static function getProductCategories()
- {
- return \Registry::use('database')->runQuery(
- "SELECT * FROM product_categories",
- []
- );
- }
-
-
-
- /** (re-) cacheCategoryByUrl( url )
- * regenerate cache of a category_product
- * by category's friendly url
- * @param $url (string): the category's friendly url
- */
- public static function cacheCategoryByUrl(string $url)
- {
- // Only Cli interface is allowed
- if (php_sapi_name() != 'cli') return false;
-
- # PROXY call:
- # MARKET \ ProductCategories_model::tree():
- # + Refresh Cache
- # --------------------------------------
- $reply = proxy(
- [\app\models\market\ProductCategories_model::class, 'categoryFromUrl'],
- [ $url ], \CACHE_CATEGORY_TTL,
- \PROXY_IGNORE_CACHE
- );
- echo ($reply == false) ? textColor("Failed\n", \FAIL) : textColor("Done!\n", \SUCCESS);
- }
-} \ No newline at end of file