Class: ElFinder2::Command::Parents

Inherits:
Base
  • Object
show all
Defined in:
lib/el_finder2/command/parents.rb

Overview

Returns all parent folders and its subfolders on required (in connector options) deep. This command is invoked when a directory is reloaded in the client. Data provided by ‘parents’ command should enable the correct drawing of tree hierarchy directories.

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from HashUtils

#from_base64url, #to_base64url, #to_path

Constructor Details

This class inherits a constructor from ElFinder2::Command::Base

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/el_finder2/command/parents.rb', line 8

def execute
  folders = ElFinder2::Folder.where(
    'id IN (:ancestor_ids) OR parent_id IN (:ancestor_ids)',
    ancestor_ids: @file.ancestor_ids
  )

  render json: {
    tree: ActiveModel::ArraySerializer.new(folders).as_json
  }
end