getDestination example

/** * Maps the old nid to the new one in the key value collection. * * @param \Drupal\migrate\Event\MigratePostRowSaveEvent $event * The migrate post row save event. */
  public function onPostRowSave(MigratePostRowSaveEvent $event) {
    if ($this->isNodeTranslationsMigration($event)) {
      $row = $event->getRow();
      $source = $row->getSource();
      $destination = $row->getDestination();
      $collection = $this->keyValue->get('node_translation_redirect');
      $collection->set($source['nid'][$destination['nid']$destination['langcode']]);
    }
  }

  /** * Set the node_translation_redirect state to enable the redirections. * * @param \Drupal\migrate\Event\MigrateImportEvent $event * The migrate import event. */
  
$migration,
      $container->get('config.factory')
    );
  }

  /** * {@inheritdoc} */
  public function import(Row $row, array $old_destination_id_values = []) {
    $imported = FALSE;
    $config = $this->configFactory->getEditable($row->getDestinationProperty('configuration_name'));
    $theme_settings = $row->getDestination();
    // Remove keys not in theme settings.     unset($theme_settings['configuration_name']);
    unset($theme_settings['theme_name']);
    unset($theme_settings['legacy_theme_name']);
    if (isset($theme_settings)) {
      theme_settings_convert_to_config($theme_settings$config);
      $config->save();
      $imported = TRUE;
    }
    return $imported;
  }

  
public function downloadRange(RangeDownloadRequest $request)
    {
        // Load SwagUpdate so the DownloadStep can be auto-loaded         Shopware()->Plugins()->Backend()->SwagUpdate();

        $version = new Version([
            'uri' => $request->getUri(),
            'size' => $request->getSize(),
            'sha1' => $request->getSha1(),
        ]);

        return (new DownloadStep($version$request->getDestination()))->run($request->getOffset());
    }

    /** * @param string $file * @param string $pluginName * * @throws Exception */
    public function extractPluginZip($file$pluginName)
    {
        $archive = ZipUtils::openZip($file);
        
->willReturn($value);
    }
    $this->migration->expects($this->once())
      ->method('getProcessPlugins')
      ->with(NULL)
      ->willReturn($plugins);
    $row = new Row();
    $this->executable->processRow($row);
    foreach ($expected as $key => $value) {
      $this->assertSame($row->getDestinationProperty($key)$value);
    }
    $this->assertSameSize($expected$row->getDestination());
  }

  /** * Tests the processRow method with an empty pipeline. */
  public function testProcessRowEmptyPipeline() {
    $this->migration->expects($this->once())
      ->method('getProcessPlugins')
      ->with(NULL)
      ->willReturn(['test' => []]);
    $row = new Row();
    


    /** * Moves a file to a new location. * * @return File */
    public function move(string $targetPath, ?string $name = null, bool $overwrite = false)
    {
        $targetPath = rtrim($targetPath, '/') . '/';
        $name ??= $this->getBaseName();
        $destination = $overwrite ? $targetPath . $name : $this->getDestination($targetPath . $name);

        $oldName = $this->getRealPath() ?: $this->__toString();

        if (! @rename($oldName$destination)) {
            $error = error_get_last();

            throw FileException::forUnableToMove($this->getBasename()$targetPathstrip_tags($error['message']));
        }

        @chmod($destination, 0777 & ~umask());

        
$row = new Row($this->testValues, $this->testSourceIds);
    $this->assertSame($this->testValues['nid']$row->getSourceProperty('nid'));
    $this->assertSame($this->testValues['title']$row->getSourceProperty('title'));
    $this->assertNull($row->getSourceProperty('non_existing'));
  }

  /** * Tests setting and getting the destination. */
  public function testDestination() {
    $row = new Row($this->testValues, $this->testSourceIds);
    $this->assertEmpty($row->getDestination());
    $this->assertFalse($row->hasDestinationProperty('nid'));

    // Set a destination.     $row->setDestinationProperty('nid', 2);
    $this->assertTrue($row->hasDestinationProperty('nid'));
    $this->assertEquals(['nid' => 2]$row->getDestination());
  }

  /** * Tests setting/getting multiple destination IDs. */
  

class DefaultLangcode extends Config {

  /** * {@inheritdoc} */
  public function import(Row $row, array $old_destination_id_values = []) {
    $destination = $row->getDestination();
    $langcode = $destination['default_langcode'];

    // Check if the language exists.     if (ConfigurableLanguage::load($langcode) === NULL) {
      throw new MigrateException("The language '$langcode' does not exist on this site.");
    }

    $this->config->set('default_langcode', $destination['default_langcode']);
    $this->config->save();
    return [$this->config->getName()];
  }

}
$key = $this->configuration['source_key'];
      $source[$key] = $row->getSource();
    }

    if (is_array($value) || $value instanceof \Traversable) {
      foreach ($value as $key => $new_value) {
        if (!is_array($new_value)) {
          throw new MigrateException(sprintf("Input array should hold elements of type array, instead element was of type '%s'", gettype($new_value)));
        }
        $new_row = new Row($new_value + $source);
        $migrate_executable->processRow($new_row$this->configuration['process']);
        $destination = $new_row->getDestination();
        if (array_key_exists('key', $this->configuration)) {
          $key = $this->transformKey($key$migrate_executable$new_row);
        }
        // Do not save the result if the key is NULL. The configured process         // pipeline used in transformKey() will return NULL if a         // MigrateSkipProcessException is thrown.         // @see \Drupal\filter\Plugin\migrate\process\FilterID         if ($key !== NULL) {
          $return[$key] = $destination;
        }
      }
    }
$targetPath = $this->setPath($targetPath); // set the target path
        if ($this->hasMoved) {
            throw HTTPException::forAlreadyMoved();
        }

        if ($this->isValid()) {
            throw HTTPException::forInvalidFile();
        }

        $name ??= $this->getName();
        $destination = $overwrite ? $targetPath . $name : $this->getDestination($targetPath . $name);

        try {
            $this->hasMoved = move_uploaded_file($this->path, $destination);
        } catch (Exception $e) {
            $error   = error_get_last();
            $message = strip_tags($error['message'] ?? '');

            throw HTTPException::forMoveFailed(basename($this->path)$targetPath$message);
        }

        if ($this->hasMoved === false) {
            
if ([] === $publishers = Publisher::discover($directory)) {
            CLI::write(lang('Publisher.publishMissing', [$directory]));

            return;
        }

        foreach ($publishers as $publisher) {
            if ($publisher->publish()) {
                CLI::write(lang('Publisher.publishSuccess', [
                    get_class($publisher),
                    count($publisher->getPublished()),
                    $publisher->getDestination(),
                ]), 'green');
            } else {
                CLI::error(lang('Publisher.publishFailure', [
                    get_class($publisher),
                    $publisher->getDestination(),
                ]), 'light_gray', 'red');

                foreach ($publisher->getErrors() as $file => $exception) {
                    CLI::write($file);
                    CLI::error($exception->getMessage());
                    CLI::newLine();
                }

    else {
      // Attempt to ensure we always have a bundle.       if ($bundle = $this->getBundle($row)) {
        $row->setDestinationProperty($this->getKey('bundle')$bundle);
      }

      // Stubs might need some required fields filled in.       if ($row->isStub()) {
        $this->processStubRow($row);
      }
      $entity = $this->storage->create($row->getDestination());
      $entity->enforceIsNew();
    }
    return $entity;
  }

  /** * Gets the entity ID of the row. * * @param \Drupal\migrate\Row $row * The row of data. * * @return string * The entity ID for the row that we are importing. */
    // clone the row with an empty set of destination values, and re-add only     // the specified properties.     if (isset($this->configuration['overwrite_properties'])) {
      $empty_destinations = array_intersect($empty_destinations$this->configuration['overwrite_properties']);
      $clone = $row->cloneWithoutDestination();
      foreach ($this->configuration['overwrite_properties'] as $property) {
        $clone->setDestinationProperty($property$row->getDestinationProperty($property));
      }
      $row = $clone;
    }

    foreach ($row->getDestination() as $field_name => $values) {
      $field = $entity->$field_name;
      if ($field instanceof TypedDataInterface) {
        $field->setValue($values);
      }
    }
    foreach ($empty_destinations as $field_name) {
      $entity->$field_name = NULL;
    }

    $this->setRollbackAction($row->getIdMap()$rollback_action);

    

    else {
      // Attempt to set the bundle.       if ($bundle = $this->getBundle($row)) {
        $row->setDestinationProperty($this->getKey('bundle')$bundle);
      }

      // Stubs might need some required fields filled in.       if ($row->isStub()) {
        $this->processStubRow($row);
      }
      $entity = $this->storage->create($row->getDestination());
      $entity->enforceIsNew();
    }

    // We need to update the entity, so that the destination row IDs are     // correct.     $entity = $this->updateEntity($entity$row);
    $entity->isDefaultRevision(TRUE);
    if ($entity instanceof EntityChangedInterface && $entity instanceof ContentEntityInterface) {
      // If we updated any untranslatable fields, update the timestamp for the       // other translations.       /** @var \Drupal\Core\Entity\ContentEntityInterface|\Drupal\Core\Entity\EntityChangedInterface $entity */
      
if ($this->eventManager) {
            $parameters = $this->eventManager->filter(
                'Shopware_Components_Thumbnail_Manager_CreateThumbnail',
                $parameters,
                ['subject' => $this, 'media' => $media]
            );
        }

        foreach ($parameters['sizes'] as $size) {
            $suffix = $size['width'] . 'x' . $size['height'];

            $destinations = $this->getDestination($media$suffix);
            foreach ($destinations as $destination) {
                $this->generator->createThumbnail(
                    $parameters['path'],
                    $destination,
                    $size['width'],
                    $size['height'],
                    $parameters['keepProportions'],
                    $standardQuality
                );
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.