Source of file CatalogueControllerExtension.php
Size: 2,127 Bytes - Last Modified: 2021-12-24T05:16:22+00:00
/var/www/docs.ssmods.com/process/src/code/extensions/CatalogueControllerExtension.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | <?php /** * Extension for Controller that provide additional methods to all * templates * * @author i-lateral (http://www.i-lateral.com) * @package catalogue */ class CatalogueControllerExtension extends Extension { /** * @return void */ public function onBeforeInit() { // Check if we are runing a dev build, if so check if DB needs // upgrading $controller = $this->owner->request->param("Controller"); $action = $this->owner->request->param("Action"); global $project; // Only check if the DB needs upgrading on a dev build if ($controller == "DevelopmentAdmin" && $action == "build") { // Now check if the files we need are installed // Check if we have the files we need, if not, create them if (!class_exists("Category")) { copy(BASE_PATH . "/catalogue/scaffold/Category", BASE_PATH . "/{$project}/code/model/Category.php"); } if (!class_exists("Category_Controller")) { copy(BASE_PATH . "/catalogue/scaffold/Category_Controller", BASE_PATH . "/{$project}/code/control/Category_Controller.php"); } if (!class_exists("Product")) { copy(BASE_PATH . "/catalogue/scaffold/Product", BASE_PATH . "/{$project}/code/model/Product.php"); } if (!class_exists("Product_Controller")) { copy(BASE_PATH . "/catalogue/scaffold/Product_Controller", BASE_PATH . "/{$project}/code/control/Product_Controller.php"); } } if ($controller != "DevelopmentAdmin") { if (class_exists('Subsite') && Subsite::currentSubsite()) { // Set the location i18n::set_locale(Subsite::currentSubsite()->Language); } } } /** * Inject our product catalogue object into the controller * * @return ProductCatalogue */ public function getCatalogue() { return Catalogue::create(); } } |