main/core/Manager/IconSetManager.php
private function extractResourceIconSetZipAndReturnNewIconItems(
        IconSet $iconSet,
        ResourceIconSetIconItemList $iconSetIconItemList
    ) {
        $ds = DIRECTORY_SEPARATOR;
        $zipFile = $iconSet->getIconsZipfile();
        $cname = $iconSet->getCname();
        $iconSetDir = $this->iconSetsWebDir.$ds.$cname;
        if (!empty($zipFile)) {
            $zipArchive = new \ZipArchive();
            if (true === $zipArchive->open($zipFile)) {
                //Test to see if a resource stamp icon is present in zip file
                $resourceStamp = $this->extractResourceStampIconFromZip($zipArchive, $iconSetDir);
                if (!empty($resourceStamp)) {
                    $iconSet->setResourceStampIcon($resourceStamp);
                    $this->om->persist($iconSet);
                    if ($iconSet->isActive()) {
                        $this->regenerateShortcutForAllResourceIcons($resourceStamp);
                    }
                }
                //List filenames and extract all files without subfolders
                for ($i = 0; $i < $zipArchive->numFiles; ++$i) {
                    $file = $zipArchive->getNameIndex($i);
                    $fileinfo = pathinfo($file);
                    $filename = $fileinfo['filename'];
                    //If file associated with one of mimeTypes then extract it. Otherwise don't
                    $alreadyInSet = $iconSetIconItemList->isInSetIcons($filename);
                    $iconItemFilenameList = $alreadyInSet ?
                        $iconSetIconItemList->getSetIcons() :
                        $iconSetIconItemList->getDefaultIcons();
                    $iconNameTypes = $iconItemFilenameList->getItemByKey($filename);
                    if (!empty($iconNameTypes)) {
                        $iconPath = $iconSetDir.$ds.$fileinfo['basename'];
                        $this->fs->remove($iconSetDir.DIRECTORY_SEPARATOR.$fileinfo['basename']);
                        $zipArchive->extractTo($iconSetDir, [$file]);

                        foreach ($iconNameTypes->getMimeTypes() as $type) {
                            // If icon don't exist, create it, otherwise update it's url in case of extension change
                            $icon = $iconItemFilenameList->getIconByMimeType($type);
                            if (!$alreadyInSet) {
                                $resourceIcon = $icon->getResourceIcon();
                                $this->createIconItemForResourceIconSet(
                                    $iconSet,
                                    $this->getRelativePathForResourceIcon($iconPath),
                                    $resourceIcon
                                );
                            } else {
                                $this->updateIconItemForResourceIconSet(
                                    $iconSet,
                                    $this->getRelativePathForResourceIcon($iconPath),
                                    $icon
                                );
                            }
                        }
                    }
                }
                $zipArchive->close();
            }
        }
    }
private function extractResourceIconSetZipAndReturnNewIconItems(
        IconSet $iconSet,
        ResourceIconSetIconItemList $iconSetIconItemList
    ) {
        $ds = DIRECTORY_SEPARATOR;
        $zipFile = $iconSet->getIconsZipfile();
        $cname = $iconSet->getCname();
        $iconSetDir = $this->iconSetsWebDir.$ds.$cname;
        if (!empty($zipFile)) {
            $zipArchive = new \ZipArchive();
            if (true === $zipArchive->open($zipFile)) {
                //Test to see if a resource stamp icon is present in zip file
                $resourceStamp = $this->extractResourceStampIconFromZip($zipArchive, $iconSetDir);
                if (!empty($resourceStamp)) {
                    $iconSet->setResourceStampIcon($resourceStamp);
                    $this->om->persist($iconSet);
                    if ($iconSet->isActive()) {
                        $this->regenerateShortcutForAllResourceIcons($resourceStamp);
                    }
                }
                //List filenames and extract all files without subfolders
                for ($i = 0; $i < $zipArchive->numFiles; ++$i) {
                    $file = $zipArchive->getNameIndex($i);
                    $fileinfo = pathinfo($file);
                    $filename = $fileinfo['filename'];
                    //If file associated with one of mimeTypes then extract it. Otherwise don't
                    $alreadyInSet = $iconSetIconItemList->isInSetIcons($filename);
                    $iconItemFilenameList = $alreadyInSet ?
                        $iconSetIconItemList->getSetIcons() :
                        $iconSetIconItemList->getDefaultIcons();
                    $iconNameTypes = $iconItemFilenameList->getItemByKey($filename);
                    if (!empty($iconNameTypes)) {
                        $iconPath = $iconSetDir.$ds.$fileinfo['basename'];
                        $this->fs->remove($iconSetDir.DIRECTORY_SEPARATOR.$fileinfo['basename']);
                        $zipArchive->extractTo($iconSetDir, [$file]);

                        foreach ($iconNameTypes->getMimeTypes() as $type) {
                            // If icon don't exist, create it, otherwise update it's url in case of extension change
                            $icon = $iconItemFilenameList->getIconByMimeType($type);
                            if (!$alreadyInSet) {
                                $resourceIcon = $icon->getResourceIcon();
                                $this->createIconItemForResourceIconSet(
                                    $iconSet,
                                    $this->getRelativePathForResourceIcon($iconPath),
                                    $resourceIcon
                                );
                            } else {
                                $this->updateIconItemForResourceIconSet(
                                    $iconSet,
                                    $this->getRelativePathForResourceIcon($iconPath),
                                    $icon
                                );
                            }
                        }
                    }
                }
                $zipArchive->close();
            }
        }
    }
private function extractResourceIconSetZipAndReturnNewIconItems ( IconSet $ iconSet , ResourceIconSetIconItemList $ iconSetIconItemList ) { $ ds = DIRECTORY_SEPARATOR ; $ zipFile = $ iconSet -> getIconsZipfile ( ) ; $ cname = $ iconSet -> getCname ( ) ; $ iconSetDir = $ this -> iconSetsWebDir . $ ds . $ cname ; if ( ! empty ( $ zipFile ) ) { $ zipArchive = new \ ZipArchive ( ) ; if ( true === $ zipArchive -> open ( $ zipFile ) ) { //Test to see if a resource stamp icon is present in zip file $ resourceStamp = $ this -> extractResourceStampIconFromZip ( $ zipArchive , $ iconSetDir ) ; if ( ! empty ( $ resourceStamp ) ) { $ iconSet -> setResourceStampIcon ( $ resourceStamp ) ; $ this -> om -> persist ( $ iconSet ) ; if ( $ iconSet -> isActive ( ) ) { $ this -> regenerateShortcutForAllResourceIcons ( $ resourceStamp ) ; } } //List filenames and extract all files without subfolders for ( $ i = 0 ; $ i < $ zipArchive -> numFiles ; ++ $ i ) { $ file = $ zipArchive -> getNameIndex ( $ i ) ; $ fileinfo = pathinfo ( $ file ) ; $ filename = $ fileinfo [ 'filename' ] ; //If file associated with one of mimeTypes then extract it. Otherwise don't $ alreadyInSet = $ iconSetIconItemList -> isInSetIcons ( $ filename ) ; $ iconItemFilenameList = $ alreadyInSet ? $ iconSetIconItemList -> getSetIcons ( ) : $ iconSetIconItemList -> getDefaultIcons ( ) ; $ iconNameTypes = $ iconItemFilenameList -> getItemByKey ( $ filename ) ; if ( ! empty ( $ iconNameTypes ) ) { $ iconPath = $ iconSetDir . $ ds . $ fileinfo [ 'basename' ] ; $ this -> fs -> remove ( $ iconSetDir . DIRECTORY_SEPARATOR . $ fileinfo [ 'basename' ] ) ; $ zipArchive -> extractTo ( $ iconSetDir , [ $ file ] ) ; foreach ( $ iconNameTypes -> getMimeTypes ( ) as $ type ) { // If icon don't exist, create it, otherwise update it's url in case of extension change $ icon = $ iconItemFilenameList -> getIconByMimeType ( $ type ) ; if ( ! $ alreadyInSet ) { $ resourceIcon = $ icon -> getResourceIcon ( ) ; $ this -> createIconItemForResourceIconSet ( $ iconSet , $ this -> getRelativePathForResourceIcon ( $ iconPath ) , $ resourceIcon ) ; } else { $ this -> updateIconItemForResourceIconSet ( $ iconSet , $ this -> getRelativePathForResourceIcon ( $ iconPath ) , $ icon ) ; } } } } $ zipArchive -> close ( ) ; } } }
Extracts icons from provided zipfile into iconSet directory.

@param IconSet $iconSet
@param $iconSetIconItemList

@return array
Extracts icons from provided zipfile into iconSet directory .