/**
  * Decide whether to show child digital objects as a compound object based
  * on 'displayAsCompound' toggle and available digital objects.
  *
  * @return boolean
  */
 public function showAsCompoundDigitalObject()
 {
     // Return false if this digital object is not linked directly to an
     // information object
     if (null === $this->informationObjectId) {
         return false;
     }
     // Return false if "show compound" toggle is not set to '1' (yes)
     $showCompoundProp = QubitProperty::getOneByObjectIdAndName($this->id, 'displayAsCompound');
     if (null === $showCompoundProp || '1' != $showCompoundProp->getValue(array('sourceCulture' => true))) {
         return false;
     }
     // Return false if this object has no children with digital objects
     $criteria = new Criteria();
     $criteria->addJoin(QubitInformationObject::ID, QubitDigitalObject::INFORMATION_OBJECT_ID);
     $criteria->add(QubitInformationObject::PARENT_ID, $this->informationObjectId);
     if (0 === count(QubitDigitalObject::get($criteria))) {
         return false;
     }
     return true;
 }
 /**
  * Save a related property and create a new property if a matching one doesn't
  * already exist.
  *
  * @param string $name name of property
  * @param string $value new value to set
  * @param array $options array of options
  * @return QubitInformationObject
  */
 public function saveProperty($name, $value, $options = array())
 {
     // Get existing property if possible
     if (null === ($property = QubitProperty::getOneByObjectIdAndName($this->id, $name, $options))) {
         // Create a new property if required
         $property = new QubitProperty();
         $property->setObjectId($this->id);
         $property->setName($name);
         if (isset($options['scope'])) {
             $property->setScope($options['scope']);
         }
     }
     $property->setValue($value, $options);
     $property->save();
     return $this;
 }