public function __invoke(AdminControllerEvent $event)
 {
     $ordersCount = $this->orders->count();
     $draftsCount = $this->drafts->count();
     $data = ['Orders' => $ordersCount, 'Invoice address drafts' => $draftsCount];
     $event->addViewVariables('orders', ['data' => $data], -1);
 }
 public function __invoke(AdminControllerEvent $event)
 {
     $total = $this->repository->count(['isDraft' => false]);
     $active = $this->repository->count(['status.name' => StatusInterface::ACTIVE]);
     $pending = $this->repository->count(['status.name' => StatusInterface::CREATED]);
     $event->addViewVariables('jobs', ['title' => 'Jobs', 'data' => ['Total jobs' => ['url' => ['lang/admin/jobs', [], true], 'value' => $total], 'Active jobs' => ['url' => ['lang/admin/jobs', [], ['query' => ['status' => 'active']], true], 'value' => $active], 'Pending jobs' => ['url' => ['lang/admin/jobs', [], ['query' => ['status' => 'created']], true], 'value' => $pending]]]);
 }
 public function testIndexAction()
 {
     $event = new AdminControllerEvent(AdminControllerEvent::EVENT_DASHBOARD, $this->target);
     $event->addViewVariables('test', ['testVar' => 'value']);
     $events = $this->getMockBuilder(EventManager::class)->setMethods(['getEvent', 'trigger'])->getMock();
     $events->expects($this->once())->method('getEvent')->with(AdminControllerEvent::EVENT_DASHBOARD, $this->identicalTo($this->target))->willReturn($event);
     $events->expects($this->once())->method('trigger')->with($this->identicalTo($event));
     $services = $this->getServiceManagerMock(['Core/AdminController/Events' => ['service' => $events, 'count_get' => 1]]);
     /* @var \Zend\View\Model\ViewModel $child
      * @var \Zend\View\Model\ViewModel $viewModel */
     $this->target->setServiceLocator($services);
     $viewModel = $this->target->indexAction();
     $this->assertInstanceOf('\\Zend\\View\\Model\\ViewModel', $viewModel);
     $children = $viewModel->getChildren();
     $child = $children[0];
     $this->assertEquals('test', $child->captureTo());
     $this->assertEquals(['test'], $viewModel->getVariable('widgets'));
     $this->assertCount(1, $children);
 }