Example #1
0
 public function copy()
 {
     $new = parent::copy();
     ob_start();
     //copy our new one to its own path.
     $newPath = $new->getNiceDir($new->get('path'));
     $new->copyToPath($newPath);
     $new->set('path', $newPath);
     $new->set('bucket', AMAZON_S3_BUCKET_NAME);
     $new->save();
     ob_end_clean();
     return $new;
 }
Example #2
0
 /**
  * Bulk Copy
  *
  * @param Model $model Model object
  * @param array $ids Array of IDs
  * @return boolean True on success, false on failure
  */
 public function bulkCopy(Model $model, $ids)
 {
     if (!$model->Behaviors->loaded('Copyable')) {
         $model->Behaviors->load('Croogo.Copyable');
     }
     $result = false;
     $ds = $model->getDataSource();
     $ds->begin();
     foreach ($ids as $id) {
         $result = $model->copy($id);
         if (!$result) {
             $ds->rollback();
             break;
         }
     }
     if ($result) {
         $ds->commit();
     }
     return $result;
 }