Good day, there is a script in a procedural style, you need to remake it into OOP, the main part of the script has already been translated, this part remains that you can’t conclude in class in order to inherit everything that is in it

if(isset($_GET['category'])){ $id = (int)$_GET['category']; // хлебные крошки // return true (array not empty) || return false $breadcrumbs_array = $this->model->breadcrumbs($categories, $id); if($breadcrumbs_array){ $breadcrumbs = "<a href='/cat/'>Главная</a> / "; foreach($breadcrumbs_array as $id => $title){ $breadcrumbs .= "<a href='?category={$id}'>{$title}</a> / "; } $breadcrumbs = rtrim($breadcrumbs, " / "); $breadcrumbs = preg_replace("#(.+)?<a.+>(.+)</a>$#", "$1$2", $breadcrumbs); }else{ $breadcrumbs = "<a href='/cat/'>Главная</a> / Каталог"; } // ID дочерних категорий $ids = $this->model->cats_id($categories, $id); $ids = !$ids ? $id : rtrim($ids, ","); if($ids) $products = $this->model->get_products($ids); else $products = null; }else{ $products = $this->model->get_products(); } 
  • Firstly, a template engine is obviously needed here. Secondly, why is OOP here? - andreymal
  • before ascribing OOP somewhere, solve a much more important task - the separation of layers of application business logic and data access, and their presentation. the hodgepodge of their pkhp and html is the big problem. - teran
  • andreymal, put in a class and called through objects, because such a view in the controller does not look very good - anonym
  • teran, what is it all about? there is a class that displays a multi-level menu, this code fragment (navigation chain) remains to be placed in the same class for convenience and greater simplicity - anonymous
  • to the fact that, in principle, the generation of htmp by pure means of the pkhp code is a non-usable hat. use templates. - teran

0