You are here

protected function IconsetFinderService::setIconsets in Social Media Links Block and Field 8.2

Searches the directories for libraries (e.g. Icon Sets).

Sets an array of library directories from the all-sites directory (i.e. sites/all/libraries/), the profiles directory, and site-specific directory (i.e. sites/somesite/libraries/). The returned array will be keyed by the library name. Site-specific libraries are prioritized over libraries in the default directories. That is, if a library with the same name appears in both the site-wide directory and site-specific directory, only the site-specific version will be listed.

Most of the code in this function are borrowed from the libraries module (http://drupal.org/project/libraries).

1 call to IconsetFinderService::setIconsets()
IconsetFinderService::__construct in src/IconsetFinderService.php
Define inital state if the service class is constructed.

File

src/IconsetFinderService.php, line 154

Class

IconsetFinderService
Service class to detect the files of the iconsets/ in various directories.

Namespace

Drupal\social_media_links

Code

protected function setIconsets() {

  // Retrieve a list of directories.
  $directories = [];
  $nomask = [
    'CVS',
  ];
  foreach ($this->searchDirs as $dir) {
    if (is_dir($dir) && ($handle = opendir($dir))) {
      while (FALSE !== ($file = readdir($handle))) {
        if (!in_array($file, $nomask) && $file[0] != '.') {
          if (is_dir("{$dir}/{$file}")) {
            $directories[$file] = "{$dir}/{$file}";
          }
        }
      }
      closedir($handle);
    }
  }
  $this->iconsets = (array) $directories;
}