本文整理匯總了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);
}