You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
915 B

2 years ago
  1. <?php namespace WpsMcloud\Actions;
  2. use WpsMcloud\Actions\Convert\Attachment;
  3. use WpsMcloud\Actions\Convert\ReplacerService;
  4. use WpsMcloud\Support\Counters;
  5. class Convert
  6. {
  7. private Attachment $attachment;
  8. private ReplacerService $replacer;
  9. public static int $countProcessedImages = 0;
  10. public static int $countImagesNotFound = 0;
  11. public function __construct()
  12. {
  13. $this->attachment = new Attachment();
  14. $this->replacer = new ReplacerService();
  15. }
  16. public function run()
  17. {
  18. $images = $this->attachment->getImagesWithoutS3MetaData();
  19. echo sprintf('Count for the processing: %d<br>', count($images));
  20. foreach ($images as $post) {
  21. $this->replacer->processImage($post);
  22. }
  23. echo sprintf('Processed: %d<br>', Counters::$processedImages);
  24. echo sprintf('Not found: %d<br>', Counters::$imagesNotFound);
  25. }
  26. }