You are here

protected function Image::saveImage in SimpleAds 8

Save image as a file entity.

2 calls to Image::saveImage()
Image::createFormSubmit in src/Plugin/SimpleAds/Type/Image.php
Create an ad.
Image::updateFormSubmit in src/Plugin/SimpleAds/Type/Image.php
Update an ad.

File

src/Plugin/SimpleAds/Type/Image.php, line 94

Class

Image
Image Ad type.

Namespace

Drupal\simpleads\Plugin\SimpleAds\Type

Code

protected function saveImage($fid) {
  $file = File::load($fid);
  $file
    ->setPermanent();
  $file
    ->save();
  $file_usage = \Drupal::service('file.usage');
  $file_usage
    ->add($file, 'simpleads', 'file', $fid);
  return $fid;
}