public function actionPing($src) { $filename = basename($src); $filepath = Url::to(ImgController::PING_IMG_DIR) . $filename; if (!file_exists($filepath)) { ImageHelper::createPingImg($src); } $path = Url::to(['/.resource/' . $filename], true); $this->renderJsonpForJquery(['src' => $path]); \Yii::$app->end(); }
public function setAttributes($values) { foreach ($values as $key => $value) { if ($key == 'id') { $this->external_id = $value; } else { if ($key == "user") { $filename = basename($value->profile_picture, ".jpg") . ".png"; $filepath = Url::to("/.resource/") . $filename; if (!file_exists($filepath)) { ImageHelper::createPingImg($value->profile_picture); } $this->{$key} = isset($value) ? json_encode($value) : null; } else { if ($this->hasAttribute($key)) { $this->{$key} = isset($value) ? json_encode($value) : null; } } } } }