コード例 #1
0
 /**
  * Extracts a given zip file and installs the extension
  * As there is no information about the extension key in the zip
  * we have to use the file name to get that information
  * filename format is expected to be extensionkey_version.zip
  *
  * @param string $file Path to uploaded file
  * @param string $fileName Filename (basename) of uploaded file
  * @param boolean $overwrite Overwrite existing extension if TRUE
  * @return array
  */
 protected function getExtensionFromZipFile($file, $fileName, $overwrite = FALSE)
 {
     // Remove version and ending from filename to determine extension key
     $extensionKey = preg_replace('/_(\\d+)(\\.|\\-)(\\d+)(\\.|\\-)(\\d+)/i', '', strtolower($fileName));
     $extensionKey = substr($extensionKey, 0, strrpos($extensionKey, '.'));
     if (!$overwrite && $this->installUtility->isAvailable($extensionKey)) {
         throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Extension is already available and overwriting is disabled.', 1342864311);
     }
     $this->fileHandlingUtility->unzipExtensionFromFile($file, $extensionKey);
     $this->installUtility->install($extensionKey);
     return array('extKey' => $extensionKey);
 }
コード例 #2
0
 /**
  * Extracts a given zip file and installs the extension
  * As there is no information about the extension key in the zip
  * we have to use the file name to get that information
  * filename format is expected to be extensionkey_version.zip
  *
  * @param string $file Path to uploaded file
  * @param string $fileName Filename (basename) of uploaded file
  * @param boolean $overwrite Overwrite existing extension if TRUE
  * @return array
  * @throws ExtensionManagerException
  */
 protected function getExtensionFromZipFile($file, $fileName, $overwrite = FALSE)
 {
     // Remove version and extension from filename to determine the extension key
     $extensionKey = $this->getExtensionKeyFromFileName($fileName);
     $isExtensionAvailable = $this->installUtility->isAvailable($extensionKey);
     if (!$overwrite && $isExtensionAvailable) {
         throw new ExtensionManagerException('Extension is already available and overwriting is disabled.', 1342864311);
     }
     if ($isExtensionAvailable) {
         $this->copyExtensionFolderToTempFolder($extensionKey);
     }
     $this->removeFromOriginalPath = TRUE;
     $this->fileHandlingUtility->unzipExtensionFromFile($file, $extensionKey);
     return array('extKey' => $extensionKey);
 }
コード例 #3
0
 /**
  * Checks if an extension is available in the system
  *
  * @param string $extensionKey
  * @return bool
  */
 public function isAvailable($extensionKey)
 {
     return $this->installUtility->isAvailable($extensionKey);
 }
コード例 #4
0
 /**
  * Checks if the function exists in the system
  *
  * @param string $extensionKey The extension key
  *
  * @return void
  * @throws \InvalidArgumentException
  */
 protected function checkExtensionExists($extensionKey)
 {
     if (!$this->installUtility->isAvailable($extensionKey)) {
         throw new InvalidArgumentException(sprintf('Extension "%s" does not exist!', $extensionKey));
     }
 }