/**
  * Given a record, add all assets it contains to the given manipulation.
  * State can be declared for this record, otherwise the underlying DataObject
  * will be queried for canView() to see if those assets are public
  *
  * @param AssetManipulationList $manipulation Set of manipulations to add assets to
  * @param DataObject $record Record
  * @param string $state One of AssetManipulationList::STATE_* constant values.
  */
 protected function addAssetsFromRecord(AssetManipulationList $manipulation, DataObject $record, $state)
 {
     // Find all assets attached to this record
     $assets = $this->findAssets($record);
     if (empty($assets)) {
         return;
     }
     // Add all assets to this stage
     foreach ($assets as $asset) {
         $manipulation->addAsset($asset, $state);
     }
 }
 /**
  * Helper to count all items in a set
  *
  * @param AssetManipulationList $set
  * @return int
  */
 protected function countItems(AssetManipulationList $set)
 {
     return count($set->getPublicAssets()) + count($set->getProtectedAssets()) + count($set->getDeletedAssets());
 }