You are here

function photos_node_form_validate in Album Photos 8.4

Same name and namespace in other branches
  1. 8.5 photos.module \photos_node_form_validate()
  2. 6.0.x photos.module \photos_node_form_validate()

Form validator to check user album limit.

1 string reference to 'photos_node_form_validate'
photos_form_node_form_alter in ./photos.module
Implements hook_form_BASE_FORM_ID_alter().

File

./photos.module, line 802
Implementation of photos.module.

Code

function photos_node_form_validate($form, FormStateInterface &$form_state) {

  // Check album count.
  $user = \Drupal::currentUser();
  $album_count = PhotosAlbum::userAlbumCount();
  $current_path = \Drupal::service('path.current')
    ->getPath();
  $path_args = explode('/', $current_path);
  if ($user
    ->id() != 1 && isset($album_count['rest']) && $path_args[3] != 'edit') {
    $form_state
      ->setErrorByName('title', t('Album limit reached.'));
  }
}