当前位置: 首页>>代码示例>>PHP>>正文


PHP SaverInterface::save方法代码示例

本文整理汇总了PHP中Akeneo\Component\StorageUtils\Saver\SaverInterface::save方法的典型用法代码示例。如果您正苦于以下问题:PHP SaverInterface::save方法的具体用法?PHP SaverInterface::save怎么用?PHP SaverInterface::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Akeneo\Component\StorageUtils\Saver\SaverInterface的用法示例。


在下文中一共展示了SaverInterface::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * {@inheritdoc}
  */
 public function store(\SplFileInfo $localFile, $destFsAlias, $deleteRawFile = false)
 {
     $filesystem = $this->mountManager->getFilesystem($destFsAlias);
     $file = $this->factory->createFromRawFile($localFile, $destFsAlias);
     $error = sprintf('Unable to move the file "%s" to the "%s" filesystem.', $localFile->getPathname(), $destFsAlias);
     if (false === ($resource = fopen($localFile->getPathname(), 'r'))) {
         throw new FileTransferException($error);
     }
     try {
         $options = [];
         $mimeType = $file->getMimeType();
         if (null !== $mimeType) {
             $options['ContentType'] = $mimeType;
         }
         $isFileWritten = $filesystem->writeStream($file->getKey(), $resource, $options);
     } catch (FileExistsException $e) {
         throw new FileTransferException($error, $e->getCode(), $e);
     }
     if (false === $isFileWritten) {
         throw new FileTransferException($error);
     }
     $this->saver->save($file);
     if (true === $deleteRawFile) {
         $this->deleteRawFile($localFile);
     }
     return $file;
 }
开发者ID:SamirBoulil,项目名称:pim-community-dev,代码行数:30,代码来源:FileStorer.php

示例2: move

 /**
  * {@inheritdoc}
  */
 public function move(FileInterface $file, $srcFsAlias, $destFsAlias)
 {
     $isFileMoved = $this->mountManager->move(sprintf('%s://%s', $srcFsAlias, $file->getKey()), sprintf('%s://%s', $destFsAlias, $file->getKey()));
     if (!$isFileMoved) {
         throw new FileTransferException(sprintf('Impossible to move the file "%s" from "%s" to "%s".', $file->getKey(), $srcFsAlias, $destFsAlias));
     }
     $file->setStorage($destFsAlias);
     $this->saver->save($file);
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:12,代码来源:FileMover.php

示例3: postAction

 /**
  * Saves a history item, by creating a new one if the page is visited for
  * the first time, or by updating an existing one if the user has already
  * visited the page.
  *
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function postAction(Request $request)
 {
     $history = json_decode($request->getContent(), true);
     $historyItem = $this->findOrCreate($this->getUser(), $history['url']);
     $historyItem->setTitle(json_encode($history['title']));
     $historyItem->doUpdate();
     $this->saver->save($historyItem);
     return new JsonResponse();
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:18,代码来源:NavigationHistoryController.php

示例4: onSuccess

 /**
  * Call when form is valid
  *
  * @param GroupInterface $group
  */
 protected function onSuccess(GroupInterface $group)
 {
     $appendProducts = $this->form->get('appendProducts')->getData();
     $removeProducts = $this->form->get('removeProducts')->getData();
     $options = ['add_products' => $appendProducts, 'remove_products' => $removeProducts];
     if ($group->getType()->isVariant()) {
         $options['copy_values_to_products'] = true;
     }
     $this->groupSaver->save($group, $options);
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:15,代码来源:GroupHandler.php

示例5: toggleAction

 /**
  * Activate/Deactivate a currency
  *
  * @param Currency $currency
  *
  * @AclAncestor("pim_enrich_currency_toggle")
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function toggleAction(Currency $currency)
 {
     try {
         $currency->toggleActivation();
         $this->currencySaver->save($currency);
         $this->addFlash('success', 'flash.currency.updated');
     } catch (\Exception $e) {
         $this->addFlash('error', 'flash.error ocurred');
     }
     return $this->redirect($this->generateUrl('pim_enrich_currency_index'));
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:19,代码来源:CurrencyController.php

示例6: removeAttributeAction

 /**
  * Remove an attribute form a variant group
  *
  * @param string $code        The variant group code
  * @param int    $attributeId The attribute id
  *
  * @AclAncestor("pim_enrich_group_remove_attribute")
  *
  * @throws NotFoundHttpException If variant group or attribute is not found or the user cannot see it
  *
  * @return JsonResponse
  */
 public function removeAttributeAction($code, $attributeId)
 {
     $group = $this->findVariantGroupOr404($code);
     $attribute = $this->findAttributeOr404($attributeId);
     $template = $group->getProductTemplate();
     if (null !== $template) {
         $this->templateBuilder->removeAttribute($template, $attribute);
         $this->groupSaver->save($group);
     }
     return new JsonResponse();
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:23,代码来源:VariantGroupAttributeController.php

示例7: addAttributes

 /**
  * Add attributes to a group
  *
  * @param AttributeGroupInterface $group
  * @param AttributeInterface[]    $attributes
  */
 public function addAttributes(AttributeGroupInterface $group, $attributes)
 {
     $maxOrder = $group->getMaxAttributeSortOrder();
     foreach ($attributes as $attribute) {
         $maxOrder++;
         $attribute->setSortOrder($maxOrder);
         $group->addAttribute($attribute);
     }
     $this->attributeSaver->saveAll($attributes);
     $this->groupSaver->save($group);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:17,代码来源:AttributeGroupManager.php

示例8: process

 /**
  * {@inheritdoc}
  */
 public function process($entity)
 {
     $this->form->setData($entity);
     if ($this->request->isMethod('POST')) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             $this->saver->save($entity);
             return true;
         }
     }
     return false;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:15,代码来源:BaseHandler.php

示例9: postRemove

 /**
  * @param RemoveEvent $event
  */
 public function postRemove(RemoveEvent $event)
 {
     $author = '';
     $subject = $event->getSubject();
     if (null !== ($token = $this->tokenStorage->getToken()) && $this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         $author = $token->getUser()->getUsername();
     }
     $previousVersion = $this->versionRepository->getNewestLogEntry(ClassUtils::getClass($subject), $event->getSubjectId());
     $version = $this->versionFactory->create(ClassUtils::getClass($subject), $event->getSubjectId(), $author, 'Deleted');
     $version->setVersion(null !== $previousVersion ? $previousVersion->getVersion() + 1 : 1)->setSnapshot(null !== $previousVersion ? $previousVersion->getSnapshot() : [])->setChangeset([]);
     $this->versionSaver->save($version);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:15,代码来源:AddRemoveVersionSubscriber.php

示例10: toggleAction

 /**
  * Activate/Deactivate a currency
  *
  * @param Currency $currency
  *
  * @AclAncestor("pim_enrich_currency_toggle")
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function toggleAction(Currency $currency)
 {
     try {
         $currency->toggleActivation();
         $this->currencySaver->save($currency);
         $this->request->getSession()->getFlashBag()->add('success', new Message('flash.currency.updated'));
     } catch (LinkedChannelException $e) {
         $this->request->getSession()->getFlashBag()->add('error', new Message('flash.currency.error.linked_to_channel'));
     } catch (\Exception $e) {
         $this->request->getSession()->getFlashBag()->add('error', new Message('flash.error ocurred'));
     }
     return new RedirectResponse($this->router->generate('pim_enrich_currency_index'));
 }
开发者ID:userz58,项目名称:pim-community-dev,代码行数:22,代码来源:CurrencyController.php

示例11: notify

 /**
  * {@inheritdoc}
  */
 public function notify(NotificationInterface $notification, array $users)
 {
     $userNotifications = [];
     foreach ($users as $user) {
         try {
             $user = is_object($user) ? $user : $this->userProvider->loadUserByUsername($user);
             $userNotifications[] = $this->userNotifFactory->createUserNotification($notification, $user);
         } catch (UsernameNotFoundException $e) {
             continue;
         }
     }
     $this->notificationSaver->save($notification);
     $this->userNotifsSaver->saveAll($userNotifications);
     return $this;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:18,代码来源:Notifier.php

示例12: setJobConfiguration

 /**
  * Save the job configuration
  *
  * @param string $configuration
  */
 protected function setJobConfiguration($configuration)
 {
     $jobExecution = $this->stepExecution->getJobExecution();
     $massEditJobConf = $this->jobConfigurationRepo->findOneBy(['jobExecution' => $jobExecution]);
     $massEditJobConf->setConfiguration($configuration);
     $this->jobConfigurationSaver->save($massEditJobConf);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:12,代码来源:VariantGroupCleaner.php

示例13: removeAttributeAction

 /**
  * Remove an attribute
  *
  * @param int $familyId
  * @param int $attributeId
  *
  * @AclAncestor("pim_enrich_family_edit_attributes")
  *
  * @throws DeleteException
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function removeAttributeAction($familyId, $attributeId)
 {
     $family = $this->findOr404('PimCatalogBundle:Family', $familyId);
     $attribute = $this->findOr404($this->attributeClass, $attributeId);
     if (false === $family->hasAttribute($attribute)) {
         throw new DeleteException($this->getTranslator()->trans('flash.family.attribute not found'));
     } elseif (AttributeTypes::IDENTIFIER === $attribute->getAttributeType()) {
         throw new DeleteException($this->getTranslator()->trans('flash.family.identifier not removable'));
     } elseif ($attribute === $family->getAttributeAsLabel()) {
         throw new DeleteException($this->getTranslator()->trans('flash.family.label attribute not removable'));
     } else {
         $family->removeAttribute($attribute);
         foreach ($family->getAttributeRequirements() as $requirement) {
             if ($requirement->getAttribute() === $attribute) {
                 $family->removeAttributeRequirement($requirement);
                 $this->getManagerForClass(ClassUtils::getClass($requirement))->remove($requirement);
             }
         }
         $this->familySaver->save($family);
     }
     if ($this->getRequest()->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return $this->redirectToRoute('pim_enrich_family_edit', ['id' => $family->getId()]);
     }
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:38,代码来源:FamilyController.php

示例14: removeAttributeAction

 /**
  * Remove an attribute
  *
  * @param int $familyId
  * @param int $attributeId
  *
  * @AclAncestor("pim_enrich_family_edit_attributes")
  *
  * @throws DeleteException
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function removeAttributeAction($familyId, $attributeId)
 {
     $family = $this->familyRepository->find($familyId);
     if (null === $family) {
         throw new NotFoundHttpException(sprintf('%s entity not found', $this->familyClass));
     }
     $attribute = $this->attributeRepo->find($attributeId);
     if (null === $attribute) {
         throw new NotFoundHttpException(sprintf('%s entity not found', $this->attributeClass));
     }
     if (false === $family->hasAttribute($attribute)) {
         throw new DeleteException($this->translator->trans('flash.family.attribute not found'));
     } elseif (AttributeTypes::IDENTIFIER === $attribute->getAttributeType()) {
         throw new DeleteException($this->translator->trans('flash.family.identifier not removable'));
     } elseif ($attribute === $family->getAttributeAsLabel()) {
         throw new DeleteException($this->translator->trans('flash.family.label attribute not removable'));
     } else {
         $family->removeAttribute($attribute);
         foreach ($family->getAttributeRequirements() as $requirement) {
             if ($requirement->getAttribute() === $attribute) {
                 $family->removeAttributeRequirement($requirement);
                 $this->doctrine->getManagerForClass(ClassUtils::getClass($requirement))->remove($requirement);
             }
         }
         $this->familySaver->save($family);
     }
     if ($this->request->isXmlHttpRequest()) {
         return new Response('', 204);
     } else {
         return new RedirectResponse($this->router->generate('pim_enrich_family_edit', ['id' => $family->getId()]));
     }
 }
开发者ID:userz58,项目名称:pim-community-dev,代码行数:44,代码来源:FamilyController.php

示例15: updateAction

 /**
  * Update product
  *
  * @param Request $request
  * @param integer $id
  *
  * @Template("PimEnrichBundle:Product:edit.html.twig")
  * @AclAncestor("pim_enrich_product_index")
  * @return RedirectResponse
  */
 public function updateAction(Request $request, $id)
 {
     $product = $this->findProductOr404($id);
     $this->productManager->ensureAllAssociationTypes($product);
     $form = $this->createForm('pim_product_edit', $product, $this->getEditFormOptions($product));
     $form->submit($request, false);
     if ($form->isValid()) {
         try {
             $this->mediaManager->handleProductMedias($product);
             $this->productSaver->save($product);
             $this->addFlash('success', 'flash.product.updated');
         } catch (MediaManagementException $e) {
             $this->addFlash('error', $e->getMessage());
         }
         $params = ['id' => $product->getId(), 'dataLocale' => $this->getDataLocaleCode()];
         if ($comparisonLocale = $this->getComparisonLocale()) {
             $params['compareWith'] = $comparisonLocale;
         }
         return $this->redirectAfterEdit($params);
     } else {
         $this->addFlash('error', 'flash.product.invalid');
     }
     $channels = $this->getRepository('PimCatalogBundle:Channel')->findAll();
     $trees = $this->productCatManager->getProductCountByTree($product);
     return $this->getProductEditTemplateParams($form, $product, $channels, $trees);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:36,代码来源:ProductController.php


注:本文中的Akeneo\Component\StorageUtils\Saver\SaverInterface::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。