You are here

public function Crop::postSave in Crop API 8

Same name and namespace in other branches
  1. 8.2 src/Entity/Crop.php \Drupal\crop\Entity\Crop::postSave()

Acts on a saved entity before the insert or update hook is invoked.

Used after the entity is saved, but before invoking the insert or update hook. Note that in case of translatable content entities this callback is only fired on their current translation. It is up to the developer to iterate over all translations if needed.

Parameters

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.

bool $update: TRUE if the entity has been updated, or FALSE if it has been inserted.

Overrides ContentEntityBase::postSave

File

src/Entity/Crop.php, line 214

Class

Crop
Defines the crop entity class.

Namespace

Drupal\crop\Entity

Code

public function postSave(EntityStorageInterface $storage, $update = TRUE) {
  parent::postSave($storage, $update);

  // If you are manually generating your image derivatives instead of waiting
  // for them to be generated on the fly, because you are using a cloud
  // storage service (like S3), then you may not want your image derivatives
  // to be flushed. If they are you could end up serving 404s during the time
  // between the crop entity being saved and the image derivative being
  // manually generated and pushed to your cloud storage service. In that
  // case, set this configuration variable to false.
  $flush_derivative_images = \Drupal::config('crop.settings')
    ->get('flush_derivative_images');
  if ($flush_derivative_images) {
    image_path_flush($this->uri->value);
  }
}