'name_en' => 'Naziv na engleskom', 'tagNames' => 'Godina', 'col_number' => 'Redni broj', ]; } public function behaviors() { return [ [ 'class' => Taggable::className(), ], ]; } public function getTags() { return $this->hasMany(Tag::className(), ['id' => 'tag_id'])->viaTable('predmeti_tag', ['predmet_id' => 'id']); }
* Makes sure that the behaviors declared in [[behaviors()]] are attached to this component. */ public function ensureBehaviors() { if ($this->_behaviors === null) { $this->_behaviors = []; foreach ($this->behaviors() as $name => $behavior) { $this->attachBehaviorInternal($name, $behavior); } } } /**
* * @param string $name the event name * @param Event|null $event the event instance. If not set, a default [[Event]] object will be created. */ public function trigger($name, Event $event = null) { $this->ensureBehaviors(); $eventHandlers = []; foreach ($this->_eventWildcards as $wildcard => $handlers) { if (StringHelper::matchWildcard($wildcard, $name)) { $eventHandlers[] = $handlers; }
* This method is called at the end of the constructor. * The default implementation will trigger an [[EVENT_INIT]] event. */ public function init() { parent::init(); $this->trigger(self::EVENT_INIT); } /** * This method is called when the AR object is created and populated with the query result. * The default implementation will trigger an [[EVENT_AFTER_FIND]] event. * When overriding this method, make sure you call the parent implementation to ensure the
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
* you may implement the so-called single-table inheritance mapping. * @param array $row row data to be populated into the record. * @return static the newly created active record */ public static function instantiate($row) { return new static(); } /** * Returns whether there is an element at the specified offset. * This method is required by the interface [[\ArrayAccess]]. * @param mixed $offset the offset to check on
return $rows; } else { $models = []; /* @var $class ActiveRecord */ $class = $this->modelClass; foreach ($rows as $row) { $model = $class::instantiate($row); $modelClass = get_class($model); $modelClass::populateRecord($model, $row); $models[] = $model; } return $models; }
public function populate($rows) { if (empty($rows)) { return []; } $models = $this->createModels($rows); if (!empty($this->join) && $this->indexBy === null) { $models = $this->removeDuplicatedModels($models); } if (!empty($this->with)) { $this->findWith($this->with, $models); }
* if the query results in nothing. */ public function one($db = null) { $row = parent::one($db); if ($row !== false) { $models = $this->populate([$row]); return reset($models) ?: null; } return null; }
'dataProvider' => $dataProvider, 'model' => $model, ]); } public function actionMaterijalView($id) { $model = Predmeti::find()->where(['id' => $id])->one(); return $this->render('materijal-view', [ 'model' => $model, ]); } /**
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
require __DIR__ . '/../yii_app/vendor/autoload.php'; require __DIR__ . '/../yii_app/vendor/yiisoft/yii2/Yii.php'; $config = require __DIR__ . '/../yii_app/config/web.php'; (new yii\web\Application($config))->run();
$_GET = [ 'id' => '51', ];