| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace common\components\uploaddrive;
- use Yii;
- use common\helpers\RegularHelper;
- /**
- * Class Local
- * @package common\components\uploaddrive
- */
- class Local extends DriveInterface
- {
- /**
- * @param $baseInfo
- * @param $fullPath
- * @return mixed
- */
- protected function baseUrl($baseInfo, $fullPath)
- {
- $baseInfo['url'] = Yii::getAlias('@attachurl') . '/' . $baseInfo['url'];
- if ($fullPath == true && !RegularHelper::verify('url', $baseInfo['url'])) {
- $baseInfo['url'] = Yii::$app->request->hostInfo . $baseInfo['url'];
- }
- return $baseInfo;
- }
- /**
- * @param $baseInfo
- * @param $fullPath
- * @return mixed
- */
- protected function domainName($baseInfo, $fullPath)
- {
- $domain_name = Yii::getAlias('@attachurl') . '/';
- // if ($fullPath == true) $domain_name = Yii::$app->request->hostInfo;
- $baseInfo['domain_name'] = $domain_name;
- return $baseInfo;
- }
- /**
- * 初始化
- */
- protected function create()
- {
- // 判断是否追加
- if (isset($this->config['superaddition']) && $this->config['superaddition'] === true) {
- $this->adapter = new \League\Flysystem\Adapter\Local(Yii::getAlias('@attachment'), FILE_APPEND);
- } elseif (isset($this->config['alias_path'])) {
- $this->adapter = new \League\Flysystem\Adapter\Local($this->config['alias_path']);
- } else {
- $this->adapter = new \League\Flysystem\Adapter\Local(Yii::getAlias('@attachment'));
- }
- }
- }
|