/**
  * @param \Phpro\Apigility\Doctrine\Bulk\Service\BulkService $bulkService
  * @param \Phpro\Apigility\Doctrine\Bulk\Model\Result $result;
  */
 public function it_should_handle_bulk_actions($bulkService, $result)
 {
     $bulkService->bulk(Argument::any())->willReturn([$result]);
     $response = $this->bulkAction();
     $response->shouldBeAnInstanceOf('Zend\\View\\Model\\JsonModel');
     $response->getVariable(0)->shouldBe($result);
 }
 /**
  * @throws ApiProblem
  */
 public function bulkAction()
 {
     $data = $this->bodyParams();
     if (!is_array($data)) {
         $exception = new ApiProblem(500, 'Invalid body');
         return new JsonModel($exception->toArray());
     }
     $result = $this->bulkService->bulk($data);
     $response = new JsonModel($result);
     return $response;
 }
 /**
  * {@inheritDoc}
  */
 public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
 {
     // Load configuration:
     $serviceManager = $serviceLocator->getServiceLocator();
     $config = $serviceManager->get('Config');
     $config = $config['zf-apigility'][self::CONFIG_NAMESPACE][$requestedName];
     // Load dependencies
     $className = $this->loadEntityClass($config);
     $objectManager = $this->loadObjectManager($serviceManager, $config);
     $hydrator = $this->loadHydrator($serviceManager, $config);
     $listeners = $this->loadListeners($serviceManager, $config);
     // Configure a bulk service
     $bulkService = new BulkService($objectManager, $className, $hydrator);
     if (count($listeners)) {
         foreach ($listeners as $listener) {
             $bulkService->getEventManager()->attach($listener);
         }
     }
     // Initialize controller
     $className = isset($config['entity']) ? $config['class'] : $requestedName;
     $className = $this->normalizeClassname($className);
     $controller = new $className($bulkService);
     return $controller;
 }