Make dblog entities
Merge request reports
Activity
added 2 commits
added 1 commit
- 829bef17 - Fix MediaSourceOEmbedVideoTest related dblog test. Add alias for dblog.formatter service
added 303 commits
-
829bef17...b155910d - 302 commits from branch
project:11.x
- ee48cc64 - Merge branch drupal:11.x into 2401463-dblog-entities-D11
-
829bef17...b155910d - 302 commits from branch
60 60 * The form builder service. 61 61 */ 62 62 public function __construct(Connection $database, ModuleHandlerInterface $module_handler, DateFormatterInterface $date_formatter, FormBuilderInterface $form_builder) { 63 @trigger_error(__CLASS__ . ' is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use the \Drupal\dblog\DblogEntryListBuilder class instead. See https://www.drupal.org/node/3236383', E_USER_DEPRECATED); 41 } 42 43 /** 44 * Shows the most frequent log messages of a given event type. 45 * 46 * Messages are not truncated on this page because events detailed herein do 47 * not have links to a detailed view. 48 * 49 * @param string $type 50 * Type of database log events to display (e.g., 'search'). 51 * 52 * @return array 53 * A build array in the format expected by 54 * \Drupal\Core\Render\RendererInterface::render(). 55 */ 56 public function list(string $type) { - core/modules/dblog/src/Entity/DblogEntry.php 0 → 100644
44 * internal = TRUE, 45 * entity_keys = { 46 * "id" = "wid", 47 * }, 48 * links = { 49 * "canonical" = "/admin/reports/dblog/event/{dblog}", 50 * "collection" = "/admin/reports/dblog", 51 * } 52 * ) 53 */ 54 final class DblogEntry extends ContentEntityBase implements DblogEntryInterface { 55 56 /** 57 * {@inheritdoc} 58 */ 59 public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { 5 use Drupal\Core\Access\AccessResult; 6 use Drupal\Core\Entity\EntityAccessControlHandler; 7 use Drupal\Core\Entity\EntityInterface; 8 use Drupal\Core\Session\AccountInterface; 9 10 /** 11 * Defines the access control handler for the dblog entry entity type. 12 * 13 * @see \Drupal\dblog\Entity\DblogEntry 14 */ 15 class DblogEntryAccessControllerHandler extends EntityAccessControlHandler { 16 17 /** 18 * {@inheritdoc} 19 */ 20 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { 12 * 13 * @see \Drupal\dblog\Entity\DblogEntry 14 */ 15 class DblogEntryAccessControllerHandler extends EntityAccessControlHandler { 16 17 /** 18 * {@inheritdoc} 19 */ 20 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { 21 return AccessResult::allowedIfHasPermission($account, 'access site reports'); 22 } 23 24 /** 25 * {@inheritdoc} 26 */ 27 public function createAccess($entity_bundle = NULL, ?AccountInterface $account = NULL, array $context = [], $return_as_object = FALSE) { 27 public function createAccess($entity_bundle = NULL, ?AccountInterface $account = NULL, array $context = [], $return_as_object = FALSE) { 27 public function createAccess($entity_bundle = NULL, ?AccountInterface $account = NULL, array $context = [], $return_as_object = FALSE): AccessResultInterface {
63 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type 64 * The entity type definition. 65 * @param \Drupal\Core\Entity\EntityStorageInterface $storage 66 * The entity storage class. 67 * @param \Symfony\Component\HttpFoundation\Request $current_request 68 * The current request. 69 * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter 70 * The date formatter service. 71 * @param \Drupal\dblog\DblogFormatterInterface $dblog_formatter 72 * The dblog formatter service. 73 * @param \Drupal\Core\Form\FormBuilderInterface $form_builder 74 * The form builder. 75 * @param \Drupal\Core\Entity\EntityStorageInterface $user_storage 76 * The user storage service. 77 */ 78 public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, Request $current_request, DateFormatterInterface $date_formatter, DblogFormatterInterface $dblog_formatter, FormBuilderInterface $form_builder, EntityStorageInterface $user_storage) { 121 if ($this->currentRequest->query->has('order')) { 122 // Allow the entity query to sort using the table header. 123 $header = $this->buildHeader(); 124 $query->tableSort($header); 125 } 126 else { 127 $query->sort('wid', 'DESC'); 128 } 129 130 return $query->execute(); 131 } 132 133 /** 134 * {@inheritdoc} 135 */ 136 public function buildHeader() { 91 public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { 92 return new static( 93 $entity_type, 94 $container->get('entity_type.manager')->getStorage($entity_type->id()), 95 $container->get('request_stack')->getCurrentRequest(), 96 $container->get('date.formatter'), 97 $container->get('dblog.formatter'), 98 $container->get('form_builder'), 99 $container->get('entity_type.manager')->getStorage('user'), 100 ); 101 } 102 103 /** 104 * {@inheritdoc} 105 */ 106 protected function getEntityIds() { 159 ], 160 'uid' => [ 161 'data' => $this->t('User'), 162 'class' => [RESPONSIVE_PRIORITY_MEDIUM], 163 'specifier' => 'uid', 164 'field' => 'uid', 165 ], 166 ]; 167 168 return $header + parent::buildHeader(); 169 } 170 171 /** 172 * {@inheritdoc} 173 */ 174 public function buildRow(EntityInterface $entity) { 51 */ 52 protected $dblogFormatter; 53 54 /** 55 * Constructs a new dblog entry view builder. 56 * 57 * @param \Drupal\Core\Render\RendererInterface $renderer 58 * The renderer service. 59 * @param \Drupal\Core\Entity\EntityStorageInterface $user_storage 60 * The user storage service. 61 * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter 62 * The date formatter service. 63 * @param \Drupal\dblog\DblogFormatterInterface $dblog_formatter 64 * The dblog formatter service. 65 */ 66 public function __construct(RendererInterface $renderer, EntityStorageInterface $user_storage, DateFormatterInterface $date_formatter, DblogFormatterInterface $dblog_formatter) { 160 public function getCacheTags() { 161 // Intentionally empty. 162 return []; 163 } 164 165 /** 166 * Creates a Link object if the provided URI is valid. 167 * 168 * @param string|null $uri 169 * The uri string to convert into link if valid. 170 * 171 * @return \Drupal\Core\Link|string|null 172 * Return a Link object if the uri can be converted as a link. In case of 173 * empty uri or invalid, fallback to the provided $uri. 174 */ 175 protected function createLink($uri) { 15 16 /** 17 * {@inheritdoc} 18 */ 19 protected function setDatabaseDumpFiles() { 20 $this->databaseDumpFiles = [ 21 __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-10.3.0.filled.standard.php.gz', 22 ]; 23 } 24 25 /** 26 * Tests that dblog view row style is updated properly. 27 * 28 * @group legacy 29 */ 30 public function testSeverityUpdate() { 4 5 namespace Drupal\Tests\dblog\Functional\Update; 6 7 use Drupal\FunctionalTests\Update\UpdatePathTestBase; 8 9 /** 10 * Tests the upgrade path for modifying dblog row styles. 11 * 12 * @group Update 13 */ 14 class DblogViewSeverityUpdateTest extends UpdatePathTestBase { 15 16 /** 17 * {@inheritdoc} 18 */ 19 protected function setDatabaseDumpFiles() { 25 protected static $modules = ['dblog', 'system', 'user']; 26 27 /** 28 * {@inheritdoc} 29 */ 30 protected function setUp(): void { 31 parent::setUp(); 32 33 $this->installSchema('dblog', ['watchdog']); 34 $this->installConfig(['system']); 35 } 36 37 /** 38 * Tests creation of log entries. 39 */ 40 public function testCreate() {
Please register or sign in to reply