/**
  * {@inheritdoc}
  */
 public function getCacheFragments($identifier)
 {
     if (is_array($identifier)) {
         // Like in https://example.org/api/articles/1,2,3.
         $identifier = implode(ResourceInterface::IDS_SEPARATOR, $identifier);
     }
     $fragments = new ArrayCollection(array('resource' => CacheDecoratedResource::serializeKeyValue($this->pluginId, $this->canonicalPath($identifier)), 'entity' => CacheDecoratedResource::serializeKeyValue($this->entityType, $this->getEntityIdByFieldId($identifier))));
     $options = $this->getOptions();
     switch ($options['renderCache']['granularity']) {
         case DRUPAL_CACHE_PER_USER:
             if ($uid = $this->getAccount()->uid) {
                 $fragments->set('user_id', (int) $uid);
             }
             break;
         case DRUPAL_CACHE_PER_ROLE:
             $fragments->set('user_role', implode(',', $this->getAccount()->roles));
             break;
     }
     return $fragments;
 }
 /**
  * {@inheritdoc}
  */
 public function getCacheFragments($identifier)
 {
     // If we are trying to get the context for multiple ids, join them.
     if (is_array($identifier)) {
         $identifier = implode(',', $identifier);
     }
     $fragments = new ArrayCollection(array('resource' => CacheDecoratedResource::serializeKeyValue($this->pluginId, $this->canonicalPath($identifier))));
     $options = $this->getOptions();
     switch ($options['renderCache']['granularity']) {
         case DRUPAL_CACHE_PER_USER:
             if ($uid = $this->getAccount()->uid) {
                 $fragments->set('user_id', (int) $uid);
             }
             break;
         case DRUPAL_CACHE_PER_ROLE:
             $fragments->set('user_role', implode(',', $this->getAccount()->roles));
             break;
     }
     return $fragments;
 }