/** * @param string $view view file name or alias * @param array $data * @param string $viewPath * @return static * @throws \rmrevin\yii\postman\LetterException */ public function setBodyFromView($view, $data = [], $viewPath = null) { $controller = \Yii::$app->controller; if (!empty($controller)) { $viewPath = isset($controller->module) && $controller->module !== null ? $controller->module->getViewPath() : $controller->getViewPath(); } if (empty($viewPath)) { $viewPath = \Yii::$app->basePath . '/views'; } if (strncmp($view, '@', 1) === 0) { // example $view = '@app/view/email/letter-text.php' $path = \Yii::getAlias($view); } else { // example $view = 'letter-text'; // expand to '/app/views/email/letter-text.php' // or '/app/modules/ModuleName/views/email/letter-text.php' $path = \Yii::getAlias($viewPath) . Component::get()->view_path . DIRECTORY_SEPARATOR . $view . '.php'; } if (!file_exists($path)) { throw new LetterException(\Yii::t('app', 'View file «{path}» not found.', ['path' => $path])); } else { $data['_code'] = $this->code; $data['_subject'] = $this->raw_subject; $this->body = \Yii::$app->getView()->renderFile($path, $data); } return $this; }
function list_drop() { $component = new Component(); $component->get(); foreach ($component as $row) { $data[''] = '[ Components ]'; $data[$row->comp_id] = $row->comp_name . ' - ' . $row->comp_type; } return $data; }
public function alter() { if (!isset($_SESSION['logged'])) { return call('pages', 'home'); } else { if (!isset($_GET['code'])) { return call('pages', 'error', 2); } $requirements = Requirement::all(); $component = Component::get($_GET['code']); require_once 'views/components/alter.php'; } }
<?php echo Component::get('head'); ?> <body> <?php echo Layout::content(); ?> </body> </html>
function get_components() { $component = new Component(); $components = $component->get()->all; $data = array(); $i = 0; foreach ($components as $x) { $data[$i]["comp_name"] = $x->comp_name; $data[$i]["comp_type"] = $x->comp_type; $i++; } echo json_encode($data); }