public function load()
 {
     $file = file_get_contents(__DIR__ . '/data/store.json');
     $fileData = json_decode($file);
     foreach ($fileData as $data) {
         $entity = new Store();
         $entity->setName($data->name);
         $entity->setUser($data->{'user-id'});
         $entity->save();
         if (!$entity->save()) {
             throw new \Exception('Save fail: ' . implode("\n", $entity->getMessages()));
         }
     }
 }
 /**
      * @SWG\Post(
      *     path="/stores",
      *     tags={"Store"},
      *     operationId="addStore",
      *     summary="Crear tienda",
      *     description="
     La tienda pertencen a un usuario existente.
     ''name'' nombre de la tienda.
     ''user-id'' referencia a un id del servicio usuarios.",
      *     consumes={"application/json"},
      *     produces={"application/json"},
      *     @SWG\Parameter(
      *         name="body",
      *         in="body",
      *         required=true,
      *         @SWG\Schema(ref="#/definitions/create_store")
      *     ),
      *     @SWG\Response(
      *         response=201,
      *         description="OK",
      *         @SWG\Schema(ref="#/definitions/store")
      *     ),
      *     @SWG\Response(
      *         response=400,
      *         description="Bad Request",
      *         @SWG\Schema(ref="#/definitions/error")
      *     ),
      *     @SWG\Response(
      *         response=403,
      *         description="Forbidden",
      *         @SWG\Schema(ref="#/definitions/error")
      *     )
      * )
      **/
 public function addAction()
 {
     $request = $this->request;
     if (!$request->isPost()) {
         return $this->methodNotAllow();
     }
     $rawBody = json_decode($request->getRawBody());
     $store = new Store();
     $store->setName($rawBody->data->name);
     $store->setUser((int) $rawBody->data->{'user-id'});
     $success = $store->create();
     if (false == $success) {
         return $this->modelBadRequest($store, $rawBody);
     }
     return $this->modelsResponse($store);
 }