當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Row::getDestinationProperty方法代碼示例

本文整理匯總了PHP中Drupal\migrate\Row::getDestinationProperty方法的典型用法代碼示例。如果您正苦於以下問題:PHP Row::getDestinationProperty方法的具體用法?PHP Row::getDestinationProperty怎麽用?PHP Row::getDestinationProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\migrate\Row的用法示例。


在下文中一共展示了Row::getDestinationProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     $source = $this->configuration['source_base_path'] . $row->getSourceProperty($this->configuration['source_path_property']);
     $destination = $row->getDestinationProperty($this->configuration['destination_path_property']);
     $replace = FILE_EXISTS_REPLACE;
     if (!empty($this->configuration['rename'])) {
         $entity_id = $row->getDestinationProperty($this->getKey('id'));
         if (!empty($entity_id) && ($entity = $this->storage->load($entity_id))) {
             $replace = FILE_EXISTS_RENAME;
         }
     }
     $dirname = drupal_dirname($destination);
     if (!file_prepare_directory($dirname, FILE_CREATE_DIRECTORY)) {
         throw new MigrateException(t('Could not create directory %dirname', array('%dirname' => $dirname)));
     }
     if ($this->configuration['move']) {
         $copied = file_unmanaged_move($source, $destination, $replace);
     } else {
         // Determine whether we can perform this operation based on overwrite rules.
         $original_destination = $destination;
         $destination = file_destination($destination, $replace);
         if ($destination === FALSE) {
             throw new MigrateException(t('File %file could not be copied because a file by that name already exists in the destination directory (%destination)', array('%file' => $source, '%destination' => $original_destination)));
         }
         $source = $this->urlencode($source);
         $copied = copy($source, $destination);
     }
     if ($copied) {
         return parent::import($row, $old_destination_id_values);
     } else {
         throw new MigrateException(t('File %source could not be copied to %destination.', array('%source' => $source, '%destination' => $destination)));
     }
 }
開發者ID:davidsoloman,項目名稱:drupalconsole.com,代碼行數:36,代碼來源:EntityFile.php

示例2: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     if ($bundle_key = $this->getKey('bundle')) {
         $bundle = $row->getDestinationProperty($bundle_key);
     } else {
         $bundle = $this->storage->getEntityTypeId();
     }
     // Some migrations save additional data of an existing entity and only
     // provide the reference to the entity, in those cases, we can not run the
     // processing below. Migrations that need that need to provide the bundle.
     if ($bundle) {
         $field_definitions = $this->entityManager->getFieldDefinitions($this->storage->getEntityTypeId(), $bundle);
         foreach ($field_definitions as $field_name => $field_definition) {
             $field_type = $field_definition->getType();
             if ($this->migrateEntityFieldPluginManager->getDefinition($field_type, FALSE)) {
                 $destination_value = $this->migrateEntityFieldPluginManager->createInstance($field_type)->import($field_definition, $row->getDestinationProperty($field_name));
                 // @TODO: check for NULL return? Add an unset to $row? Maybe needed in
                 // exception handling? Propagate exception?
                 $row->setDestinationProperty($field_name, $destination_value);
             }
         }
     }
     $entity = $this->getEntity($row, $old_destination_id_values);
     return $this->save($entity, $old_destination_id_values);
 }
開發者ID:anatalsceo,項目名稱:en-classe,代碼行數:28,代碼來源:EntityContentBase.php

示例3: getEntityId

 /**
  * {@inheritdoc}
  */
 protected function getEntityId(Row $row)
 {
     $entity_type = $row->getDestinationProperty('entity_type');
     $bundle = $row->getDestinationProperty('bundle');
     $field_name = $row->getDestinationProperty('field_name');
     return "{$entity_type}.{$bundle}.{$field_name}";
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:10,代碼來源:EntityBaseFieldOverride.php

示例4: getEntityId

 /**
  * {@inheritdoc}
  */
 protected function getEntityId(Row $row)
 {
     // Try to find the block by its plugin ID and theme.
     $properties = array('plugin' => $row->getDestinationProperty('plugin'), 'theme' => $row->getDestinationProperty('theme'));
     $blocks = array_keys($this->storage->loadByProperties($properties));
     return reset($blocks);
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:10,代碼來源:EntityBlock.php

示例5: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     $uid = $row->getDestinationProperty('uid');
     $module = $row->getDestinationProperty('module');
     $key = $row->getDestinationProperty('key');
     $this->userData->set($module, $uid, $key, $row->getDestinationProperty('settings'));
     return [$uid, $module, $key];
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:11,代碼來源:UserData.php

示例6: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     /** @var \Drupal\shortcut\ShortcutSetInterface $set */
     $set = $this->shortcutSetStorage->load($row->getDestinationProperty('set_name'));
     /** @var \Drupal\user\UserInterface $account */
     $account = User::load($row->getDestinationProperty('uid'));
     $this->shortcutSetStorage->assignUser($set, $account);
     return array($set->id(), $account->id());
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:12,代碼來源:ShortcutSetUsers.php

示例7: import

  /**
   * {@inheritdoc}
   */
  public function import(Row $row, array $old_destination_id_values = array()) {

    db_insert('photos_comment')
      ->fields(array(
        'fid' => $row->getDestinationProperty('fid'),
        'cid' => $row->getDestinationProperty('cid')
      ))
      ->execute();

    return array($row->getDestinationProperty('fid'), $row->getDestinationProperty('cid'));
  }
開發者ID:AshishNaik021,項目名稱:iimisac-d8,代碼行數:14,代碼來源:PhotosComment.php

示例8: import

  /**
   * {@inheritdoc}
   */
  public function import(Row $row, array $old_destination_id_values = array()) {

    db_insert('photos_access_user')
      ->fields(array(
        'id' => $row->getDestinationProperty('id'),
        'uid' => $row->getDestinationProperty('uid'),
      ))
      ->execute();

    return array($row->getDestinationProperty('id'), $row->getDestinationProperty('uid'));
  }
開發者ID:AshishNaik021,項目名稱:iimisac-d8,代碼行數:14,代碼來源:PhotosAccessUser.php

示例9: getEntity

 /**
  * Get the entity.
  *
  * @param \Drupal\migrate\Row $row
  *   The row object.
  *
  * @return \Drupal\Core\Entity\EntityInterface|false
  *   The entity or false if it can not be created.
  */
 protected function getEntity(Row $row, array $old_destination_id_values)
 {
     $revision_id = $old_destination_id_values ? reset($old_destination_id_values) : $row->getDestinationProperty($this->getKey('revision'));
     if (!empty($revision_id) && ($entity = $this->storage->loadRevision($revision_id))) {
         $entity->setNewRevision(FALSE);
     } else {
         $entity_id = $row->getDestinationProperty($this->getKey('id'));
         $entity = $this->storage->load($entity_id);
         $entity->enforceIsNew(FALSE);
         $entity->setNewRevision(TRUE);
     }
     $this->updateEntity($entity, $row);
     $entity->isDefaultRevision(FALSE);
     return $entity;
 }
開發者ID:HakS,項目名稱:drupal8_training,代碼行數:24,代碼來源:EntityRevision.php

示例10: transform

 /**
  * {@inheritdoc}
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     $source = $this->configuration['source'];
     $properties = is_string($source) ? array($source) : $source;
     $return = array();
     foreach ($properties as $property) {
         if ($property || (string) $property === '0') {
             $is_source = TRUE;
             if ($property[0] == '@') {
                 $property = preg_replace_callback('/^(@?)((?:@@)*)([^@]|$)/', function ($matches) use(&$is_source) {
                     // If there are an odd number of @ in the beginning, it's a
                     // destination.
                     $is_source = empty($matches[1]);
                     // Remove the possible escaping and do not lose the terminating
                     // non-@ either.
                     return str_replace('@@', '@', $matches[2]) . $matches[3];
                 }, $property);
             }
             if ($is_source) {
                 $return[] = $row->getSourceProperty($property);
             } else {
                 $return[] = $row->getDestinationProperty($property);
             }
         } else {
             $return[] = $value;
         }
     }
     if (is_string($source)) {
         $this->multiple = is_array($return[0]);
         return $return[0];
     }
     return $return;
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:36,代碼來源:Get.php

示例11: import

 /**
  * {@inheritdoc}
  * @throws \Drupal\migrate\MigrateException
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     // Do not overwrite the root account password.
     if ($row->getDestinationProperty('uid') == 1) {
         $row->removeDestinationProperty('pass');
     }
     return parent::import($row, $old_destination_id_values);
 }
開發者ID:sgtsaughter,項目名稱:d8portfolio,代碼行數:12,代碼來源:EntityUser.php

示例12: transform

 /**
  * {@inheritdoc}
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     // Only the filter_html filter's settings have a changed format.
     if ($row->getDestinationProperty('id') === 'filter_html') {
         $value['allowed_html'] = str_replace(array_keys($this->allowedHtmlDefaultAttributes), array_values($this->allowedHtmlDefaultAttributes), $value['allowed_html']);
     }
     return $value;
 }
開發者ID:dmyerson,項目名稱:d8ecs,代碼行數:11,代碼來源:FilterSettings.php

示例13: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     $values = array();
     // array_intersect_key() won't work because the order is important because
     // this is also the return value.
     foreach (array_keys($this->getIds()) as $id) {
         $values[$id] = $row->getDestinationProperty($id);
     }
     $entity = $this->getEntity($values['entity_type'], $values['bundle'], $values[static::MODE_NAME]);
     if (!$row->getDestinationProperty('hidden')) {
         $entity->setComponent($values['field_name'], $row->getDestinationProperty('options') ?: array());
     } else {
         $entity->removeComponent($values['field_name']);
     }
     $entity->save();
     return array_values($values);
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:20,代碼來源:ComponentEntityDisplayBase.php

示例14: import

  /**
   * {@inheritdoc}
   */
  public function import(Row $row, array $old_destination_id_values = array()) {
    // @todo build storage interface for photos?

    // @todo look up node->nid in migration system and match pid!
    // @todo add support to check if pid exists.
    $path = db_update('photos_album')
      ->fields(array(
        'fid' => $row->getDestinationProperty('fid'),
        'wid' => $row->getDestinationProperty('wid'),
        'count' => $row->getDestinationProperty('count'),
        'data' => $row->getDestinationProperty('data'),
      ))
      ->condition('pid', $row->getDestinationProperty('pid'))
      ->execute();

    return array($path['pid']);
  }
開發者ID:AshishNaik021,項目名稱:iimisac-d8,代碼行數:20,代碼來源:Photos.php

示例15: import

 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     $values = array();
     // array_intersect_key() won't work because the order is important because
     // this is also the return value.
     foreach (array_keys($this->getIds()) as $id) {
         $values[$id] = $row->getDestinationProperty($id);
     }
     $entity = $this->getEntity($values['entity_type'], $values['bundle'], $values[static::MODE_NAME]);
     if (!$entity->isNew()) {
         $settings = $row->getDestinationProperty('field_group');
         $entity->setThirdPartySetting('field_group', $row->getDestinationProperty('id'), $settings);
         if (isset($settings['format_type']) && ($settings['format_type'] == 'no_style' || $settings['format_type'] == 'hidden')) {
             $entity->unsetThirdPartySetting('field_group', $row->getDestinationProperty('id'));
         }
         $entity->save();
     }
     return array_values($values);
 }
開發者ID:frankcr,項目名稱:sftw8,代碼行數:22,代碼來源:FieldGroupEntityFormDisplay.php


注:本文中的Drupal\migrate\Row::getDestinationProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。