Author: david
Date: Tue Jul 19 16:02:00 2011
New Revision: 9334

Log:
Get asset path from digital object, don't pass parent.  Make getAssetPath() 
non-static method.  Update calls to getAssetPath()

Modified:
   trunk/lib/model/QubitDigitalObject.php

Modified: trunk/lib/model/QubitDigitalObject.php
==============================================================================
--- trunk/lib/model/QubitDigitalObject.php      Tue Jul 19 15:46:58 2011        
(r9333)
+++ trunk/lib/model/QubitDigitalObject.php      Tue Jul 19 16:02:00 2011        
(r9334)
@@ -413,17 +413,6 @@
       throw new sfException('Not a valid filename');
     }
 
-    if (null == ($parentInformationObject = $this->getInformationObject()))
-    {
-      $parentInformationObject = $this->parent->getInformationObject();
-    }
-
-    // Fail if no valid parent information object found
-    if (null == $parentInformationObject)
-    {
-      throw new sfException('No valid parent was set for this digital 
object.');
-    }
-
     // Fail if asset's intended usage is a reference or thumbnail object and
     // it's *not* an image mimetype
     $allowed = QubitDigitalObject::isImageFile($asset->getName()) || 
QubitDigitalObject::isAudioFile($asset->getName());
@@ -442,7 +431,7 @@
     }
 
     // Upload paths for this information object / digital object
-    $infoObjectPath = 
QubitDigitalObject::getAssetPathfromParent($parentInformationObject);
+    $infoObjectPath = $this->getAssetPath();
     $filePath       = sfConfig::get('sf_web_dir').$infoObjectPath.'/';
     $relativePath   = $infoObjectPath.'/';
     $filePathName   = $filePath.$cleanFileName;
@@ -766,22 +755,22 @@
    * we break up information object path by using first and second digits of
    * the information object id as sub-directories (e.g. uploads/3/2/3235/).
    *
-   * @param mixed    Parent (QubitDigitalObject or QubitInformationObject)
    * @return string  asset file path
    */
-  public static function getAssetPathfromParent($parent)
+  public function getAssetPath()
   {
-    if (get_class($parent) == 'QubitDigitalObject')
+    if (isset($this->informationObject))
     {
-      $infoObject = $parent->getAncestorInformationObject();
+      $infoObject = $this->informationObject;
     }
-    else if (get_class($parent) == 'QubitInformationObject')
+    else if (isset($this->parent))
     {
-      $infoObject = $parent;
+      $infoObject = $this->parent->informationObject;
     }
-    else
+    
+    if (!isset($infoObject))
     {
-      throw new sfException('Invalid class "'.get_class($parent).'" for 
$parent');
+      throw new sfException('Couldn\'t find related information object for 
digital object');
     }
 
     $infoObjectId = (string) $infoObject->id;
@@ -1084,7 +1073,7 @@
       $newDigiObject->save();
 
       // Derive new file path based on newInfoObject
-      $assetPath = self::getAssetPathfromParent($newInfoObject);
+      $assetPath = $newDigiObject->getAssetPath();
       $createPath = '';
       foreach (explode('/', $assetPath) as $d)
       {

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to