original_string: protected function addStorageFiles()
      {
          $items = $this->package->getStorageServices();
          foreach ($items as $service => $resources) {
              if (is_string($resources)) {
                  $resources = explode(',', $resources);
              }
              foreach ($resources as $resourceName => $resource) {
                  // If reachable flag is present and service is not reachable then skip it.
                  if ($resourceName === static::REACHABLE_FLAG && $resource === false) {
                      continue;
                  }
  
                  if (Session::checkServicePermission(
                      Verbs::GET, $service, $resource, Session::getRequestor(), false
                  )) {
                      /** @type FileServiceInterface $storage */
                      $storage = ServiceManager::getService($service);
                      if (!$storage) {
                          throw new InternalServerErrorException("Can not find storage service $service.");
                      }
  
                      if ($storage->folderExists($resource)) {
                          $zippedResource = $this->getStorageFolderZip($storage, $resource);
                          if ($zippedResource !== false) {
                              $newFileName = $service . '/' . rtrim($resource, '/') . '/' . md5($resource) . '.zip';
                              $this->package->zipFile($zippedResource, $newFileName);
                              $this->destructible[] = $zippedResource;
                          }
                      } elseif ($storage->fileExists($resource)) {
                          $content = $storage->getFileContent($resource, null, false);
                          $this->package->zipContent($service . '/' . $resource, $content);
                      }
                  }
              }
          }
      }
code: protected function addStorageFiles()
      {
          $items = $this->package->getStorageServices();
          foreach ($items as $service => $resources) {
              if (is_string($resources)) {
                  $resources = explode(',', $resources);
              }
              foreach ($resources as $resourceName => $resource) {
                  // If reachable flag is present and service is not reachable then skip it.
                  if ($resourceName === static::REACHABLE_FLAG && $resource === false) {
                      continue;
                  }
  
                  if (Session::checkServicePermission(
                      Verbs::GET, $service, $resource, Session::getRequestor(), false
                  )) {
                      /** @type FileServiceInterface $storage */
                      $storage = ServiceManager::getService($service);
                      if (!$storage) {
                          throw new InternalServerErrorException("Can not find storage service $service.");
                      }
  
                      if ($storage->folderExists($resource)) {
                          $zippedResource = $this->getStorageFolderZip($storage, $resource);
                          if ($zippedResource !== false) {
                              $newFileName = $service . '/' . rtrim($resource, '/') . '/' . md5($resource) . '.zip';
                              $this->package->zipFile($zippedResource, $newFileName);
                              $this->destructible[] = $zippedResource;
                          }
                      } elseif ($storage->fileExists($resource)) {
                          $content = $storage->getFileContent($resource, null, false);
                          $this->package->zipContent($service . '/' . $resource, $content);
                      }
                  }
              }
          }
      }
code_tokens: protected function addStorageFiles ( ) { $ items = $ this -> package -> getStorageServices ( ) ; foreach ( $ items as $ service => $ resources ) { if ( is_string ( $ resources ) ) { $ resources = explode ( ',' , $ resources ) ; } foreach ( $ resources as $ resourceName => $ resource ) { // If reachable flag is present and service is not reachable then skip it. if ( $ resourceName === static :: REACHABLE_FLAG && $ resource === false ) { continue ; } if ( Session :: checkServicePermission ( Verbs :: GET , $ service , $ resource , Session :: getRequestor ( ) , false ) ) { /** @type FileServiceInterface $storage */ $ storage = ServiceManager :: getService ( $ service ) ; if ( ! $ storage ) { throw new InternalServerErrorException ( "Can not find storage service $service." ) ; } if ( $ storage -> folderExists ( $ resource ) ) { $ zippedResource = $ this -> getStorageFolderZip ( $ storage , $ resource ) ; if ( $ zippedResource !== false ) { $ newFileName = $ service . '/' . rtrim ( $ resource , '/' ) . '/' . md5 ( $ resource ) . '.zip' ; $ this -> package -> zipFile ( $ zippedResource , $ newFileName ) ; $ this -> destructible [ ] = $ zippedResource ; } } elseif ( $ storage -> fileExists ( $ resource ) ) { $ content = $ storage -> getFileContent ( $ resource , null , false ) ; $ this -> package -> zipContent ( $ service . '/' . $ resource , $ content ) ; } } } } }
docstring: Adds app files or other storage files to the package.
  
  @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
docstring_tokens: Adds app files or other storage files to the package .