| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\Mcp\Abilities; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
class Ability_Definition { |
| 10 |
public string $label; |
| 11 |
public string $description; |
| 12 |
public string $category; |
| 13 |
public array $output_schema; |
| 14 |
public array $meta; |
| 15 |
/** @var callable */ |
| 16 |
public $permission_callback; |
| 17 |
public array $input_schema; |
| 18 |
|
| 19 |
public function __construct( |
| 20 |
string $label, |
| 21 |
string $description, |
| 22 |
string $category, |
| 23 |
array $output_schema, |
| 24 |
array $meta, |
| 25 |
callable $permission_callback, |
| 26 |
array $input_schema = [] |
| 27 |
) { |
| 28 |
$this->label = $label; |
| 29 |
$this->description = $description; |
| 30 |
$this->category = $category; |
| 31 |
$this->output_schema = $output_schema; |
| 32 |
$this->meta = $meta; |
| 33 |
$this->permission_callback = $permission_callback; |
| 34 |
$this->input_schema = $input_schema; |
| 35 |
} |
| 36 |
|
| 37 |
public function to_array(): array { |
| 38 |
$definition = [ |
| 39 |
'label' => $this->label, |
| 40 |
'description' => $this->description, |
| 41 |
'category' => $this->category, |
| 42 |
'output_schema' => $this->output_schema, |
| 43 |
'meta' => $this->meta, |
| 44 |
'permission_callback' => $this->permission_callback, |
| 45 |
]; |
| 46 |
|
| 47 |
if ( ! empty( $this->input_schema ) ) { |
| 48 |
$definition['input_schema'] = $this->input_schema; |
| 49 |
} |
| 50 |
|
| 51 |
return $definition; |
| 52 |
} |
| 53 |
} |
| 54 |
|