public function FollowTaxonomyActivityContext::isValidEntity in Open Social 10.0.x
Same name and namespace in other branches
- 10.3.x modules/social_features/social_follow_taxonomy/src/Plugin/ActivityContext/FollowTaxonomyActivityContext.php \Drupal\social_follow_taxonomy\Plugin\ActivityContext\FollowTaxonomyActivityContext::isValidEntity()
- 10.1.x modules/social_features/social_follow_taxonomy/src/Plugin/ActivityContext/FollowTaxonomyActivityContext.php \Drupal\social_follow_taxonomy\Plugin\ActivityContext\FollowTaxonomyActivityContext::isValidEntity()
- 10.2.x modules/social_features/social_follow_taxonomy/src/Plugin/ActivityContext/FollowTaxonomyActivityContext.php \Drupal\social_follow_taxonomy\Plugin\ActivityContext\FollowTaxonomyActivityContext::isValidEntity()
Determines if the entity is valid for this context.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity object.
Return value
bool TRUE if it's valid entity.
Overrides ActivityContextBase::isValidEntity
File
- modules/
social_features/ social_follow_taxonomy/ src/ Plugin/ ActivityContext/ FollowTaxonomyActivityContext.php, line 171
Class
- FollowTaxonomyActivityContext
- Provides a 'FollowTaxonomyActivityContext' activity context plugin.
Namespace
Drupal\social_follow_taxonomy\Plugin\ActivityContextCode
public function isValidEntity(EntityInterface $entity) {
if (!$entity instanceof ContentEntityInterface) {
return FALSE;
}
// Check entity type.
switch ($entity
->getEntityTypeId()) {
case 'node':
foreach ($this
->getListOfTagsFields() as $field_name) {
if ($entity
->hasField($field_name)) {
return TRUE;
}
}
return FALSE;
}
return FALSE;
}