Skip to content

Commit

Permalink
fix(feed): 修复动态话题 logo 验证错误和读取错误
Browse files Browse the repository at this point in the history
  • Loading branch information
medz committed Sep 13, 2018
1 parent 7867045 commit 9e8260d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/API2/Resources/Feed/Topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public function toArray($request): array
return [
'id' => $this->id,
'name' => $this->name,
'logo' => $this->when($this->logo, $this->logo),
'logo' => $this->when($this->logo, function () {
return $this->logo->toArray();
}),
'desc' => $this->when($this->desc, $this->desc),
'creator_user_id' => $this->creator_user_id,
'feeds_count' => $this->feeds_count,
Expand Down
4 changes: 3 additions & 1 deletion app/API2/Resources/Feed/TopicCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public function collectionItemToArray($item): array
return [
'id' => $item->id,
'name' => $item->name,
'logo' => $this->when((bool) $item->logo, $item->logo),
'logo' => $this->when((bool) $item->logo, function () use ($item) {
return $item->logo->toArray();
}),
'created_at' => $this->dateTimeToIso8601ZuluString($item->{Model::CREATED_AT}),
];
}
Expand Down
6 changes: 4 additions & 2 deletions app/FileStorage/Validators/Rulers/FileStorageRuler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

namespace Zhiyi\Plus\FileStorage\Validators\Rulers;

use Exception;
use Zhiyi\Plus\FileStorage\Resource;
use Zhiyi\Plus\FileStorage\StorageInterface;

class FileStorageRuler implements RulerInterface
Expand All @@ -36,7 +38,7 @@ class FileStorageRuler implements RulerInterface
*/
public function __construct(StorageInterface $storage)
{
$this->storage;
$this->storage = $storage;
}

/**
Expand All @@ -50,7 +52,7 @@ public function handle(array $params): bool
return (bool) $this->storage
->meta(new Resource($params[1]))
->getSize();
} finally {
} catch (Exception $e) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ValidatorRegister
* @var array
*/
protected $rules = [
'file_storage',
'file_storage' => FileStorageRuler::class,
];

/**
Expand Down

0 comments on commit 9e8260d

Please sign in to comment.