Changed path for adding hat to /zencrm/hat/{person_id}/....

Because the person id needs to be in third place in the URL, so that it filters the entity reference view for the contact details. But the second place cannot be "person" as then it would try to render the person blocks on th page.
This commit is contained in:
naomi 2018-04-12 12:06:51 +02:00
parent 607941c725
commit 2cf897c92b
3 changed files with 6 additions and 6 deletions

View File

@ -15,9 +15,9 @@ class HatController extends ControllerBase {
* @return string
* Return Hello string.
*/
public function createHatForPerson($type, $person_id) {
public function createHatForPerson($person_id, $hat_type_id) {
$values = array(
'type' => $type,
'type' => $hat_type_id,
'person' => $person_id
);

View File

@ -25,13 +25,13 @@ class HatCreator extends BlockBase {
// 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) {
foreach($hat_types as $hat_type_id => $type) {
$hats = \Drupal::entityTypeManager()
->getStorage('hat')
->loadByProperties(['type' => $id, 'person' => $person_id]);
->loadByProperties(['type' => $hat_type_id, 'person' => $person_id]);
if (!reset($hats)) {
$label = $type['label'];
$markup .= "<p><a class='use-ajax' data-dialog-type='modal' href='/zencrm/hat/add/$id/$person_id?destination=/zencrm/person/$person_id'>Add a $label Hat</a></p>";
$markup .= "<p><a class='use-ajax' data-dialog-type='modal' href='/zencrm/hat/$person_id/add/$hat_type_id?destination=/zencrm/person/$person_id'>Add a $label Hat</a></p>";
}
}
return [

View File

@ -1,5 +1,5 @@
zencrm.hat.create:
path: '/zencrm/hat/add/{type}/{person_id}'
path: '/zencrm/hat/{person_id}/add/{hat_type_id}'
defaults:
_controller: '\Drupal\zencrm\Controller\HatController::createHatForPerson'
_title: 'Add New Hat'