| Total Complexity | 11 |
| Total Lines | 89 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class SalesForceDefaultContactField extends DataObject |
||
| 8 | { |
||
| 9 | |||
| 10 | /** |
||
| 11 | * |
||
| 12 | * @param array $array fields to send |
||
| 13 | * |
||
| 14 | * @return LiteralField |
||
| 15 | */ |
||
| 16 | public static function field_showing_fields_to_send($array) |
||
| 17 | { |
||
| 18 | $htmlArray = []; |
||
| 19 | foreach($array as $field => $value) { |
||
| 20 | $htmlArray[] = $field.' = '.$value.' ('.gettype($value).')'; |
||
| 21 | } |
||
| 22 | |||
| 23 | return LiteralField::create( |
||
| 24 | 'FieldsToSendToSalesforce', |
||
| 25 | '<h2>Fields Added:</h2><p>'.implode('</p><p>', $htmlArray).'</p>' |
||
| 26 | ); |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * |
||
| 31 | * @var array |
||
| 32 | */ |
||
| 33 | private static $db = [ |
||
|
1 ignored issue
–
show
|
|||
| 34 | 'Key' => 'Varchar', |
||
| 35 | 'Value' => 'Varchar' |
||
| 36 | ]; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Defines summary fields commonly used in table columns |
||
| 40 | * as a quick overview of the data for this dataobject |
||
| 41 | * @var array |
||
| 42 | */ |
||
| 43 | private static $summary_fields = [ |
||
|
1 ignored issue
–
show
|
|||
| 44 | 'Key' => 'Field Name', |
||
| 45 | 'Value' => 'Field Value' |
||
| 46 | ]; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * |
||
| 50 | * @return string |
||
| 51 | */ |
||
| 52 | public function getTitle() |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * contact fields that should be created by default... |
||
| 59 | * @var array |
||
| 60 | */ |
||
| 61 | private static $defaults_records = []; |
||
|
1 ignored issue
–
show
|
|||
| 62 | |||
| 63 | public function requireDefaultRecords() |
||
| 64 | { |
||
| 65 | foreach($this->Config()->get('default_records') as $key => $value) { |
||
| 66 | $filter = [ |
||
| 67 | 'Key' => $key |
||
| 68 | ]; |
||
| 69 | |||
| 70 | $obj = SalesForceDefaultContactField::get()->filter($filter)->first(); |
||
| 71 | if(! $obj) { |
||
| 72 | $obj->create($filter); |
||
| 73 | $obj->Value = $value; |
||
| 74 | $obj->write(); |
||
| 75 | } |
||
| 76 | |||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @return mixed |
||
| 82 | */ |
||
| 83 | public function BetterValue() |
||
| 96 | } |
||
| 97 | } |
||
| 100 |