Skip to content

Commit

Permalink
create interface for processor data #3463
Browse files Browse the repository at this point in the history
  • Loading branch information
Shelob9 committed Jan 22, 2020
1 parent 4dcf82f commit 8fb4ac6
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cf2/Factories/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Processor implements ProcessorFactory
* @param array $form Saved settings for this form
* @param array $fields Processor settings field configuration
*
* @return \Caldera_Forms_Processor_Get_Data
* @return \Caldera_Forms_Processor_Data
*/
public function dataFactory(array $config,array $form,array $fields){
return new \Caldera_Forms_Processor_Get_Data($config,$form,$fields);
Expand Down
56 changes: 56 additions & 0 deletions processors/classes/data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/**
* Interface Caldera_Forms_Processor_Data
*
* Contract for Caldera_Forms_Processor_Get_Data
*/
interface Caldera_Forms_Processor_Data{
/**
* Add an error message to the errors property
*
* @param string $message Message for error
* @since 1.8.10
*
*/
public function add_error($message);

/**
* Get the errors
*
* @return array|null
* @since 1.8.10
*
*/
public function get_errors();

/**
* Get the values
*
* @return array|null
* @since 1.8.10
*
*/
public function get_values();

/**
* Get prepared fields
*
* @return array|null
* @since 1.8.10
*
*/
public function get_fields();

/**
* Get one value from the processor
*
* @param string $field Name of field
* @param mixed $default Optional. Default value to return if none set.
*
* @return mixed
* @since 1.8.10
*
*/
public function get_value($field, $default = null);
}
2 changes: 1 addition & 1 deletion processors/classes/get_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @copyright 2015 CalderaWP LLC
*/

class Caldera_Forms_Processor_Get_Data {
class Caldera_Forms_Processor_Get_Data implements Caldera_Forms_Processor_Data{

/**
* The values from current submission
Expand Down

0 comments on commit 8fb4ac6

Please sign in to comment.