Issue #2030129 by a_c_m, tim.plunkett: Fixed FilterFormat has no access controller.
parent
031a22cdda
commit
165ec2ca55
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\filter\FilterFormatAccessController.
|
||||
*/
|
||||
|
||||
namespace Drupal\filter;
|
||||
|
||||
use Drupal\Core\Entity\EntityAccessController;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
|
||||
/**
|
||||
* Defines the access controller for the filter format entity type.
|
||||
*/
|
||||
class FilterFormatAccessController extends EntityAccessController {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
|
||||
// Handle special cases up front. All users have access to the fallback
|
||||
// format.
|
||||
if ($entity->isFallbackFormat()) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (user_access('administer filters', $account)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Check the permission if one exists; otherwise, we have a non-existent
|
||||
// format so we return FALSE.
|
||||
$permission = filter_permission_name($entity);
|
||||
return !empty($permission) && user_access($permission, $account);
|
||||
}
|
||||
|
||||
}
|
|
@ -143,7 +143,9 @@ class FilterFormatListController extends ConfigEntityListController implements F
|
|||
public function getOperations(EntityInterface $entity) {
|
||||
$operations = parent::getOperations($entity);
|
||||
|
||||
$operations['edit']['title'] = t('Configure');
|
||||
if (isset($operations['edit'])) {
|
||||
$operations['edit']['title'] = t('Configure');
|
||||
}
|
||||
|
||||
// The fallback format may not be disabled.
|
||||
if ($entity->isFallbackFormat()) {
|
||||
|
|
|
@ -28,6 +28,7 @@ use Drupal\filter\FilterBag;
|
|||
* "disable" = "Drupal\filter\Form\FilterDisableForm"
|
||||
* },
|
||||
* "list" = "Drupal\filter\FilterFormatListController",
|
||||
* "access" = "Drupal\filter\FilterFormatAccessController",
|
||||
* "storage" = "Drupal\Core\Config\Entity\ConfigStorageController"
|
||||
* },
|
||||
* config_prefix = "filter.format",
|
||||
|
|
|
@ -76,7 +76,16 @@ class FilterAdminTest extends WebTestBase {
|
|||
|
||||
// Edit text format.
|
||||
$this->drupalGet('admin/config/content/formats');
|
||||
$this->assertLinkByHref('admin/config/content/formats/manage/' . $format_id);
|
||||
// Cannot use the assertNoLinkByHref method as it does partial url matching
|
||||
// and 'admin/config/content/formats/manage/' . $format_id . '/disable'
|
||||
// exists.
|
||||
// @todo: See https://drupal.org/node/2031223 for the above
|
||||
$edit_link = $this->xpath('//a[@href=:href]', array(
|
||||
':href' => url('admin/config/content/formats/manage/' . $format_id)
|
||||
));
|
||||
$this->assertTrue($edit_link, format_string('Link href %href found.',
|
||||
array('%href' => 'admin/config/content/formats/manage/' . $format_id)
|
||||
));
|
||||
$this->drupalGet('admin/config/content/formats/manage/' . $format_id);
|
||||
$this->drupalPost(NULL, array(), t('Save configuration'));
|
||||
|
||||
|
|
Loading…
Reference in New Issue