-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace rynpsc\phonenumber\integrations\feedme; | ||
|
||
use Cake\Utility\Hash; | ||
use craft\feedme\base\Field as BaseField; | ||
use craft\feedme\base\FieldInterface; | ||
use craft\feedme\helpers\DataHelper; | ||
use rynpsc\phonenumber\fields\PhoneNumberField; | ||
|
||
class Field extends BaseField implements FieldInterface | ||
{ | ||
public static string $name = 'Phone Number'; | ||
|
||
public static string $class = PhoneNumberField::class; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getMappingTemplate(): string | ||
{ | ||
return 'phone-number/integrations/feedme/mapping-template'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function parseField(): mixed | ||
{ | ||
$preppedData = []; | ||
|
||
$fields = Hash::get($this->fieldInfo, 'fields'); | ||
|
||
if (!$fields) { | ||
return null; | ||
} | ||
|
||
foreach ($fields as $subFieldHandle => $subFieldInfo) { | ||
$preppedData[$subFieldHandle] = DataHelper::fetchValue($this->feedData, $subFieldInfo, $this->feed); | ||
} | ||
|
||
return $preppedData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{% if parentPath is defined %} | ||
{% set prefixPath = parentPath %} | ||
{% else %} | ||
{% set prefixPath = [handle] %} | ||
{% endif %} | ||
|
||
{% set classes = ['complex-field'] %} | ||
|
||
<tr class="complex-field complex-field-header"> | ||
<td class="col-field" colspan="3"> | ||
<div class="field"> | ||
<div class="heading"> | ||
<label class="">{{ name }}</label> | ||
</div> | ||
|
||
<div class="additional-mapping-fields"> | ||
{% namespace 'fieldMapping[' ~ prefixPath | join('][') ~ ']' %} | ||
<input type="hidden" name="field" value="{{ className(field) }}"> | ||
{% endnamespace %} | ||
</div> | ||
</div> | ||
</td> | ||
</tr> | ||
|
||
{% set fields = { | ||
region: 'Region', | ||
number: 'Number', | ||
} %} | ||
|
||
{% for key, col in fields %} | ||
{% set nameLabel = col %} | ||
{% set instructionsHandle = handle ~ '[' ~ key ~ ']' %} | ||
|
||
{% set path = prefixPath|merge ([ 'fields', key ]) %} | ||
|
||
{% set default = default ?? { | ||
type: 'text', | ||
} %} | ||
|
||
{% embed 'feed-me/_includes/fields/_base' %}{% endembed %} | ||
{% endfor %} |