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,9 +5,9 @@ namespace Drupal\zencrm\Controller;
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
|
||||
/**
|
||||
* Class ProfileController.
|
||||
* Class HatController.
|
||||
*/
|
||||
class ProfileController extends ControllerBase {
|
||||
class HatController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* Hello.
|
||||
@ -15,18 +15,18 @@ class ProfileController extends ControllerBase {
|
||||
* @return string
|
||||
* Return Hello string.
|
||||
*/
|
||||
public function createProfileForPerson($type, $person_id) {
|
||||
public function createHatForPerson($type, $person_id) {
|
||||
$values = array(
|
||||
'type' => $type,
|
||||
'person' => $person_id
|
||||
);
|
||||
|
||||
$node = \Drupal::entityTypeManager()
|
||||
->getStorage('profile')
|
||||
->getStorage('hat')
|
||||
->create($values);
|
||||
|
||||
$form = \Drupal::entityTypeManager()
|
||||
->getFormObject('profile', 'default')
|
||||
->getFormObject('hat', 'default')
|
||||
->setEntity($node);
|
||||
return \Drupal::formBuilder()->getForm($form);
|
||||
}
|
@ -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