| null */ protected ?array $cachedSuffixActions = null; /** * @var array */ protected array $suffixActions = []; /** * @var array | null */ protected ?array $cachedPrefixActions = null; /** * @var array */ protected array $prefixActions = []; public function prefixAction(Action | Closure $action): static { $this->prefixActions([$action]); return $this; } /** * @param array $actions */ public function prefixActions(array $actions): static { $this->prefixActions = [ ...$this->prefixActions, ...$actions, ]; return $this; } public function suffixAction(Action | Closure $action): static { $this->suffixActions([$action]); return $this; } /** * @param array $actions */ public function suffixActions(array $actions): static { $this->suffixActions = [ ...$this->suffixActions, ...$actions, ]; return $this; } /** * @return array */ public function getPrefixActions(): array { return $this->cachedPrefixActions ?? $this->cachePrefixActions(); } /** * @return array */ public function cachePrefixActions(): array { $this->cachedPrefixActions = []; foreach ($this->prefixActions as $prefixAction) { foreach (Arr::wrap($this->evaluate($prefixAction)) as $action) { $this->cachedPrefixActions[$action->getName()] = $this->prepareAction( $action ->defaultSize(ActionSize::Small) ->defaultView(Action::ICON_BUTTON_VIEW), ); } } return $this->cachedPrefixActions; } /** * @return array */ public function getSuffixActions(): array { return $this->cachedSuffixActions ?? $this->cacheSuffixActions(); } /** * @return array */ public function cacheSuffixActions(): array { $this->cachedSuffixActions = []; foreach ($this->suffixActions as $suffixAction) { foreach (Arr::wrap($this->evaluate($suffixAction)) as $action) { $this->cachedSuffixActions[$action->getName()] = $this->prepareAction( $action ->defaultSize(ActionSize::Small) ->defaultView(Action::ICON_BUTTON_VIEW), ); } } return $this->cachedSuffixActions; } }