If this record is the result of a query and the attribute is not loaded,
null will be returned.
public getAttribute ( string $name ) : mixed | ||
$name | string | the attribute name |
리턴 | mixed | the attribute value. `null` if the attribute is not set or does not exist. |
/** * Returns the status string of the next valid status from the list of transitions * * @param BaseActiveRecord|SimpleWorkflowBehavior $model * @return string */ public static function getNextStatus($model) { $currentStatus = $model->getAttribute('status'); $statusList = $model->getWorkflowSource()->getAllStatuses($model->getWorkflow()->getId()); $transitions = array_keys(WorkflowHelper::getNextStatusListData($this->owner)); $started = false; foreach ($statusList as $status) { $status_id = $status->getId(); if ($started) { if (in_array($status_id, $transitions) && static::isValidNextStatus($model, $status_id)) { return $status_id; } } if ($status_id == $currentStatus) { $started = true; } } return $currentStatus; }
/** * @param BaseActiveRecord $owner * @param $attribute * @param $dimension * @param bool $absoluteUrl * * @return mixed|null|string */ public function thumbnail($owner, $attribute, $dimension, $absoluteUrl = true) { $value = $owner->getAttribute($attribute); if ((new UrlValidator())->validate($value)) { return $value; } if ($value && file_exists($value)) { return Url::to('@web/' . (new Thumbnailer(['imagePath' => $value]))->generate($dimension), $absoluteUrl); } if ($this->placeholder) { list($width, $height) = Utils::getDimension($dimension); return call_user_func([$this->placeholder, 'getImage'], $width, $height); } return null; }