. * */ namespace Vvveb\Component; use Vvveb\Sql\PostSQL; use Vvveb\System\Component\ComponentBase; use Vvveb\System\Event; use Vvveb\System\Images; class Posts extends ComponentBase { public static $defaultOptions = [ 'start' => 0, 'language_id' => 1, 'site_id' => 1, 'post_id' => 'url', 'limit' => ['url', 4], 'id_manufacturer' => NULL, 'order' => ['url', 'price asc'], 'id_category' => 'url', 'id' => NULL, ]; public $options = []; function results() { $posts = new PostSQL(); $results = $posts->getAll($this->options); foreach ($results['post'] as $id => &$post) { if (isset($post['images'])) { $post['images'] = json_decode($post['images'], 1); foreach ($post['images'] as &$image) { $image = Images::image($image, 'post'); } } if (isset($post['image'])) { $post['images'][] = Images::image($post['image'], 'post'); } } list($results) = Event::trigger(__CLASS__, __FUNCTION__, $results); return $results; } }