class SocialGroupHero in Open Social 8.7
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/src/SocialGroupHero.php \Drupal\social_group\SocialGroupHero
- 8.5 modules/social_features/social_group/src/SocialGroupHero.php \Drupal\social_group\SocialGroupHero
- 8.6 modules/social_features/social_group/src/SocialGroupHero.php \Drupal\social_group\SocialGroupHero
- 8.8 modules/social_features/social_group/src/SocialGroupHero.php \Drupal\social_group\SocialGroupHero
- 10.3.x modules/social_features/social_group/src/SocialGroupHero.php \Drupal\social_group\SocialGroupHero
- 10.0.x modules/social_features/social_group/src/SocialGroupHero.php \Drupal\social_group\SocialGroupHero
- 10.1.x modules/social_features/social_group/src/SocialGroupHero.php \Drupal\social_group\SocialGroupHero
- 10.2.x modules/social_features/social_group/src/SocialGroupHero.php \Drupal\social_group\SocialGroupHero
Class SocialGroupHero.
@package Drupal\social_group
Hierarchy
- class \Drupal\social_group\SocialGroupHero
Expanded class hierarchy of SocialGroupHero
1 string reference to 'SocialGroupHero'
- social_group.services.yml in modules/
social_features/ social_group/ social_group.services.yml - modules/social_features/social_group/social_group.services.yml
1 service uses SocialGroupHero
- social_group.hero_image in modules/
social_features/ social_group/ social_group.services.yml - Drupal\social_group\SocialGroupHero
File
- modules/
social_features/ social_group/ src/ SocialGroupHero.php, line 12
Namespace
Drupal\social_groupView source
class SocialGroupHero {
/**
* Config Factory.
*
* @var \Drupal\Core\Config\ConfigFactory
*/
protected $configFactory;
protected $isSmall = FALSE;
/**
* Constructor.
*
* @param \Drupal\Core\Config\ConfigFactory $config_factory
* The injected configfactory.
*/
public function __construct(ConfigFactory $config_factory) {
$this->configFactory = $config_factory;
}
/**
* Function that determines the group hero imagestyle.
*
* @return string
* Of the image / crop style.
*/
public function getGroupHeroCropType() : string {
$settings = $this->configFactory
->get('social_group.settings');
// Return the selected style, or the default one.
return $settings
->get('default_hero') ?? 'hero';
}
/**
* Function that determines the group hero croptype.
*
* @return string
* The crop style.
*/
public function getGroupHeroImageStyle() : string {
return $this
->cropToStyle($this
->getGroupHeroCropType());
}
/**
* Small or not.
*
* @return bool
* Is this considered small.
*/
public function isSmall() : bool {
// Invoke cropToStyle, to get info about the size.
$this
->cropToStyle($this->configFactory
->get('social_group.settings')
->get('default_hero'));
// Return info about the size.
return $this->isSmall;
}
/**
* Function that converts crop type to image style.
*
* @param string $cropType
* The croptype.
*
* @return string
* The associated image style.
*/
protected function cropToStyle($cropType) : string {
$values = [
'hero' => 'social_xx_large',
'hero_small' => 'social_hero_small',
];
switch ($cropType) {
case 'hero_small':
$this->isSmall = TRUE;
default:
}
return $values[$cropType] ?? 'social_xx_large';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SocialGroupHero:: |
protected | property | Config Factory. | |
SocialGroupHero:: |
protected | property | ||
SocialGroupHero:: |
protected | function | Function that converts crop type to image style. | |
SocialGroupHero:: |
public | function | Function that determines the group hero imagestyle. | |
SocialGroupHero:: |
public | function | Function that determines the group hero croptype. | |
SocialGroupHero:: |
public | function | Small or not. | |
SocialGroupHero:: |
public | function | Constructor. |