<?php
namespace Moto\Application\Content; use Moto\Json\Request; use Moto\Json\Response; use Moto\Json\Server; use Moto; class RenderService extends Moto\Service\AbstractStaticService { public static function render($request = null) { if (null === $request) { $request = static::getRequest()->getParams(); } $table = Moto\System::getDbTable('contentBlock'); $table->useResultAsModel(true); $id = Moto\Util::getValue($request, 'id'); $record = $table->getById($id); if (!$record) { $popupId = Moto\Website\Settings::get('notfound_popup_id', 0) * 1; if ($popupId > 0) { $record = $table->getById($popupId); } } if (!$record) { throw new Server\Exception(Moto\System\Exception::ERROR_NOT_FOUND_MESSAGE, Moto\System\Exception::ERROR_NOT_FOUND_CODE); } $contentHelper = new Moto\Website\PageSectionContent($record); $result = $record->toArray(); $result['content'] = $contentHelper->toHtml(); return $result; } }