Skip to content

Instantly share code, notes, and snippets.

@maximzasorin
Last active October 30, 2015 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximzasorin/2187cffb28c0774b0744 to your computer and use it in GitHub Desktop.
Save maximzasorin/2187cffb28c0774b0744 to your computer and use it in GitHub Desktop.
Transfer image from one object to other for HostCMS
<?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