|
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 |
|
@@ -604,6 +606,24 @@ public static function __callStatic($method, $parameters) |
604 | 606 | return Facades\AssetContainer::{$method}(...$parameters); |
605 | 607 | } |
606 | 608 |
|
| 609 | + public function getQueryableValue(string $field) |
| 610 | + { |
| 611 | + if (in_array($method = Str::camel($field), $this->queryableMethods())) { |
| 612 | + return $this->{$method}(); |
| 613 | + } |
| 614 | + |
| 615 | + return null; |
| 616 | + } |
| 617 | + |
| 618 | + private function queryableMethods(): array |
| 619 | + { |
| 620 | + return [ |
| 621 | + 'absoluteUrl', 'accessible', 'allowDownloading', 'allowMoving', 'allowRenaming', 'allowUploads', |
| 622 | + 'blueprint', 'createFolders', 'diskHandle', 'diskPath', 'editUrl', 'handle', 'hasSearchIndex', |
| 623 | + 'id', 'path', 'private', 'searchIndex', 'showUrl', 'sortDirection', 'sortField', 'title', 'url', |
| 624 | + ]; |
| 625 | + } |
| 626 | + |
607 | 627 | public function __toString() |
608 | 628 | { |
609 | 629 | return $this->handle(); |
|
0 commit comments