Last active
October 30, 2015 07:10
-
-
Save maximzasorin/2187cffb28c0774b0744 to your computer and use it in GitHub Desktop.
Transfer image from one object to other for HostCMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SomeTransferClass { | |
// ... | |
private function _transferImages($sourceObject, $destObject) | |
{ | |
if (is_file($sourceObject->getLargeFilePath())) | |
{ | |
try | |
{ | |
$destObject->createDir(); | |
$destObject->image_large = $destObject->getTableName() . '_' . $destObject->id . '.' . | |
Core_File::getExtension($sourceObject->image_large); | |
Core_File::copy($sourceObject->getLargeFilePath(), $destObject->getLargeFilePath()); | |
$destObject->save(); | |
} | |
catch (Exception $e) {} | |
} | |
if (is_file($sourceObject->getSmallFilePath())) | |
{ | |
try | |
{ | |
$destObject->createDir(); | |
$destObject->image_small = 'small_' . $destObject->getTableName() . '_' . $destObject->id . '.' . | |
Core_File::getExtension($sourceObject->image_small); | |
Core_File::copy($sourceObject->getSmallFilePath(), $destObject->getSmallFilePath()); | |
$destObject->save(); | |
} | |
catch (Exception $e) {} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment