You are here

class RefreshDirectoryTree in Media Directories 8

Same name and namespace in other branches
  1. 3.x modules/media_directories_ui/src/Ajax/RefreshDirectoryTree.php \Drupal\media_directories_ui\Ajax\RefreshDirectoryTree
  2. 2.x modules/media_directories_ui/src/Ajax/RefreshDirectoryTree.php \Drupal\media_directories_ui\Ajax\RefreshDirectoryTree

Class RefreshDirectoryTree.

Hierarchy

Expanded class hierarchy of RefreshDirectoryTree

3 files declare their use of RefreshDirectoryTree
AddMediaFormBase.php in modules/media_directories_ui/src/Form/AddMediaFormBase.php
DirectoryDeleteForm.php in modules/media_directories_ui/src/Form/DirectoryDeleteForm.php
MediaDirectoriesController.php in modules/media_directories_ui/src/Controller/MediaDirectoriesController.php

File

modules/media_directories_ui/src/Ajax/RefreshDirectoryTree.php, line 10

Namespace

Drupal\media_directories_ui\Ajax
View source
class RefreshDirectoryTree implements CommandInterface {

  /**
   * The selected directory.
   *
   * @var int
   */
  protected $selectedDirectory;

  /**
   * Newly selected media entity ids.
   *
   * @var array
   */
  protected $newlySelectedEntityIds;

  /**
   * RefreshDirectoryTree constructor.
   *
   * @param int $selected_directory
   *   The selected directory.
   * @param array $newly_selected_entity_ids
   *   Newly selected media entity ids.
   */
  public function __construct($selected_directory = MEDIA_DIRECTORY_ROOT, array $newly_selected_entity_ids = []) {
    $this->selectedDirectory = $selected_directory;
    $this->newlySelectedEntityIds = $newly_selected_entity_ids;
  }

  /**
   * Implements \Drupal\Core\Ajax\CommandInterface:render().
   */
  public function render() {
    return [
      'command' => 'refreshDirectoryTree',
      'data' => [
        'selected_directory' => isset($this->selectedDirectory) ? $this->selectedDirectory : MEDIA_DIRECTORY_ROOT,
        'newly_selected_entity_ids' => $this->newlySelectedEntityIds,
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RefreshDirectoryTree::$newlySelectedEntityIds protected property Newly selected media entity ids.
RefreshDirectoryTree::$selectedDirectory protected property The selected directory.
RefreshDirectoryTree::render public function Implements \Drupal\Core\Ajax\CommandInterface:render(). Overrides CommandInterface::render
RefreshDirectoryTree::__construct public function RefreshDirectoryTree constructor.