-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed the orphan action to compare string and interger values - D8CORE-5193 Add "Forget" orphan action (#47) - Migrate process plugin to adjust date values to 11:59pm (#46) - Deny field access to imported fields on nodes (#44)
- Loading branch information
Showing
8 changed files
with
344 additions
and
27 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
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,66 @@ | ||
<?php | ||
|
||
namespace Drupal\stanford_migrate\Plugin\migrate\process; | ||
|
||
use Drupal\migrate\MigrateExecutableInterface; | ||
use Drupal\migrate\ProcessPluginBase; | ||
use Drupal\migrate\Row; | ||
|
||
/** | ||
* Adjust an ending timestamp to work with the "All Day" for smart date module. | ||
* | ||
* @code | ||
* process: | ||
* field_date/end_value: | ||
* plugin: datetime_adjust | ||
* source: end_value | ||
* start_time: start_value | ||
* @endcode | ||
* | ||
* @MigrateProcessPlugin( | ||
* id = "smartdate_adjust" | ||
* ) | ||
*/ | ||
class SmartDateAllDayAdjust extends ProcessPluginBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { | ||
if (empty($this->configuration['start_time'])) { | ||
return $value; | ||
} | ||
$start = $row->get($this->configuration['start_time']); | ||
if (empty($start)) { | ||
return $value; | ||
} | ||
|
||
if (!is_numeric($start)) { | ||
$start = strtotime($start); | ||
} | ||
|
||
if (!is_numeric($value)) { | ||
$value = strtotime($value); | ||
} | ||
|
||
// If the start and end values are the same & the start is at 12:00 midnight | ||
// then increase the end value to be at the end of the day for the smart | ||
// date module to work correctly. | ||
if ((int) date('Gi', $start) == 0 && $start == $value) { | ||
return $value + (60 * 60 * 24) - 60; | ||
} | ||
|
||
// If either the start or the end date value are not at midnight, don't | ||
// adjust the end value at all since it won't be considered an "All Day" | ||
// date time. | ||
if ((int) date('Gi', $start) || (int) date('Gi', $value)) { | ||
return $value; | ||
} | ||
|
||
// Now that the start and the end must both be at midnight and different | ||
// days, reduce the end value by 1 minute to work correctly with the smart | ||
// date module. | ||
return $value - 60; | ||
} | ||
|
||
} |
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
Oops, something went wrong.