/**
  * Gets enabled protections for entity as a string.
  *
  * @param \Drupal\userprotect\Entity\ProtectionRuleInterface $entity
  *   The entity the to get protections for.
  *
  * @return string
  *   The enabled protections, comma-separated.
  */
 public function getProtections(ProtectionRuleInterface $entity)
 {
     $all_protections = $entity->getProtections()->getAll();
     $enabled_protections = $entity->getProtections()->getEnabledPlugins();
     if (count($all_protections) == count($enabled_protections)) {
         return $this->t('All');
     }
     return implode(', ', array_map(function ($item) {
         return $item->label();
     }, $enabled_protections));
 }
 /**
  * Tests getProtections().
  */
 protected function testGetProtections()
 {
     $this->assertTrue($this->protectionRule->getProtections() instanceof UserProtectionPluginCollection);
 }