Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- foreach ( $Offers as $offer )
- {
- $localImages = array();
- foreach( $offer->getOriginalImages() as $image )
- {
- $pathParts = pathinfo( $image );
- $fileName = $pathParts['basename'];
- $webPath = $photosDir . '/' . $offer->getCompany()->getId() . '/' . $offer->getId() . '/o/';
- $localDir = $webDir . $webPath;
- $localImage = $localDir . $fileName;
- $webImage = $webPath . $fileName;
- if ( ! is_dir( $localDir ) ) {
- mkdir( $localDir, 0777, TRUE );
- }
- try {
- $this->stopwatch->start( 'copy image' );
- $cp = copy( $image, $localImage );
- $event = $this->stopwatch->stop( 'copy image' );
- $periods = $event->getPeriods();
- $period = array_pop( $periods );
- echo 'copy:';
- var_dump( $period->getDuration() / 1000 );
- $this->stopwatch->start( 'warmup cache' );
- $this->warmUpImageCache( $localImage, $webImage );
- $event = $this->stopwatch->stop( 'warmup cache' );
- $periods = $event->getPeriods();
- $period = array_pop( $periods );
- echo 'cache:';
- var_dump( $period->getDuration() / 1000 );
- }
- catch (\ErrorException $e) {
- var_dump( $e->getMessage() );
- $this->logger->error( sprintf( '%s : OfferId - %s', $e->getMessage(), $offer->getId() ) );
- }
- if ( $cp ) {
- $localImages[] = $webImage;
- }
- }
- $offer->setImages( $localImages );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement