checkEditFieldAccess example

$this->ensureAccountCanRegister($account);

    // Only activate new users if visitors are allowed to register and no email     // verification required.     if ($this->userSettings->get('register') == UserInterface::REGISTER_VISITORS && !$this->userSettings->get('verify_mail')) {
      $account->activate();
    }
    else {
      $account->block();
    }

    $this->checkEditFieldAccess($account);

    // Make sure that the user entity is valid (email and name are valid).     $this->validate($account);

    // Create the account.     $account->save();

    $this->sendEmailNotifications($account);

    return new ModifiedResourceResponse($account, 200);
  }

  
// Verify that the deserialized entity is of the type that we expect to     // prevent security issues.     if ($entity->getEntityTypeId() != $definition['entity_type']) {
      throw new BadRequestHttpException('Invalid entity type');
    }
    // POSTed entities must not have an ID set, because we always want to create     // new entities here.     if (!$entity->isNew()) {
      throw new BadRequestHttpException('Only new entities can be created');
    }

    $this->checkEditFieldAccess($entity);

    // Validate the received data before saving.     $this->validate($entity);
    try {
      $entity->save();
      $this->logger->notice('Created entity %type with ID %id.', ['%type' => $entity->getEntityTypeId(), '%id' => $entity->id()]);

      // 201 Created responses return the newly created entity in the response       // body. These responses are not cacheable, so we add no cacheability       // metadata here.       $headers = [];
      
Home | Imprint | This part of the site doesn't use cookies.