mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 12:27:04 +01:00 
			
		
		
		
	 1900c04b71
			
		
	
	
		1900c04b71
		
			
		
	
	
	
	
		
			
			Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com> Co-authored-by: Boy132 <Boy132@users.noreply.github.com> Co-authored-by: Lance Pioch <git@lance.sh>
		
			
				
	
	
		
			40 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Traits\Filament;
 | |
| 
 | |
| use App\Enums\HeaderActionPosition;
 | |
| use Exception;
 | |
| use Filament\Actions\Action;
 | |
| use Filament\Actions\ActionGroup;
 | |
| use Filament\Actions\CreateAction;
 | |
| use Filament\Actions\DeleteAction;
 | |
| 
 | |
| trait CanCustomizeHeaderActions
 | |
| {
 | |
|     /** @var array<Action|ActionGroup|CreateAction|DeleteAction> */
 | |
|     protected static array $customHeaderActions = [];
 | |
| 
 | |
|     public static function registerCustomHeaderActions(HeaderActionPosition $position, Action|ActionGroup ...$customHeaderActions): void
 | |
|     {
 | |
|         static::$customHeaderActions[$position->value] = array_merge(static::$customHeaderActions[$position->value] ?? [], $customHeaderActions);
 | |
|     }
 | |
| 
 | |
|     /** @return array<int,CreateAction> */
 | |
|     protected function getDefaultHeaderActions(): array
 | |
|     {
 | |
|         return [];
 | |
|     }
 | |
| 
 | |
|     /** @return array<Action|ActionGroup>
 | |
|      * @throws Exception
 | |
|      */
 | |
|     protected function getHeaderActions(): array
 | |
|     {
 | |
|         return array_merge(
 | |
|             static::$customHeaderActions[HeaderActionPosition::Before->value] ?? [],
 | |
|             $this->getDefaultHeaderActions(),
 | |
|             static::$customHeaderActions[HeaderActionPosition::After->value] ?? []
 | |
|         );
 | |
|     }
 | |
| }
 |