AUTONAMI_TOKENS::save_token_data( mixed $args, mixed $trigger )

Method save_token_data


Parameters Parameters

$args

(Required)

$trigger

(Required)


Top ↑

Return Return

(void)


Source Source

File: src/integrations/autonami/tokens/autonami-tokens.php

	public function save_token_data( $args, $trigger ) {

		if ( 'AUTONAMI' !== $trigger->get_integration() ) {
			return;
		}

		if ( ! isset( $args['trigger_args'] ) || ! isset( $args['entry_args']['code'] ) ) {
			return;
		}

		$trigger_code = $args['entry_args']['code'];

		$log_entry = $args['trigger_entry'];

		$data = array_shift( $args['trigger_args'] );

		if ( in_array( $trigger_code, $this->get_list_triggers(), true ) ) {

			if ( $data instanceof \BWFCRM_Lists ) {
				$this->save_list_tokens( $data, $log_entry );
			}
		}

		if ( in_array( $trigger_code, $this->get_tag_triggers(), true ) ) {

			if ( $data instanceof \BWFCRM_Tag ) {
				$this->save_tag_tokens( $data, $log_entry );
			}
		}

		$bwfcrm_contact = array_shift( $args['trigger_args'] );

		if ( $bwfcrm_contact instanceof \BWFCRM_Contact ) {
			$this->save_contact_tokens( $bwfcrm_contact, $log_entry );
		}

		do_action( 'automator_autonami_save_tokens', $data, $bwfcrm_contact, $trigger_code, $log_entry );

	}