Changed name of Profile entity to Hat
so as not to conflict with Profile or Profile2 module on existing sites
This commit is contained in:
@ -5,14 +5,14 @@ namespace Drupal\zencrm\Plugin\Block;
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
|
||||
/**
|
||||
* Provides a 'ProfileCreator' block.
|
||||
* Provides a 'HatCreator' block.
|
||||
*
|
||||
* @Block(
|
||||
* id = "profile_creator",
|
||||
* admin_label = @Translation("Profile creator"),
|
||||
* id = "hat_creator",
|
||||
* admin_label = @Translation("Hat creator"),
|
||||
* )
|
||||
*/
|
||||
class ProfileCreator extends BlockBase {
|
||||
class HatCreator extends BlockBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@ -21,15 +21,15 @@ class ProfileCreator extends BlockBase {
|
||||
$person_id = \Drupal::routeMatch()->getParameter('person')->id();
|
||||
$markup = "";
|
||||
|
||||
// Only offer profile creation on profiles they don't already have.
|
||||
$profile_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('profile');
|
||||
foreach($profile_types as $id => $type) {
|
||||
$profiles = \Drupal::entityTypeManager()
|
||||
->getStorage('profile')
|
||||
// Only offer hat creation on hats they don't already have.
|
||||
$hat_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('hat');
|
||||
foreach($hat_types as $id => $type) {
|
||||
$hats = \Drupal::entityTypeManager()
|
||||
->getStorage('hat')
|
||||
->loadByProperties(['type' => $id, 'person' => $person_id]);
|
||||
if (!reset($profiles)) {
|
||||
if (!reset($hats)) {
|
||||
$label = $type['label'];
|
||||
$markup .= "<p><a class='use-ajax' data-dialog-type='modal' href='/zencrm/profile/add/$id/$person_id'>Create $label Profile</a></p>";
|
||||
$markup .= "<p><a class='use-ajax' data-dialog-type='modal' href='/zencrm/hat/add/$id/$person_id'>Create $label Hat</a></p>";
|
||||
}
|
||||
}
|
||||
return [
|
Reference in New Issue
Block a user