"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/modules/field/src/Plugin/migrate/process/d6/FieldTypeDefaults.php" (26 Nov 2020, 840 Bytes) of package /linux/www/drupal-8.9.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "FieldTypeDefaults.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\field\Plugin\migrate\process\d6;
    4 
    5 use Drupal\migrate\MigrateException;
    6 use Drupal\migrate\ProcessPluginBase;
    7 use Drupal\migrate\MigrateExecutableInterface;
    8 use Drupal\migrate\Row;
    9 
   10 /**
   11  * Gives us a chance to set per field defaults.
   12  *
   13  * @MigrateProcessPlugin(
   14  *   id = "d6_field_type_defaults"
   15  * )
   16  */
   17 class FieldTypeDefaults extends ProcessPluginBase {
   18 
   19   /**
   20    * {@inheritdoc}
   21    */
   22   public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
   23     if (is_array($value)) {
   24       if ($row->getSourceProperty('module') == 'date') {
   25         $value = 'datetime_default';
   26       }
   27       else {
   28         throw new MigrateException(sprintf('Failed to lookup field type %s in the static map.', var_export($value, TRUE)));
   29       }
   30     }
   31     return $value;
   32   }
   33 
   34 }