本文整理匯總了PHP中Oro\Bundle\SecurityBundle\SecurityFacade::isGranted方法的典型用法代碼示例。如果您正苦於以下問題:PHP SecurityFacade::isGranted方法的具體用法?PHP SecurityFacade::isGranted怎麽用?PHP SecurityFacade::isGranted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Oro\Bundle\SecurityBundle\SecurityFacade
的用法示例。
在下文中一共展示了SecurityFacade::isGranted方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: processConfigs
/**
* Validate configs nad fill default values
*
* @param DatagridConfiguration $config
*/
public function processConfigs(DatagridConfiguration $config)
{
$configItems = $config->offsetGetOr(Configuration::BASE_CONFIG_KEY, []);
$configuration = new Configuration(Configuration::BASE_CONFIG_KEY);
$normalizedConfigItems = $this->validateConfiguration($configuration, [Configuration::BASE_CONFIG_KEY => $configItems]);
$isGranted = $this->securityFacade->isGranted('EDIT', 'entity:' . $configItems['entity_name']);
//according to ACL disable inline editing for the whole grid
if (!$isGranted) {
$normalizedConfigItems[Configuration::CONFIG_KEY_ENABLE] = false;
}
// replace config values by normalized, extra keys passed directly
$resultConfigItems = array_replace_recursive($configItems, $normalizedConfigItems);
if (is_null($resultConfigItems['save_api_accessor']['default_route_parameters']['className'])) {
$resultConfigItems['save_api_accessor']['default_route_parameters']['className'] = $this->entityClassNameHelper->getUrlSafeClassName($configItems['entity_name']);
}
$config->offsetSet(Configuration::BASE_CONFIG_KEY, $resultConfigItems);
//add inline editing where it is possible, do not use ACL, because additional parameters for columns needed
$columns = $config->offsetGetOr(FormatterConfiguration::COLUMNS_KEY, []);
$blackList = $configuration->getBlackList();
foreach ($columns as $columnName => &$column) {
if (!in_array($columnName, $blackList)) {
$newColumn = $this->guesser->getColumnOptions($columnName, $configItems['entity_name'], $column);
//frontend type key must not be replaced with default value
$typeKey = PropertyInterface::FRONTEND_TYPE_KEY;
if (!empty($newColumn[$typeKey])) {
$column[$typeKey] = $newColumn[$typeKey];
}
$column = array_replace_recursive($newColumn, $column);
}
}
$config->offsetSet(FormatterConfiguration::COLUMNS_KEY, $columns);
}
示例2: getRecipients
/**
* @param object $object
* @param int $depth
* @param bool $ignoreAcl
* @param Organization|null $organization
*
* @return Recipient[]
*/
public function getRecipients($object, $depth = 1, $ignoreAcl = false, Organization $organization = null)
{
$recipients = [];
if ($this->isAccessDenyForOrganization($object, $ignoreAcl, $organization)) {
return $recipients;
}
if (!$depth || ($ignoreAcl || !$this->securityFacade->isGranted('VIEW', $object))) {
if (!$depth || $this->securityFacade->getLoggedUser() !== $object) {
return $recipients;
}
}
$className = ClassUtils::getClass($object);
$metadata = $this->getMetadata($className);
$attributes = $this->initAttributes($className, $metadata);
foreach ($metadata->associationMappings as $name => $assoc) {
if (in_array('Oro\\Bundle\\EmailBundle\\Entity\\EmailInterface', class_implements($assoc['targetEntity']), true)) {
$attributes[] = new EmailAttribute($name, true);
} else {
if ($depth > 1) {
$assocObject = $this->getPropertyAccessor()->getValue($object, $name);
if (!$assocObject instanceof \Traversable && !is_array($assocObject)) {
if ($assocObject) {
$assocObject = [$assocObject];
} else {
$assocObject = [];
}
}
foreach ($assocObject as $obj) {
$recipients = array_merge($recipients, $this->getRecipients($obj, $depth - 1, false, $organization));
}
}
}
}
return array_merge($recipients, $this->createRecipientsFromEmails($this->createEmailsFromAttributes($attributes, $object), $object, $metadata));
}
示例3: isVisible
/**
* {@inheritdoc}
*/
public function isVisible(array $config = [], array $context = [])
{
if (!isset($config['acl'])) {
throw new \InvalidArgumentException('The "acl" should be provided in the configuration.');
}
return $this->securityFacade->isGranted($config['acl']);
}
示例4: isAllowed
/**
* {@inheritdoc}
*/
public function isAllowed()
{
if (!$this->acl) {
return true;
}
return $this->securityFacade->hasLoggedUser() && $this->securityFacade->isGranted($this->acl);
}
示例5: getCalendarDefaultValues
/**
* {@inheritdoc}
*/
public function getCalendarDefaultValues($organizationId, $userId, $calendarId, array $calendarIds)
{
$result = [];
if (!$this->calendarConfig->isPublicCalendarEnabled()) {
foreach ($calendarIds as $id) {
$result[$id] = null;
}
return $result;
}
/** @var SystemCalendarRepository $repo */
$repo = $this->doctrineHelper->getEntityRepository('OroCalendarBundle:SystemCalendar');
$qb = $repo->getPublicCalendarsQueryBuilder();
/** @var SystemCalendar[] $calendars */
$calendars = $qb->getQuery()->getResult();
$isEventManagementGranted = $this->securityFacade->isGranted('oro_public_calendar_event_management');
foreach ($calendars as $calendar) {
$resultItem = ['calendarName' => $calendar->getName(), 'backgroundColor' => $calendar->getBackgroundColor(), 'removable' => false, 'position' => -80];
if ($isEventManagementGranted) {
$resultItem['canAddEvent'] = true;
$resultItem['canEditEvent'] = true;
$resultItem['canDeleteEvent'] = true;
}
$result[$calendar->getId()] = $resultItem;
}
return $result;
}
示例6: setDefaultOptions
/**
* Options:
* - grid_name - name of grid that will be used for entity selection
* - grid_parameters - parameters need to be passed to grid request
* - grid_render_parameters - render parameters need to be set for grid rendering
* - existing_entity_grid_id - grid row field name used as entity identifier
* - create_enabled - enables new entity creation
* - create_acl - ACL resource used to determine that create is allowed, by default CREATE for entity used
* - create_form_route - route name for creation form
* - create_form_route_parameters - route parameters for create_form_route_parameters
*
* {@inheritDoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(['existing_entity_grid_id' => 'id', 'create_enabled' => true, 'create_acl' => null, 'create_form_route' => null, 'create_form_route_parameters' => [], 'grid_name' => null, 'grid_parameters' => [], 'grid_render_parameters' => []]);
$resolver->setNormalizers(['create_enabled' => function (Options $options, $createEnabled) {
$createRouteName = $options->get('create_form_route');
$createEnabled = $createEnabled && !empty($createRouteName);
if ($createEnabled) {
$aclName = $options->get('create_acl');
if (empty($aclName)) {
$aclObjectName = 'Entity:' . $options->get('entity_class');
$createEnabled = $this->securityFacade->isGranted('CREATE', $aclObjectName);
} else {
$createEnabled = $this->securityFacade->isGranted($aclName);
}
}
return $createEnabled;
}, 'grid_name' => function (Options $options, $gridName) {
if (!empty($gridName)) {
return $gridName;
}
$formConfig = $this->configManager->getProvider('form')->getConfig($options->get('entity_class'));
if ($formConfig->has('grid_name')) {
return $formConfig->get('grid_name');
}
throw new InvalidConfigurationException('The option "grid_name" must be set.');
}]);
}
示例7: addEntityFields
/**
* {@inheritdoc}
*/
public function addEntityFields(FormBuilderInterface $builder)
{
// user fields
$builder->addEventSubscriber(new UserSubscriber($builder->getFormFactory(), $this->security));
$this->setDefaultUserFields($builder);
if ($this->securityFacade->isGranted('oro_user_role_view')) {
$builder->add('roles', 'entity', ['property_path' => 'rolesCollection', 'label' => 'oro.user.roles.label', 'class' => 'OroUserBundle:Role', 'property' => 'label', 'query_builder' => function (EntityRepository $er) {
return $er->createQueryBuilder('r')->where('r.role <> :anon')->setParameter('anon', User::ROLE_ANONYMOUS)->orderBy('r.label');
}, 'multiple' => true, 'expanded' => true, 'required' => !$this->isMyProfilePage, 'read_only' => $this->isMyProfilePage, 'disabled' => $this->isMyProfilePage, 'translatable_options' => false]);
}
if ($this->securityFacade->isGranted('oro_user_group_view')) {
$builder->add('groups', 'entity', ['label' => 'oro.user.groups.label', 'class' => 'OroUserBundle:Group', 'property' => 'name', 'multiple' => true, 'expanded' => true, 'required' => false, 'read_only' => $this->isMyProfilePage, 'disabled' => $this->isMyProfilePage, 'translatable_options' => false]);
}
if ($this->securityFacade->isGranted('oro_organization_view') && $this->securityFacade->isGranted('oro_business_unit_view')) {
$builder->add('organizations', 'oro_organizations_select', ['required' => false, 'label' => 'oro.user.form.access_settings.label']);
}
$builder->add('plainPassword', 'repeated', ['label' => 'oro.user.password.label', 'type' => 'password', 'required' => true, 'first_options' => ['label' => 'oro.user.password.label'], 'second_options' => ['label' => 'oro.user.password_re.label']])->add('emails', 'collection', ['label' => 'oro.user.emails.label', 'type' => 'oro_user_email', 'allow_add' => true, 'allow_delete' => true, 'by_reference' => false, 'prototype' => true, 'prototype_name' => 'tag__name__']);
if ($this->userConfigManager->get('oro_imap.enable_google_imap')) {
$builder->add('imapAccountType', 'oro_imap_choice_account_type', ['label' => 'oro.user.imap_configuration.label']);
} else {
$builder->add('imapConfiguration', 'oro_imap_configuration', ['label' => 'oro.user.imap_configuration.label']);
}
$builder->add('change_password', ChangePasswordType::NAME)->add('avatar', 'oro_image', ['label' => 'oro.user.avatar.label', 'required' => false]);
$this->addInviteUserField($builder);
}
示例8: isUnsubscribeGranted
/**
* @return bool
*/
protected function isUnsubscribeGranted()
{
if ($this->unsubscribeGranted === null) {
$this->unsubscribeGranted = $this->securityFacade->isGranted('orocrm_magento_newsletter_subscriber_unsubscribe_customer');
}
return $this->unsubscribeGranted;
}
示例9: isApplicable
/**
* Checks if the entity can have comments
*
* @param object|null $entity
*
* @return bool
*/
public function isApplicable($entity)
{
if (!is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || !$this->securityFacade->isGranted('oro_comment_view')) {
return false;
}
return $this->commentAssociationHelper->isCommentAssociationEnabled(ClassUtils::getClass($entity));
}
示例10: process
/**
* Process form
*
* @param mixed $entity
*
* @return mixed|null The instance of saved entity on successful processing; otherwise, null
*/
public function process($entity)
{
if ($this->securityFacade->isGranted('EDIT', $entity)) {
return parent::process($entity);
}
return null;
}
示例11: onViewsLoad
/**
* @param GridViewsLoadEvent $event
*/
public function onViewsLoad(GridViewsLoadEvent $event)
{
$gridName = $event->getGridName();
$currentUser = $this->getCurrentUser();
if (!$currentUser) {
return;
}
$gridViews = $this->getGridViewRepository()->findGridViews($this->aclHelper, $currentUser, $gridName);
if (!$gridViews) {
return;
}
$choices = [];
$views = [];
foreach ($gridViews as $gridView) {
$view = $gridView->createView();
$view->setEditable($this->securityFacade->isGranted('EDIT', $gridView));
$view->setDeletable($this->securityFacade->isGranted('DELETE', $gridView));
$views[] = $view->getMetadata();
$choices[] = ['label' => $this->createGridViewLabel($currentUser, $gridView), 'value' => $gridView->getId()];
}
$newGridViews = $event->getGridViews();
$newGridViews['choices'] = array_merge($newGridViews['choices'], $choices);
$newGridViews['views'] = array_merge($newGridViews['views'], $views);
$event->setGridViews($newGridViews);
}
示例12: beforeProcess
/**
* {@inheritdoc}
*/
public function beforeProcess($entity)
{
//check owner (Contact) entity with 'edit' permission
if (!$this->securityFacade->isGranted('EDIT', $entity->getOwner())) {
throw new AccessDeniedException();
}
}
示例13: applyPermissions
/**
* {@inheritdoc}
*/
protected function applyPermissions(&$item, $calendarId)
{
if (!$this->securityFacade->isGranted('oro_public_calendar_event_management')) {
$item['editable'] = false;
$item['removable'] = false;
}
}
示例14: onNavigationConfigure
/**
* @param ConfigureMenuEvent $event
*/
public function onNavigationConfigure(ConfigureMenuEvent $event)
{
$menu = $event->getMenu();
$children = array();
$entitiesMenuItem = $menu->getChild('system_tab')->getChild('entities_list');
if ($entitiesMenuItem) {
/** @var ConfigProvider $entityConfigProvider */
$entityConfigProvider = $this->configManager->getProvider('entity');
/** @var ConfigProvider $entityExtendProvider */
$entityExtendProvider = $this->configManager->getProvider('extend');
$extendConfigs = $entityExtendProvider->getConfigs();
foreach ($extendConfigs as $extendConfig) {
if ($this->checkAvailability($extendConfig)) {
$config = $entityConfigProvider->getConfig($extendConfig->getId()->getClassname());
if (!class_exists($config->getId()->getClassName()) || !$this->securityFacade->hasLoggedUser() || !$this->securityFacade->isGranted('VIEW', 'entity:' . $config->getId()->getClassName())) {
continue;
}
$children[$config->get('label')] = array('label' => $this->translator->trans($config->get('label')), 'options' => array('route' => 'oro_entity_index', 'routeParameters' => array('entityName' => str_replace('\\', '_', $config->getId()->getClassName())), 'extras' => array('safe_label' => true, 'routes' => array('oro_entity_*'))));
}
}
sort($children);
foreach ($children as $child) {
$entitiesMenuItem->addChild($child['label'], $child['options']);
}
}
}
示例15: getLastOperationsData
/**
* Get last operations data
*
* @param array $types
*
* @return array
*/
public function getLastOperationsData(array $types)
{
$types = array_filter($types, function ($type) {
return $this->securityFacade->isGranted(sprintf('pim_importexport_%s_execution_show', $type));
});
return $this->repository->getLastOperationsData($types);
}