• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Saver\SaverInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了SaverInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: write

 /**
  * {@inheritdoc}
  */
 public function write(array $items)
 {
     $this->versionManager->setRealTimeVersioning($this->realTimeVersioning);
     foreach ($items as $item) {
         $this->incrementCount($item);
     }
     $this->mediaManager->handleAllProductsMedias($items);
     $this->productSaver->saveAll($items, ['recalculate' => false]);
     $this->cacheClearer->clear();
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:13,代码来源:ProductWriter.php


示例5: 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


示例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: 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


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: 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


示例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: 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


示例15: 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


示例16: 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


示例17: removeAttributeFromProduct

 /**
  * Deletes values that link an attribute to a product
  *
  * @param ProductInterface   $product
  * @param AttributeInterface $attribute
  * @param array              $savingOptions
  *
  * @deprecated Will be removed in 1.5, please use ProductBuilderInterface::removeAttributeFromProduct() and
  *             ProductSaver::save() instead.
  */
 public function removeAttributeFromProduct(ProductInterface $product, AttributeInterface $attribute, array $savingOptions = [])
 {
     foreach ($product->getValues() as $value) {
         if ($attribute === $value->getAttribute()) {
             $product->removeValue($value);
         }
     }
     $options = array_merge(['recalculate' => false, 'schedule' => false], $savingOptions);
     $this->productSaver->save($product, $options);
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:20,代码来源:ProductManager.php


示例18: manageFormSubmission

 /**
  * Manage form submission of an attribute option
  *
  * @param AttributeOptionInterface $attributeOption
  * @param array                    $data
  *
  * @return FormInterface
  */
 protected function manageFormSubmission(AttributeOptionInterface $attributeOption, array $data = [])
 {
     $form = $this->formFactory->createNamed('option', 'pim_enrich_attribute_option', $attributeOption);
     $form->submit($data, false);
     if ($form->isValid()) {
         $this->optionSaver->save($attributeOption);
         $option = $this->normalizer->normalize($attributeOption, 'array', ['onlyActivatedLocales' => true]);
         return new JsonResponse($option);
     }
     return $this->viewHandler->handle(RestView::create($form));
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:19,代码来源:AttributeOptionController.php


示例19: store

 /**
  * {@inheritdoc}
  */
 public function store(\SplFileInfo $localFile, $destFsAlias)
 {
     $filesystem = $this->mountManager->getFilesystem($destFsAlias);
     $storageData = $this->pathGenerator->generate($localFile);
     $file = $this->factory->create($localFile, $storageData, $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 {
         $isFileWritten = $filesystem->writeStream($file->getKey(), $resource);
     } catch (FileExistsException $e) {
         throw new FileTransferException($error, $e->getCode(), $e);
     }
     if (false === $isFileWritten) {
         throw new FileTransferException($error);
     }
     $this->saver->save($file, ['flush_only_object' => true]);
     $this->deleteRawFile($localFile);
     return $file;
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:24,代码来源:RawFileStorer.php


示例20: toggleStatusAction

 /**
  * Toggle product status (enabled/disabled)
  *
  * @param Request $request
  * @param int     $id
  *
  * @return Response|RedirectResponse
  *
  * @AclAncestor("pim_enrich_product_edit_attributes")
  */
 public function toggleStatusAction(Request $request, $id)
 {
     $product = $this->findProductOr404($id);
     $toggledStatus = !$product->isEnabled();
     $product->setEnabled($toggledStatus);
     $this->productSaver->save($product);
     $successMessage = $toggledStatus ? 'flash.product.enabled' : 'flash.product.disabled';
     if ($request->isXmlHttpRequest()) {
         return new JsonResponse(['successful' => true, 'message' => $this->translator->trans($successMessage)]);
     } else {
         return $this->redirectToRoute('pim_enrich_product_index');
     }
 }
开发者ID:VinceBLOT,项目名称:pim-community-dev,代码行数:23,代码来源:ProductController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Form\AlbumForm类代码示例发布时间:2022-05-23
下一篇:
PHP Repository\IdentifiableObjectRepositoryInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap