/var/www/albero/application/models/Products/CategoryModel.php
<?php
namespace App\Model\Products;
use App\Model;
use JetBrains\PhpStorm\Internal\ReturnTypeContract;
class CategoryModel extends Model
{
public function getCategoryById(int $categoryId)
{
if (empty($categoryId)) {
return [];
}
$SQL_TEXT = <<<sql
SELECT c.id AS category_id,
c.name AS category_name,
c.meta_title AS category_meta_title,
c.meta_description AS category_meta_description,
c.meta_keywords AS category_meta_keywords,
c.logo AS category_logo,
c.`description` AS category_description,
c.h1 AS category_h1,
c.url as slug,
concat(c.url, '_', c.id) as final_slug,
c.news_ids
FROM categories c
WHERE c.id = '$categoryId'
sql;
return $this->mcs->getRowSQL($SQL_TEXT, 'getCategoryById');
}
public function getCategoriesForMainMenu(): array
{
$categories = $this->mcs->getDataSQL("SELECT * FROM v_menu", 'getCategoriesForMainMenu');
$menu = [];
foreach ($categories as $category) {
Arguments
"App\Model\Products\CategoryModel::getCategoryById(): Argument #1 ($categoryId) must be of type int, null given, called in /var/www/albero/application/controllers/Product.php on line 24"
/var/www/albero/application/controllers/Product.php
use App\Core\FrontendController;
use App\Model\Products\ProductModel;
use App\Model\Products\CategoryModel;
use Own\Event;
class Product extends FrontendController
{
private ProductModel $pm;
public function __construct()
{
parent::__construct();
$this->pm = new ProductModel();
$this->pageType = 'product';
}
public function getProduct(string $productUrl, int $productId)
{
$this->data['product'] = $this->pm->getProduct($productId);
$this->data['product']['category'] = $this->categories->getCategoryById($this->data['product']['category_id']);
if ($this->data['product']['url'] !== $productUrl) {
redirect(base_url('product/' . $this->data['product']['url'] . '_' . $productId), 'auto', 301);
}
$langLib = get_instance()->lang;
$idiom = get_instance()->userLang == 'ua' ? 'ukrainian' : 'russian';
$langLib->load('seo',$idiom);
$this->translater->translate($this->data['product']);
$this->data['title'] = $this->data['meta_title'] = $this->data['product']['site_name'] . $langLib->l('seo.suffix.product.title');
$this->data['meta_description'] = $this->data['product']['site_name'] . $langLib->l('seo.suffix.product.meta_description');
$this->data['h1'] = $this->data['product']['site_name'];
$this->page = 'product';
$this->render();
}
}
/var/www/albero/system/core/CodeIgniter.php
$scalarTypes = ['int', 'bool', 'string'];
try {
$newParams = [];
$refMEthod = new ReflectionMethod($CI, $method);
foreach ($refMEthod->getParameters() as $i=>$parameter) {
$type = $parameter->getType()->getName();
if(!in_array($type, $scalarTypes)) {
$newParams[$parameter->getPosition()] = $containerBuilder->get($type);
} else {
$newParams[] = array_shift($params);
}
}
if(!empty($params)) foreach ($params as $param) $newParams[] = $param;
$params = $newParams;
} catch (ReflectionException $e) {
show_error($e->getMessage());
}
call_user_func_array(array(&$CI, $method), $params);
// Mark a benchmark end point
$BM->mark('controller_execution_time_( ' . $class . ' / ' . $method . ' )_end');
/*
* ------------------------------------------------------
* Is there a "post_controller" hook?
* ------------------------------------------------------
*/
$EXT->call_hook('post_controller');
/*
* ------------------------------------------------------
* Send the final rendered output to the browser
* ------------------------------------------------------
*/
if ($EXT->call_hook('display_override') === FALSE) {
$OUT->_display();
}
/var/www/albero/public/index.php
);
}
else
{
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
exit(3); // EXIT_CONFIG
}
define('VIEWPATH', $view_folder.DIRECTORY_SEPARATOR);
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*/
require_once BASEPATH.'core/CodeIgniter.php';
Arguments
"/var/www/albero/system/core/CodeIgniter.php"