public function __construct(ServiceLocatorInterface $serviceLocator)
 {
     $request = new Request();
     if (is_null($this->userLogged)) {
         if ($request->getHeader('Authorization') == '') {
             $sessionStorage = new SessionStorage("SessaoUsuario");
             $this->authService = new AuthenticationService();
             $this->authService->setStorage($sessionStorage);
             if ($this->getAuthService()->hasIdentity()) {
                 $this->userLogged = $this->getAuthService()->getIdentity();
             } else {
                 return FALSE;
             }
         } else {
             $this->authApiService = $serviceLocator->get('api-identity');
             if ($this->authApiService->getAuthenticationIdentity()) {
                 /** @var \Doctrine\ORM\EntityManager $entityManager */
                 $entityManager = $serviceLocator->get("Doctrine\\ORM\\EntityManager");
                 $userEntity = $entityManager->getRepository("Application\\Entity\\WcUser")->findOneByUsername($this->authApiService->getAuthenticationIdentity()['user_id']);
                 /** @var \Auth\Service\AuthService $authService */
                 $authService = $serviceLocator->get("Auth\\Service\\AuthService");
                 $getArraySession = $authService->getArraySession($userEntity);
                 $this->userLogged = $getArraySession;
             } else {
                 return FALSE;
             }
         }
     }
     return $this->userLogged;
 }
 /**
  * @dataProvider multipartFormDataMethods
  */
 public function testCanDecodeMultipartFormDataRequestsFromStreamsForPutAndPatchOperations($method)
 {
     $request = new ContentNegotiationRequest();
     $request->setMethod($method);
     $request->getHeaders()->addHeaderLine('Content-Type', 'multipart/form-data; boundary=6603ddd555b044dc9a022f3ad9281c20');
     $request->setContentStream('file://' . realpath(__DIR__ . '/TestAsset/multipart-form-data.txt'));
     $event = new MvcEvent();
     $event->setRequest($request);
     $event->setRouteMatch(new RouteMatch(array()));
     $listener = $this->listener;
     $result = $listener($event);
     $parameterData = $event->getParam('ZFContentNegotiationParameterData');
     $params = $parameterData->getBodyParams();
     $this->assertEquals(array('mime_type' => 'md'), $params);
     $files = $request->getFiles();
     $this->assertEquals(1, $files->count());
     $file = $files->get('text');
     $this->assertInternalType('array', $file);
     $this->assertArrayHasKey('error', $file);
     $this->assertArrayHasKey('name', $file);
     $this->assertArrayHasKey('tmp_name', $file);
     $this->assertArrayHasKey('size', $file);
     $this->assertArrayHasKey('type', $file);
     $this->assertEquals('README.md', $file['name']);
     $this->assertRegexp('/^zfc/', basename($file['tmp_name']));
     $this->assertTrue(file_exists($file['tmp_name']));
 }