trimString($values['name'], 255); } // Start a new asset entity with the provided values. /** @var \Drupal\asset\Entity\AssetInterface $asset */ $asset = Asset::create($values); // Track which quick form created the entity. $asset->quick[] = $this->getQuickId(); // Save the asset. $asset->save(); // Display a message with a link to the asset. $message = $this->t('Asset created: @name', [':url' => $asset->toUrl()->toString(), '@name' => $asset->label()]); $this->messenger->addStatus($message); // Return the asset entity. return $asset; } }