|
7 | 7 | use Statamic\Contracts\Assets\AssetContainer as AssetContainerContract; |
8 | 8 | use Statamic\Contracts\Data\Augmentable; |
9 | 9 | use Statamic\Contracts\Data\Augmented; |
| 10 | +use Statamic\Contracts\Query\ContainsQueryableValues; |
10 | 11 | use Statamic\Data\ExistsAsFile; |
11 | 12 | use Statamic\Data\HasAugmentedInstance; |
12 | 13 | use Statamic\Events\AssetContainerBlueprintFound; |
|
27 | 28 | use Statamic\Facades\Stache; |
28 | 29 | use Statamic\Facades\URL; |
29 | 30 | use Statamic\Support\Arr; |
| 31 | +use Statamic\Support\Str; |
30 | 32 | use Statamic\Support\Traits\FluentlyGetsAndSets; |
31 | 33 |
|
32 | | -class AssetContainer implements Arrayable, ArrayAccess, AssetContainerContract, Augmentable |
| 34 | +class AssetContainer implements Arrayable, ArrayAccess, AssetContainerContract, Augmentable, ContainsQueryableValues |
33 | 35 | { |
34 | 36 | use ExistsAsFile, FluentlyGetsAndSets, HasAugmentedInstance; |
35 | 37 |
|
@@ -693,6 +695,24 @@ public static function __callStatic($method, $parameters) |
693 | 695 | return Facades\AssetContainer::{$method}(...$parameters); |
694 | 696 | } |
695 | 697 |
|
| 698 | + public function getQueryableValue(string $field) |
| 699 | + { |
| 700 | + if (in_array($method = Str::camel($field), $this->queryableMethods())) { |
| 701 | + return $this->{$method}(); |
| 702 | + } |
| 703 | + |
| 704 | + return null; |
| 705 | + } |
| 706 | + |
| 707 | + private function queryableMethods(): array |
| 708 | + { |
| 709 | + return [ |
| 710 | + 'absoluteUrl', 'accessible', 'allowDownloading', 'allowMoving', 'allowRenaming', 'allowUploads', |
| 711 | + 'blueprint', 'createFolders', 'diskHandle', 'diskPath', 'editUrl', 'handle', 'hasSearchIndex', |
| 712 | + 'id', 'path', 'private', 'searchIndex', 'showUrl', 'sortDirection', 'sortField', 'title', 'url', |
| 713 | + ]; |
| 714 | + } |
| 715 | + |
696 | 716 | public function __toString() |
697 | 717 | { |
698 | 718 | return $this->handle(); |
|
0 commit comments