Skip to content

Commit

Permalink
Merge branch '5.x' into 6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybrad committed Feb 7, 2025
2 parents a2d6922 + ba68b6c commit 7841091
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Added support for viewing read-only settings on environments where `allowAdminChanges` is disabled. ([#1592](https://github.com/craftcms/feed-me/issues/1592))
- Improved the experience of mapping relational fields with individual field instances in Craft 5. ([#1585](https://github.com/craftcms/feed-me/issues/1585))
- Feed Me settings are now only available to admins and when `allowAdminChanges` is set to `true`. ([#1581](https://github.com/craftcms/feed-me/pull/1581))
- Added support for Craft [Time](https://craftcms.com/docs/5.x/reference/field-types/time.html) fields. ([#1593](https://github.com/craftcms/feed-me/pull/1593))
- Added support for `formatted` and `raw` subfields in the Google Maps plugin. ([#1587](https://github.com/craftcms/feed-me/pull/1587))
- Fixed a bug where empty values were not respected for inner-element fields when `setEmptyValues` is set to `true`. ([#1590](https://github.com/craftcms/feed-me/pull/1590))
- Fixed a bug where values with an empty string would not be treated as empty if `setEmtpyValues` is set to `true`. ([#1591](https://github.com/craftcms/feed-me/pull/1591))
Expand Down
65 changes: 65 additions & 0 deletions src/fields/Time.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace craft\feedme\fields;

use Cake\Utility\Hash;
use craft\feedme\base\Field;
use craft\feedme\base\FieldInterface;
use craft\feedme\helpers\DateHelper;
use craft\fields\Time as TimeField;

/**
*
* @property-read string $mappingTemplate
*/
class Time extends Field implements FieldInterface
{
// Properties
// =========================================================================

/**
* @var string
*/
public static string $name = 'Time';

/**
* @var string
*/
public static string $class = TimeField::class;

// Templates
// =========================================================================

/**
* @inheritDoc
*/
public function getMappingTemplate(): string
{
return 'feed-me/_includes/fields/time';
}

// Public Methods
// =========================================================================

/**
* @inheritDoc
*/
public function parseField(): mixed
{
$value = $this->fetchValue();

if ($value === null) {
return null;
}

$formatting = Hash::get($this->fieldInfo, 'options.match');

$timeValue = DateHelper::parseString($value, $formatting);

if ($timeValue) {
return $timeValue;
}

return $value;
}
}
2 changes: 2 additions & 0 deletions src/services/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use craft\feedme\fields\SuperTable;
use craft\feedme\fields\Table;
use craft\feedme\fields\Tags;
use craft\feedme\fields\Time;
use craft\feedme\fields\TypedLink;
use craft\feedme\fields\Users;
use craft\helpers\Component as ComponentHelper;
Expand Down Expand Up @@ -142,6 +143,7 @@ public function getRegisteredFields(): array
RadioButtons::class,
Table::class,
Tags::class,
Time::class,
Users::class,

// Third-Party
Expand Down
8 changes: 8 additions & 0 deletions src/templates/_includes/fields/time.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% import 'feed-me/_macros' as feedMeMacro %}
{% import '_includes/forms' as forms %}

{% set default = default ?? {
type: 'time',
} %}

{% extends 'feed-me/_includes/fields/date' %}

0 comments on commit 7841091

Please sign in to comment.