public function init($config) { $modelClass = $this->modelClass; foreach ($this->relations as $name => $details) { if (is_array($details)) { $relationClass = $details[1]; switch ($details[0]) { case DbRelations::BELONGS_TO: $this->relations[$name] = DbRelation::belongsTo($details[1], $details[2]); break; case DbRelations::HAS_ONE: $this->relations[$name] = DbRelation::hasOne($details[1])->columnsEqual($modelClass::getDb()->getTablePk($modelClass::getTableName()), $details[2]); break; case DbRelations::HAS_MANY: $this->relations[$name] = DbRelation::hasMany($details[1])->columnsEqual($modelClass::getDb()->getTablePk($modelClass::getTableName()), $details[2]); break; case DbRelations::MANY_TO_MANY: //table_name(model_column, relation_column) list($tableName, $columns) = explode("(", $details[2]); $columns = explode(',', substr($columns, 0, strlen($columns) - 1)); $this->relations[$name] = DbRelation::manyToMany($details[1])->join([$tableName => $name . '_' . $tableName], [$modelClass::getDb()->getTablePk($modelClass::getTableName()) => trim($columns[0])])->columnsEqual($name . '_' . $tableName . '.' . trim($columns[1]), $relationClass::getDb()->getTablePk($relationClass::getTableName())); break; default: trigger_error("Invalid relation type {$details[0]}!"); } } $this->relations[$name]->name = $name; } return parent::init($config); }
protected function init($config) { if (!$this->dayClass) { $this->dayClass = CalendarDay::className(); } $this->_calcWeeks(); parent::init($config); }
protected function init($config) { if (!self::$sessionStarted) { session_start(); self::$sessionStarted = true; } return parent::init($config); }
protected function init($config = array()) { $transport = new \Swift_SmtpTransport($this->smtpHost, $this->smtpPort, $this->smtpSecure); $transport->setUsername($this->smtpUser); $transport->setPassword($this->smtpPassword); $this->mailer = new \Swift_Mailer($transport); return parent::init(); }
public function init($config) { parent::init($config); $this->refresh(); if ($this->isGuest()) { $this->checkAutoLogin(); } return true; }
public function init($config) { $this->predis = new Client($this->parameters, $this->options); return parent::info($config); }
public function init($config) { $this->parseMap(); return parent::init($config); }
public function init($config) { if (Session::get()->exists($this->sessionKey)) { $session = Session::get()->value($this->sessionKey); if (isset($session['userId']) && $session['userId'] == (WebApp::get()->user()->isConnected() ? WebApp::get()->user()->id : 0)) { // handle logout + login $this->user2Sections = $session['user2Sections']; } else { $this->reloadRights(); } } else { $this->reloadRights(); } parent::init($config); }
protected function init($options) { parent::init($options); self::$_instances[md5(serialize($options))] = $this; $this->normalizeRequest(); $this->calculateCurrentURL(); if ($this->secure && isset($_POST) && count($_POST)) { $key = $this->getCsrfKey(); $value = $this->getCsrfValue(); if (!isset($_POST[$key])) { $this->error('CSRF token missing!'); list($this->controller, $this->action) = WebApp::get()->pageAccessDenied; $this->calculateModulePath(); return; } elseif ($_POST[$key] != $value) { $this->error('Invalid CSRF token!' . $_POST[$key] . ' != ' . $value); list($this->controller, $this->action) = WebApp::get()->pageAccessDenied; $this->calculateModulePath(); return; } unset($_POST[$key]); } if (!$this->SEO) { $this->language = isset($_GET['language']) ? $_GET['language'] : $this->defaultLanguage; $this->module = isset($_GET['module']) ? $_GET['module'] : $this->defaultModule; $this->controller = isset($_GET['controller']) ? $_GET['controller'] : $this->defaultController; $this->action = isset($_GET['action']) ? $_GET['action'] : null; $this->calculateModulePath(); } else { $this->updateURLData(); } foreach ($this->modules as $name => $details) { if (is_array($details) && isset($details['path'])) { WebApp::get()->autoload()->addPsr4('\\app\\modules\\' . $name, $details['path'], true); } } }