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


PHP InputHelper::filename方法代码示例

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


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

示例1: indexAction

 /**
  * @return JsonResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function indexAction()
 {
     //set some permissions
     $permissions = $this->factory->getSecurity()->isGranted(['core:themes:view', 'core:themes:create', 'core:themes:edit', 'core:themes:delete'], "RETURN_ARRAY");
     if (!$permissions['core:themes:view']) {
         return $this->accessDenied();
     }
     $themeHelper = $this->container->get('mautic.helper.theme');
     $dir = $this->factory->getSystemPath('themes', true);
     $action = $this->generateUrl('mautic_themes_index');
     $form = $this->get('form.factory')->create('theme_upload', [], ['action' => $action]);
     if ($this->request->getMethod() == 'POST') {
         if (isset($form) && !($cancelled = $this->isFormCancelled($form))) {
             if ($this->isFormValid($form)) {
                 $fileData = $form['file']->getData();
                 $fileName = InputHelper::filename($fileData->getClientOriginalName());
                 $themeName = basename($fileName, '.zip');
                 if (in_array($themeName, $this->defaultThemes)) {
                     $form->addError(new FormError($this->factory->getTranslator()->trans('mautic.core.theme.default.cannot.overwrite', ['%name%' => $themeName], 'validators')));
                 } elseif (!empty($fileData)) {
                     try {
                         $fileData->move($dir, $fileName);
                         $themeHelper->install($dir . '/' . $fileName);
                         $this->addFlash('mautic.core.theme.installed', ['%name%' => $themeName]);
                     } catch (\Exception $e) {
                         $form->addError(new FormError($this->factory->getTranslator()->trans($e->getMessage(), [], 'validators')));
                     }
                 } else {
                     $form->addError(new FormError($this->factory->getTranslator()->trans('mautic.dashboard.upload.filenotfound', [], 'validators')));
                 }
             }
         }
     }
     return $this->delegateView(['viewParameters' => ['items' => $themeHelper->getInstalledThemes('all', true, true), 'defaultThemes' => $this->defaultThemes, 'form' => $form->createView(), 'permissions' => $permissions, 'security' => $this->factory->getSecurity()], 'contentTemplate' => 'MauticCoreBundle:Theme:list.html.php', 'passthroughVars' => ['activeLink' => '#mautic_themes_index', 'mauticContent' => 'theme', 'route' => $this->generateUrl('mautic_themes_index')]]);
 }
开发者ID:Yame-,项目名称:mautic,代码行数:38,代码来源:ThemeController.php

示例2: getDirectoryName

 /**
  * @param $newName
  *
  * @return string
  */
 private function getDirectoryName($newName)
 {
     return InputHelper::filename($newName, true);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:9,代码来源:ThemeHelper.php


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