本文整理汇总了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')]]);
}
示例2: getDirectoryName
/**
* @param $newName
*
* @return string
*/
private function getDirectoryName($newName)
{
return InputHelper::filename($newName, true);
}