UOA_RECIPECOMPLETED_STATUS::define_trigger()

Define and register the trigger by pushing it into the Automator object


Source Source

File: src/integrations/uncanny-automator/triggers/uoa-recipecompleted-status.php

	public function define_trigger() {
		$trigger = array(
			'author'              => Automator()->get_author_name( $this->trigger_code ),
			'support_link'        => Automator()->get_author_support_link( $this->trigger_code, 'integration/automator-core/' ),
			'integration'         => self::$integration,
			'code'                => $this->trigger_code,
			'type'                => 'anonymous',
			/* translators: Logged-in trigger - Uncanny Automator */
			'sentence'            => sprintf( esc_attr__( '{{A recipe:%1$s}} completes with a {{specific:%2$s}} status', 'uncanny-automator' ), $this->trigger_meta, 'RECIPESTATUS' ),
			/* translators: Logged-in trigger - Uncanny Automator */
			'select_option_name'  => esc_attr__( '{{A recipe}} completes with a {{specific}} status', 'uncanny-automator' ),
			'action'              => array( 'automator_recipe_completed', 'automator_recipe_completed_with_errors' ),
			'priority'            => 99,
			'accepted_args'       => 4,
			'validation_function' => array( $this, 'on_completion' ),
			'options'             => [
				Automator()->helpers->recipe->uncanny_automator->options->get_recipes( null, $this->trigger_meta, true ),
				array(
					'option_code'     => 'RECIPESTATUS',
					/* translators: Noun */
					'label'           => esc_attr__( 'Status', 'uncanny-automator' ),
					'input_type'      => 'select',
					'required'        => true,
					'options'         => array(
						'0' => esc_attr__( 'In progress', 'uncanny-automator' ),
						'1' => esc_attr__( 'Completed', 'uncanny-automator' ),
						'2' => esc_attr__( 'Completed with errors', 'uncanny-automator' ),
						//'5' => esc_attr__( 'Scheduled', 'uncanny-automator' ), will be dealt in a separate trigger
						'9' => esc_attr__( 'Completed - do nothing', 'uncanny-automator' ),
					),
					'relevant_tokens' => array(
						'UOARECIPES_recipe_status' => esc_attr__( 'Recipe status', 'uncanny-automator' ),
					),
				),
			],
		);
		Automator()->register->trigger( $trigger );
	}