Exemplo n.º 1
0
 /**
  * Remove excluded directories from collection
  *
  * @param \Magento\Framework\Data\Collection\Filesystem $collection
  * @param array $conditions
  * @return \Magento\Framework\Data\Collection\Filesystem
  */
 protected function removeItemFromCollection($collection, $conditions)
 {
     $regExp = $conditions['reg_exp'] ? '~' . implode('|', array_keys($conditions['reg_exp'])) . '~i' : null;
     $storageRootLength = strlen($this->_cmsWysiwygImages->getStorageRoot());
     foreach ($collection as $key => $value) {
         $rootChildParts = explode('/', substr($value->getFilename(), $storageRootLength));
         if (array_key_exists($rootChildParts[1], $conditions['plain']) || $regExp && preg_match($regExp, $value->getFilename())) {
             $collection->removeItemByKey($key);
         }
     }
     return $collection;
 }