public function actionGet($path) { $entity = Entity::findOne(['path' => '/' . $path]); if (!$entity) { throw new NotFoundHttpException(\Yii::t('yii', 'Page not found.')); } $storage = $this->module->getStorage($entity->entity->storage); if (!$storage) { throw new InvalidConfigException("Medialib storage \"{$entity->entity->storage}\" not found"); } $url = strtr($storage[0], ['{path}' => $entity->entity->path, '{host}' => Yii::$app->request->serverName]); return $this->redirect($url); }
public function actionIndex($path) { $entity = Entity::findOne(['path' => '/' . $path]); if (!$entity) { throw new NotFoundHttpException(\Yii::t('yii', 'Page not found.')); } $storage = $this->module->getStorage($entity->entity->storage); if (!$storage) { throw new InvalidConfigException("Medialib storage \"{$entity->entity->storage}\" not found"); } $version = $_SERVER['QUERY_STRING'] ? $_SERVER['QUERY_STRING'] : 'origin'; $url = $this->module->getStorage($entity->entity->storage)->genUrl($entity->entity->hash, $version); return $this->redirect($url); }