本文整理汇总了PHP中Mautic\CoreBundle\Factory\MauticFactory::getSecurity方法的典型用法代码示例。如果您正苦于以下问题:PHP MauticFactory::getSecurity方法的具体用法?PHP MauticFactory::getSecurity怎么用?PHP MauticFactory::getSecurity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mautic\CoreBundle\Factory\MauticFactory
的用法示例。
在下文中一共展示了MauticFactory::getSecurity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTokenContent
/**
* @param int $page
*
* @return string
*/
public function getTokenContent($page = 1)
{
if (!$this->factory->getSecurity()->isGranted('lead:fields:full')) {
return;
}
$session = $this->factory->getSession();
//set limits
$limit = 5;
$start = $page === 1 ? 0 : ($page - 1) * $limit;
if ($start < 0) {
$start = 0;
}
$request = $this->factory->getRequest();
$search = $request->get('search', $session->get('mautic.lead.emailtoken.filter', ''));
$session->set('mautic.lead.emailtoken.filter', $search);
$filter = array('string' => $search, 'force' => array(array('column' => 'f.isPublished', 'expr' => 'eq', 'value' => true)));
$fields = $this->factory->getModel('lead.field')->getEntities(array('start' => $start, 'limit' => $limit, 'filter' => $filter, 'orderBy' => 'f.label', 'orderByDir' => 'ASC', 'hydration_mode' => 'HYDRATE_ARRAY'));
$count = count($fields);
if ($count && $count < $start + 1) {
//the number of entities are now less then the current page so redirect to the last page
if ($count === 1) {
$page = 1;
} else {
$page = ceil($count / $limit) ?: 1;
}
$session->set('mautic.lead.emailtoken.page', $page);
}
return $this->factory->getTemplating()->render('MauticLeadBundle:SubscribedEvents\\EmailToken:list.html.php', array('items' => $fields, 'page' => $page, 'limit' => $limit, 'totalCount' => $count, 'tmpl' => $request->get('tmpl', 'index'), 'searchValue' => $search));
}
示例2: getTokens
/**
* @param string $tokenRegex Token regex without wrapping regex escape characters. Use (value) or (.*?) where the ID of the
* entity should go. i.e. {pagelink=(value)}
* @param string $filter String to filter results by
* @param string $labelColumn The column that houses the label
* @param string $valueColumn The column that houses the value
* @param CompositeExpression $expr Use $factory->getDatabase()->getExpressionBuilder()->andX()
*
* @return array|void
*/
public function getTokens($tokenRegex, $filter = '', $labelColumn = 'name', $valueColumn = 'id', CompositeExpression $expr = null)
{
//set some permissions
$permissions = $this->factory->getSecurity()->isGranted($this->permissionSet, "RETURN_ARRAY");
if (in_array(false, $permissions)) {
return;
}
$repo = $this->factory->getModel($this->modelName)->getRepository();
$prefix = $repo->getTableAlias();
if (!empty($prefix)) {
$prefix .= '.';
}
$exprBuilder = $this->factory->getDatabase()->getExpressionBuilder();
if ($expr == null) {
$expr = $exprBuilder->andX();
}
if (isset($permissions[$this->viewPermissionBase . ':viewother']) && !$permissions[$this->viewPermissionBase . ':viewother']) {
$expr->add($exprBuilder->eq($prefix . 'createdBy', $this->factory->getUser()->getId()));
}
if (!empty($filter)) {
$expr->add($exprBuilder->like('LOWER(' . $labelColumn . ')', ':label'));
$parameters = array('label' => strtolower($filter) . '%');
} else {
$parameters = array();
}
$items = $repo->getSimpleList($expr, $parameters, $labelColumn, $valueColumn);
$tokens = array();
foreach ($items as $item) {
$token = str_replace(array('(value)', '(.*?)'), $item['value'], $tokenRegex);
$tokens[$token] = $item['label'];
}
return $tokens;
}
示例3: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->translator = $factory->getTranslator();
/** @var \Mautic\LeadBundle\Model\ListModel $listModel */
$listModel = $factory->getModel('lead.list');
$this->fieldChoices = $listModel->getChoiceFields();
// Locales
$this->timezoneChoices = FormFieldHelper::getTimezonesChoices();
$this->countryChoices = FormFieldHelper::getCountryChoices();
$this->regionChoices = FormFieldHelper::getRegionChoices();
// Segments
$lists = $listModel->getUserLists();
foreach ($lists as $list) {
$this->listChoices[$list['id']] = $list['name'];
}
// Emails
/** @var \Mautic\EmailBundle\Model\EmailModel $emailModel */
$emailModel = $factory->getModel('email');
$viewOther = $factory->getSecurity()->isGranted('email:emails:viewother');
$emails = $emailModel->getRepository()->getEmailList('', 0, 0, $viewOther, true);
foreach ($emails as $email) {
$this->emailChoices[$email['language']][$email['id']] = $email['name'];
}
ksort($this->emailChoices);
// Tags
$leadModel = $factory->getModel('lead');
$tags = $leadModel->getTagList();
foreach ($tags as $tag) {
$this->tagChoices[$tag['value']] = $tag['label'];
}
}
示例4: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->translator = $factory->getTranslator();
$this->em = $factory->getEntityManager();
$this->model = $factory->getModel('page');
$this->canViewOther = $factory->getSecurity()->isGranted('page:pages:viewother');
$this->user = $factory->getUser();
}
示例5: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->em = $factory->getEntityManager();
$this->security = $factory->getSecurity();
$this->dispatcher = $factory->getDispatcher();
$this->translator = $factory->getTranslator();
$this->factory = $factory;
}
示例6: accessDenied
/**
* Generates access denied message
*
* @param bool $batch Flag if a batch action is being performed
* @param string $msg Message that is logged
*
* @return JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse|array
* @throws AccessDeniedHttpException
*/
public function accessDenied($batch = false, $msg = 'mautic.core.url.error.401')
{
$anonymous = $this->factory->getSecurity()->isAnonymous();
if ($anonymous || !$batch) {
throw new AccessDeniedHttpException($this->factory->getTranslator()->trans($msg, array('%url%' => $this->request->getRequestUri())));
}
if ($batch) {
return array('type' => 'error', 'msg' => $this->factory->getTranslator()->trans('mautic.core.error.accessdenied', array(), 'flashes'));
}
}
示例7: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$viewOther = $factory->getSecurity()->isGranted('asset:assets:viewother');
$choices = $factory->getModel('asset')->getRepository()->getAssetList('', 0, 0, $viewOther);
foreach ($choices as $asset) {
$this->choices[$asset['language']][$asset['id']] = $asset['title'];
}
//sort by language
ksort($this->choices);
}
示例8: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->factory = $factory;
$this->templating = $factory->getTemplating();
$this->request = $factory->getRequest();
$this->security = $factory->getSecurity();
$this->serializer = $factory->getSerializer();
$this->params = $factory->getSystemParameters();
$this->dispatcher = $factory->getDispatcher();
$this->translator = $factory->getTranslator();
$this->init();
}
示例9: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->translator = $factory->getTranslator();
$this->security = $factory->getSecurity();
}
示例10: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->viewOther = $factory->getSecurity()->isGranted('email:emails:viewother');
$this->repo = $factory->getModel('email')->getRepository();
}
示例11: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->viewOther = $factory->getSecurity()->isGranted('dynamicContent:dynamicContents:viewother');
$this->repo = $factory->getModel('dynamicContent')->getRepository();
$this->repo->setCurrentUser($factory->getUser());
}
示例12: getSecurity
/**
* @return mixed
*/
protected function getSecurity()
{
return $this->factory->getSecurity();
}
示例13: initialize
/**
* Initialize some variables
*
* @param FilterControllerEvent $event
*
* @return void
*/
public function initialize(FilterControllerEvent $event)
{
$this->security = $this->factory->getSecurity();
}
示例14: isGranted
/**
* @param $permission
*
* @return mixed
*/
public function isGranted($permission)
{
return $this->factory->getSecurity()->isGranted($permission);
}
示例15: __construct
/**
* @param MauticFactory $factory
*/
public function __construct(MauticFactory $factory)
{
$this->model = $factory->getModel('page');
$this->canViewOther = $factory->getSecurity()->isGranted('page:pages:viewother');
}