form_field_access-1.0.0-alpha1/src/Entity/FormFieldAccess.php

src/Entity/FormFieldAccess.php
<?php

namespace Drupal\form_field_access\Entity;

use Drupal\Core\Config\Entity\ConfigEntityBase;

/**
 * Represents a Field Form Access.
 *
 * @ConfigEntityType(
 *   id = "form_field_access",
 *   label = @Translation("Form Field Access"),
 *   label_collection = @Translation("Form Field Access"),
 *   label_singular = @Translation("form field access"),
 *   label_plural = @Translation("form fields access"),
 *   label_count = @PluralTranslation(
 *     singular = "@count form field access",
 *     plural = "@count form field access",
 *   ),
 *   handlers = {
 *     "list_builder" = "Drupal\form_field_access\FormFieldAccessListBuilder",
 *     "storage" = "Drupal\Core\Config\Entity\ConfigEntityStorage",
 *     "access" = "Drupal\Core\Entity\EntityAccessControlHandler",
 *     "form" = {
 *       "add" = "Drupal\form_field_access\Form\FormFieldAccessEditForm",
 *       "edit" = "Drupal\form_field_access\Form\FormFieldAccessEditForm",
 *       "delete" = "Drupal\form_field_access\Form\FormFieldAccessDeleteForm"
 *     },
 *     "route_provider" = {
 *       "html" = "Drupal\Core\Entity\Routing\AdminHtmlRouteProvider"
 *     },
 *   },
 *   config_prefix = "form_field_access",
 *   admin_permission = "administer form field access entities",
 *   entity_keys = {
 *     "id" = "id",
 *   },
 *   links = {
 *     "add-form" = "/admin/people/form-field-access/add",
 *     "edit-form" = "/admin/people/form-field-access/{form_field_access}",
 *     "delete-form" = "/admin/people/form-field-access/{form_field_access}/delete",
 *     "collection" = "/admin/people/form-field-access"
 *   },
 *   config_export = {
 *     "id",
 *     "entity_type_id",
 *     "bundle",
 *     "fields",
 *   }
 * )
 */
class FormFieldAccess extends ConfigEntityBase implements FormFieldAccessInterface {

  /**
   * {@inheritDoc}
   */
  public function getReferredEntityTypeId(): string|null {
    return $this->get('entity_type_id');
  }

  /**
   * {@inheritDoc}
   */
  public function getReferredBundle(): string|null {
    return $this->get('bundle');
  }

  /**
   * {@inheritDoc}
   */
  public function getDisallowedFields(): array {
    $fields = $this->get('fields');
    return $fields['disallowed'] ?? [];
  }

  /**
   * {@inheritDoc}
   */
  public function getDisallowedFieldRoles(string $field_name): array {
    $disallowed_fields = $this->getDisallowedFields();
    return array_keys($disallowed_fields[$field_name] ?? []);
  }

  /**
   * {@inheritDoc}
   */
  public function getRequiredFields(): array {
    $fields = $this->get('fields');
    return $fields['required'] ?? [];
  }

  /**
   * {@inheritDoc}
   */
  public function getRequiredFieldRoles(string $field_name): array {
    $required_fields = $this->getRequiredFields();
    return array_keys($required_fields[$field_name] ?? []);
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc