Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
+21
-7
@@ -17,6 +17,7 @@ use IPS\core\Form\WebhookSelector;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Select;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\Url as FormUrl;
|
||||
@@ -25,6 +26,7 @@ use IPS\Log;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
@@ -139,6 +141,8 @@ class Webhook extends Model
|
||||
}
|
||||
|
||||
$form->add( new WebhookSelector('webhook_events', $this->events ?? [], TRUE , [ 'options' => $events] ) );
|
||||
|
||||
$form->add( new Node( 'webhook_api_key', $this->api_key, false, array( 'class' => Key::class, 'multiple' => false ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,8 +163,9 @@ class Webhook extends Model
|
||||
{
|
||||
$values['content_type'] = $values['webhook_content_type'];
|
||||
}
|
||||
$values['api_key'] = ( $values['webhook_api_key'] instanceof Key ) ? $values['webhook_api_key']->id : '';
|
||||
|
||||
unset( $values['webhook_events'], $values['webhook_content_type'], $values['webhook_content_type_other'] );
|
||||
unset( $values['webhook_events'], $values['webhook_content_type'], $values['webhook_content_type_other'], $values['webhook_api_key'] );
|
||||
|
||||
return $values;
|
||||
}
|
||||
@@ -293,22 +298,31 @@ class Webhook extends Model
|
||||
/**
|
||||
* Get API Key
|
||||
*
|
||||
* @return Key
|
||||
* @return Key|null
|
||||
*/
|
||||
public function get_api_key() : Key
|
||||
public function get_api_key() : ?Key
|
||||
{
|
||||
return Key::load( $this->_data['api_key'] );
|
||||
if( isset($this->_data['api_key'] ) && $this->_data['api_key'] )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Key::load( $this->_data['api_key'] );
|
||||
}
|
||||
catch( OutOfRangeException ){}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set API Key
|
||||
*
|
||||
* @param Key $key The API Key
|
||||
* @param Key|string|null $key The API Key
|
||||
* @return void
|
||||
*/
|
||||
public function set_api_key(Key $key ) : void
|
||||
public function set_api_key( Key|string|null $key ) : void
|
||||
{
|
||||
$this->_data['api_key'] = $key->id;
|
||||
$key = ( $key instanceof Key ) ? $key->id : $key;
|
||||
$this->_data['api_key'] = $key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user