/**
  * Build the user activity dashboard with an ActivitySummaryEvent.
  *
  * @return \Message\Cog\HTTP\Response
  */
 public function index()
 {
     $user = $this->get('user.current');
     $event = new ActivitySummaryEvent();
     $event->setUser($user);
     $this->get('event.dispatcher')->dispatch(ActivitySummaryEvent::DASHBOARD_ACTIVITY_SUMMARY, $event);
     $data = ['activities' => $event->getActivities()];
     return $this->render('Message:Mothership:User::module:dashboard:user-summary', ['user' => $user, 'activities' => $data['activities']]);
 }
 /**
  * Add the user's last edited product and order into the user summary
  * dashboard block.
  *
  * @param  ActivitySummaryEvent $event
  */
 public function buildDashboardBlockUserSummary(ActivitySummaryEvent $event)
 {
     $productID = $this->get('db.query')->run("\n\t\t\tSELECT product_id\n\t\t\tFROM product\n\t\t\tWHERE :userID?b IS NULL OR updated_by = :userID?i\n\t\t\tORDER BY updated_at DESC\n\t\t\tLIMIT 1\n\t\t", ['userID' => $event->getUser()->id]);
     if (count($productID)) {
         $product = $this->get('product.loader')->getByID($productID[0]->product_id);
         if ($product) {
             $url = $this->get('routing.generator')->generate('ms.commerce.product.edit.attributes', ['productID' => $product->id], UrlGeneratorInterface::ABSOLUTE_PATH);
             $event->addActivity(new Activity('Last edited product', $product->authorship->updatedAt(), $product->name, $url));
         }
     }
     $orderID = $this->get('db.query')->run("\n\t\t\tSELECT order_id\n\t\t\tFROM order_summary\n\t\t\tWHERE :userID?b IS NULL OR updated_by = :userID?i\n\t\t\tORDER BY updated_at DESC\n\t\t\tLIMIT 1\n\t\t", ['userID' => $event->getUser()->id]);
     if (count($orderID)) {
         $order = $this->get('order.loader')->getByID($orderID[0]->order_id);
         if ($order) {
             $url = $this->get('routing.generator')->generate('ms.commerce.order.detail.view', ['orderID' => $order->id], UrlGeneratorInterface::ABSOLUTE_PATH);
             $event->addActivity(new Activity('Last edited order', $order->authorship->updatedAt(), '#' . $order->id, $url));
         }
     }
 }
 /**
  * Add the user's last edited page into the user summary dashboard block.
  *
  * @param  ActivitySummaryEvent $event
  */
 public function buildDashboardBlockUserSummary(ActivitySummaryEvent $event)
 {
     $pageID = $this->get('db.query')->run("\n\t\t\tSELECT page_id\n\t\t\tFROM page\n\t\t\tWHERE updated_by = :userID?i\n\t\t\tORDER BY updated_at DESC\n\t\t\tLIMIT 1\n\t\t", ['userID' => $event->getUser()->id]);
     if (count($pageID)) {
         $page = $this->get('cms.page.loader')->getByID($pageID[0]->page_id);
         if ($page) {
             $event->addActivity(new Activity('Last edited page', $page->authorship->updatedAt(), $page->title, $this->get('routing.generator')->generate('ms.cp.cms.edit', ['pageID' => $page->id], UrlGeneratorInterface::ABSOLUTE_URL)));
         }
     }
 }