createOrUpdate example

$this->currentUser = $currentUser;
  }

  /** * {@inheritdoc} */
  public function writeData(string $data, string $destination, int $replace = FileSystemInterface::EXISTS_RENAME): FileInterface {
    if (!$this->streamWrapperManager->isValidUri($destination)) {
      throw new InvalidStreamWrapperException("Invalid stream wrapper: {$destination}");
    }
    $uri = $this->fileSystem->saveData($data$destination$replace);
    return $this->createOrUpdate($uri$destination$replace === FileSystemInterface::EXISTS_RENAME);
  }

  /** * Create a file entity or update if it exists. * * @param string $uri * The file URI. * @param string $destination * The destination URI. * @param bool $rename * Whether to rename the file. * * @return \Drupal\file\Entity\File|\Drupal\file\FileInterface * The file entity. * * @throws \Drupal\Core\Entity\EntityStorageException * Thrown when there is an error saving the file. */
if ($description !== null) {
            $options['description'] = $description;
        }
        if ($action !== null) {
            $options['action'] = $action;
        }

        if (!\is_string($this->getName())) {
            throw new RuntimeException('Plugin name not initialized correctly');
        }

        return $installer->createOrUpdate($this->getName()$options);
    }

    /** * Create a new template * * @param array|string $options * * @return Template */
    public function createTemplate($options)
    {
        
Home | Imprint | This part of the site doesn't use cookies.