You are here

function content_sync_get_content_directory in Content Synchronization 8.2

Same name and namespace in other branches
  1. 8 content_sync.module \content_sync_get_content_directory()
  2. 3.0.x content_sync.module \content_sync_get_content_directory()

Returns the path of a content directory.

Content directories are configured using $content_directories in settings.php.

Parameters

string $type: The type of content directory to return.

Return value

string The content directory path.

Throws

\Exception

7 calls to content_sync_get_content_directory()
ContentExportTrait::generateExportBatch in src/Form/ContentExportTrait.php
ContentFileStorageFactory::getActive in src/Content/ContentFileStorageFactory.php
Returns a FileStorage object working with the active content directory.
ContentFileStorageFactory::getSync in src/Content/ContentFileStorageFactory.php
Returns a FileStorage object working with the sync content directory.
ContentImportForm::buildForm in src/Form/ContentImportForm.php
Form constructor.
ContentImportForm::submitForm in src/Form/ContentImportForm.php
Form submission handler.

... See full list

File

./content_sync.module, line 176
Allows site administrators to modify content.

Code

function content_sync_get_content_directory($type) {
  global $content_directories;

  // @todo Remove fallback in Drupal 9. https://www.drupal.org/node/2574943

  /*if ($type == CONTENT_SYNC_DIRECTORY &&
    !isset($content_directories[CONTENT_SYNC_DIRECTORY])
    && isset($content_directories[CONTENT_STAGING_DIRECTORY])) {
    $type = CONTENT_STAGING_DIRECTORY;
    }*/
  if ($type == 'sync' && !isset($content_directories['sync']) && isset($content_directories['staging'])) {
    $type = 'staging';
  }
  if (!empty($content_directories[$type])) {
    return $content_directories[$type];
  }

  // @todo https://www.drupal.org/node/2696103 Throw a more specific exception.
  // throw new \Exception("The content directory type '$type' does not exist");
  \Drupal::messenger()
    ->addError("The content directory type '{$type}' does not exist");
}