Merge branch 'dev'
This commit is contained in:
commit
998f72f505
@ -23,6 +23,7 @@ class ContextualMenu extends BlockBase {
|
||||
*/
|
||||
public function build() {
|
||||
$route_name = \Drupal::routeMatch()->getRouteName();
|
||||
\Drupal::logger('my_module')->error(\Drupal::routeMatch()->getParameter('oc_actor')->bundle());
|
||||
if ($route_name == 'entity.oc_actor.canonical' && \Drupal::routeMatch()->getParameter('oc_actor')->bundle() == 'client' ) {
|
||||
$markup = $this->actorPage();
|
||||
$build = [];
|
||||
@ -41,20 +42,20 @@ class ContextualMenu extends BlockBase {
|
||||
*/
|
||||
private function actorPage() {
|
||||
$actor_id = \Drupal::routeMatch()->getParameter('oc_actor')->id();
|
||||
$current_path = \Drupal::service('path.current')->getPath();
|
||||
return $this->generateLinksForAddingNewActivities("Add activity", ['actor_id' => $actor_id, 'destination' => $current_path]);
|
||||
return $this->generateLinksForAddingNewActivities("Add activity", $actor_id);
|
||||
}
|
||||
/**
|
||||
* returns html markup.
|
||||
*/
|
||||
private function generateLinksForAddingNewActivities($title, $query = []) {
|
||||
private function generateLinksForAddingNewActivities($title, $actor_id) {
|
||||
$title = t($title);
|
||||
$markup = "<br /><p><strong>$title: </strong>";
|
||||
$allActivityTypes = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_activity');
|
||||
$redirect_destination = \Drupal\Core\Url::fromRoute("entity.oc_actor.canonical", ['oc_actor' => $actor_id])->toString();
|
||||
foreach($allActivityTypes as $machine_name => $activityType) {
|
||||
$label = $activityType['label'];
|
||||
$url = \Drupal\Core\Url::fromRoute("entity.oc_activity.add_form", ['oc_activity_type' => $machine_name]);
|
||||
$url->setOption('query', $query);
|
||||
$url->setOption('query', ['actor_id' => $actor_id, 'destination' => $redirect_destination]);
|
||||
$link = \Drupal\Core\Link::fromTextAndUrl($label, $url)->toString();
|
||||
$markup .= " $link";
|
||||
}
|
||||
|
Reference in New Issue
Block a user