/**
  * @param Tx_Smoothmigration_Domain_Model_Issue $issue
  *
  * @return string
  */
 public function getSolution(Tx_Smoothmigration_Domain_Model_Issue $issue)
 {
     if (is_string($issue->getAdditionalInformation())) {
         $additionalInformation = unserialize($issue->getAdditionalInformation());
     } else {
         $additionalInformation = $issue->getAdditionalInformation();
     }
     switch ($additionalInformation['type']) {
         case 'configuration':
             $result = $this->ll('result.typo3-database-database-utf8.databaseServerSetting', array($additionalInformation['setting'], $additionalInformation['actualValue'], $additionalInformation['preferredValue']));
             break;
         case 'databaseCollation':
             $result = $this->ll('result.typo3-database-database-utf8.databaseCollation', array($additionalInformation['characterSet'], $additionalInformation['defaultCollation'], 'utf8', 'utf8_general_ci'));
             break;
         case 'tableCollation':
             $result = $this->ll('result.typo3-database-database-utf8.databaseTableCollation', array($additionalInformation['tableName'], $additionalInformation['tableCollation'], 'utf8_general_ci'));
             break;
         case 'columnCollation':
             $result = $this->ll('result.typo3-database-database-utf8.databaseColumnCollation', array($additionalInformation['tableName'], $additionalInformation['columnName'], $additionalInformation['characterSetName'], $additionalInformation['collationName']));
             break;
         default:
             $result = '';
     }
     return $result;
 }
 /**
  * @param Tx_Smoothmigration_Domain_Model_Issue $issue
  *
  * @return string
  */
 public function getRawTextForCopyPaste(Tx_Smoothmigration_Domain_Model_Issue $issue)
 {
     $information = $issue->getAdditionalInformation();
     $originalClass = $information['ORIGINAL_CLASS'];
     $newClass = $information['IMPLEMENTATION_CLASS'];
     return $this->ll('result.typo3-core-code-xclasses.raw', array($originalClass, $newClass));
 }
 /**
  * @param Tx_Smoothmigration_Domain_Model_Issue $issue
  *
  * @return mixed
  */
 public function render($issue)
 {
     $check = Tx_Smoothmigration_Service_Check_Registry::getInstance()->getActiveCheckByIdentifier($issue->getInspection());
     if ($check !== NULL) {
         $this->templateVariableContainer->add('explanation', $check->getResultAnalyzer()->getExplanation($issue));
         $this->templateVariableContainer->add('solution', $check->getResultAnalyzer()->getSolution($issue));
         $content = $this->renderChildren();
         $this->templateVariableContainer->remove('explanation');
         $this->templateVariableContainer->remove('solution');
     }
     return $content;
 }
 /**
  * Execute the check
  *
  * @return void
  */
 public function execute()
 {
     $regularExpression = $this->generateRegularExpression();
     if (trim($regularExpression)) {
         if ($this->getExtensionKey()) {
             $locations = Tx_Smoothmigration_Utility_FileLocatorUtility::searchInExtension($this->getExtensionKey(), '.*\\.(php|inc)$', $regularExpression);
         } else {
             $locations = Tx_Smoothmigration_Utility_FileLocatorUtility::searchInExtensions('.*\\.(php|inc)$', $regularExpression);
         }
         foreach ($locations as $location) {
             $issue = new Tx_Smoothmigration_Domain_Model_Issue($this->parentCheck->getIdentifier(), $location);
             $issue->setAdditionalInformation($this->getRepleacabilityReport($location));
             $this->issues[] = $issue;
         }
     }
 }
 /**
  * Execute the check
  * @return void
  */
 public function execute()
 {
     $characterSets = $this->getMySqlCharacterSets();
     $preferredCharacterSets = array('character_set_connection' => 'utf8', 'character_set_database' => 'utf8', 'character_set_server' => 'utf8');
     foreach ($characterSets as $key => $characterSet) {
         if (array_key_exists($key, $preferredCharacterSets)) {
             if ($characterSet !== $preferredCharacterSets[$key]) {
                 $physicalLocation = new Tx_Smoothmigration_Domain_Model_IssueLocation_Database(TYPO3_db_username . '@' . TYPO3_db_host . '/' . TYPO3_db);
                 $details = new Tx_Smoothmigration_Domain_Model_IssueLocation_Configuration(Tx_Smoothmigration_Domain_Model_IssueLocation_Configuration::TYPE_DATABASESERVER, TYPO3_db_username . '@' . TYPO3_db_host . '/' . TYPO3_db . ': ' . $key, $characterSet, $physicalLocation);
                 $issue = new Tx_Smoothmigration_Domain_Model_Issue($this->parentCheck->getIdentifier(), $details);
                 $issue->setAdditionalInformation(array('type' => 'configuration', 'setting' => $key, 'preferredValue' => $preferredCharacterSets[$key], 'actualValue' => $characterSet));
                 $this->issues[] = $issue;
             }
         }
     }
     $dbCharsetCollation = $this->getDatabaseCharsetAndCollation();
     $allowedCollations = array('utf8_general_ci', 'utf8_unicode_ci', 'utf8_general_cs', 'utf8_unicode_cs', 'utf8_bin');
     $physicalLocation = new Tx_Smoothmigration_Domain_Model_IssueLocation_Database(TYPO3_db_username . '@' . TYPO3_db_host . '/' . TYPO3_db);
     if ($dbCharsetCollation['characterSet'] !== 'utf8' or !in_array($dbCharsetCollation['defaultCollation'], $allowedCollations)) {
         $key = 'databaseCharacterset';
         $details = new Tx_Smoothmigration_Domain_Model_IssueLocation_Configuration(Tx_Smoothmigration_Domain_Model_IssueLocation_Configuration::TYPE_DATABASE, TYPO3_db_username . '@' . TYPO3_db_host . '/' . TYPO3_db . ': ' . $key, $key, $physicalLocation);
         $issue = new Tx_Smoothmigration_Domain_Model_Issue($this->parentCheck->getIdentifier(), $details);
         $issue->setAdditionalInformation(array('type' => 'databaseCollation', 'characterSet' => $dbCharsetCollation['characterSet'], 'defaultCollation' => $dbCharsetCollation['defaultCollation']));
         $this->issues[] = $issue;
     }
     $tableCollations = $this->getTableCollations();
     foreach ($tableCollations as $collationInfo) {
         $key = $collationInfo['table_name'] . '#' . $collationInfo['collation_name'];
         $physicalLocation = new Tx_Smoothmigration_Domain_Model_IssueLocation_Database(TYPO3_db_username . '@' . TYPO3_db_host . '/' . TYPO3_db);
         $details = new Tx_Smoothmigration_Domain_Model_IssueLocation_Configuration(Tx_Smoothmigration_Domain_Model_IssueLocation_Configuration::TYPE_DATABASE, TYPO3_db_username . '@' . TYPO3_db_host . '/' . TYPO3_db . ': ' . $key, $key, $physicalLocation);
         $issue = new Tx_Smoothmigration_Domain_Model_Issue($this->parentCheck->getIdentifier(), $details);
         $issue->setAdditionalInformation(array('type' => 'tableCollation', 'tableName' => $collationInfo['table_name'], 'tableCollation' => $collationInfo['table_collation']));
         $this->issues[] = $issue;
     }
     $columnCollations = $this->getColumnCollations();
     foreach ($columnCollations as $collationInfo) {
         $key = $collationInfo['table_name'] . '#' . $collationInfo['column_name'] . '#' . $collationInfo['character_set_name'] . '#' . $collationInfo['collation_name'];
         $physicalLocation = new Tx_Smoothmigration_Domain_Model_IssueLocation_Database(TYPO3_db_username . '@' . TYPO3_db_host . '/' . TYPO3_db);
         $details = new Tx_Smoothmigration_Domain_Model_IssueLocation_Configuration(Tx_Smoothmigration_Domain_Model_IssueLocation_Configuration::TYPE_DATABASE, TYPO3_db_username . '@' . TYPO3_db_host . '/' . TYPO3_db . ': ' . $key, $key, $physicalLocation);
         $issue = new Tx_Smoothmigration_Domain_Model_Issue($this->parentCheck->getIdentifier(), $details);
         $issue->setAdditionalInformation(array('type' => 'columnCollation', 'tableName' => $collationInfo['table_name'], 'columnName' => $collationInfo['column_name'], 'characterSetName' => $collationInfo['character_set_name'], 'collationName' => $collationInfo['collation_name']));
         $this->issues[] = $issue;
     }
 }
 /**
  * Handle issue
  *
  * @param Tx_Smoothmigration_Domain_Model_Issue $issue
  *
  * @return void
  */
 protected function handleIssue(Tx_Smoothmigration_Domain_Model_Issue $issue)
 {
     if (is_string($issue->getLocationInfo())) {
         $locationInfo = unserialize($issue->getLocationInfo());
     } else {
         $locationInfo = $issue->getLocationInfo();
     }
     $physicalLocation = $locationInfo->getPhysicalLocation();
     // first retrieve the old ext_localconf.php that contained the xclass
     $physicalPath = str_replace('EXT:', 'ext/', $physicalLocation->getFilePath());
     if (file_exists(PATH_site . 'typo3conf/' . $physicalPath)) {
         $physicalPath = PATH_site . 'typo3conf/' . $physicalPath;
     } elseif (file_exists(PATH_site . 'typo3/sys' . $physicalPath)) {
         $physicalPath = PATH_site . 'typo3/sys' . $physicalPath;
     } elseif (file_exists(PATH_site . $physicalPath)) {
         $physicalPath = PATH_site . $physicalPath;
     } else {
         return;
     }
     $additionalInfo = $issue->getAdditionalInformation();
     $extPath = substr(0, -17, $physicalPath);
     if (file_exists(substr(0, -4, $physicalPath) . '.obsolete.php')) {
         // if it has already been processed, because it contains more than just one xclass, rebuild the new ext_localconf.php and ext_autoload.php by adding the current classes etc
         $xClasses = (require $extPath . 'ext_autoload.php');
         $extLocalconfSource = substr(0, -2, file_get_contents($physicalPath));
         $xClasses[$additionalInfo['IMPLEMENTATION_CLASS']] = $additionalInfo['IMPLEMENTATION_CLASS_FILENAME'];
         $extLocalconfSource .= '$GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'Objects\'][\'' . $additionalInfo['ORIGINAL_CLASS'] . '\'] = array(\'className\' => \'' . $additionalInfo['IMPLEMENTATION_CLASS'] . '\');' . "\n?>";
         file_put_contents($physicalPath, $extLocalconfSource);
         unset($extLocalconfSource);
         $newAutoloadSource = '<?php return array(' . "\n";
         foreach ($xClasses as $xclass => $path) {
             $newAutoloadSource .= '\'' . $xclass . '\' => \'' . $path . '\',' . "\n";
         }
         file_put_contents($extPath . 'ext_autoload.php', $newAutoloadSource . '); ?>');
     } else {
         // else rename the ext_localconf.php and create a new one with the new style and also create the ext_autoload.php
         rename($physicalPath, substr(0, -4, $physicalPath) . '.obsolete.php');
         $extLocalconfSource = "<?php\n" . '$GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'Objects\'][\'' . $additionalInfo['ORIGINAL_CLASS'] . '\'] = array(\'className\' => \'' . $additionalInfo['IMPLEMENTATION_CLASS'] . '\');' . "\n?>";
         file_put_contents($physicalPath, $extLocalconfSource);
         $xClassCode = "<php\n" . 'return array(\'' . $additionalInfo['IMPLEMENTATION_CLASS'] . '\'=> \'' . $additionalInfo['IMPLEMENTATION_CLASS_FILENAME'] . '\',);' . "\n?>";
         file_put_contents($extPath . 'ext_autoload.php', $xClassCode);
     }
 }
 /**
  * Perform the actual replacement
  *
  * @param Tx_Smoothmigration_Domain_Model_Issue $issue
  * @param object $locationInfo
  *
  * @return boolean
  */
 protected function performReplacement(Tx_Smoothmigration_Domain_Model_Issue $issue, $locationInfo)
 {
     $search = trim($locationInfo->getMatchedString());
     $replacement = trim($search, ')') . ', \'' . $issue->getExtension() . '\')';
     $this->messageService->message($locationInfo->getFilePath() . ' line: ' . $locationInfo->getLineNumber() . LF . 'Replacing [' . $search . '] =>' . ' [' . $replacement . ']');
     if ($issue->getMigrationStatus() != 0) {
         $this->messageService->successMessage('already migrated', TRUE);
         return;
     }
     if (!file_exists($locationInfo->getFilePath())) {
         $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::ERROR_FILE_NOT_FOUND);
         $this->messageService->errorMessage('Error, file not found', TRUE);
         return;
     }
     if (!is_writable($locationInfo->getFilePath())) {
         $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::ERROR_FILE_NOT_WRITABLE);
         $this->messageService->errorMessage('Error, file not writable', TRUE);
         return;
     }
     $fileObject = new SplFileObject($locationInfo->getFilePath());
     $newFileContent = '';
     foreach ($fileObject as $lineNumber => $lineContent) {
         if ($lineNumber + 1 != $locationInfo->getLineNumber()) {
             $newFileContent .= $lineContent;
         } else {
             $newLineContent = str_replace($search, $replacement, $lineContent);
             if (!strstr($newLineContent, $replacement)) {
                 $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::ERROR_FILE_NOT_CHANGED);
                 $this->messageService->errorMessage($this->ll('migrationsstatus.4'), TRUE);
                 return;
             }
             $newFileContent .= $newLineContent;
         }
     }
     file_put_contents($locationInfo->getFilePath(), $newFileContent);
     $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::SUCCESS);
     $this->messageService->successMessage('Succes' . LF, TRUE);
 }
 /**
  * Handle issue
  *
  * @param Tx_Smoothmigration_Domain_Model_Issue $issue
  * @return void
  */
 protected function handleIssue(Tx_Smoothmigration_Domain_Model_Issue $issue)
 {
     if (is_string($issue->getLocationInfo())) {
         $locationInfo = unserialize($issue->getLocationInfo());
     } else {
         $locationInfo = $issue->getLocationInfo();
     }
     $this->messageService->message($locationInfo->getFilePath() . ':' . $locationInfo->getLineNumber() . ' [' . trim($locationInfo->getMatchedString()) . '] => ');
     if ($issue->getMigrationStatus() != 0) {
         $this->messageService->successMessage('already migrated', TRUE);
         return;
     }
     $newFileContent = '';
     if (!file_exists($locationInfo->getFilePath())) {
         $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::ERROR_FILE_NOT_FOUND);
         $this->messageService->errorMessage('Error, file not found', TRUE);
         return;
     }
     if (!is_writable($locationInfo->getFilePath())) {
         $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::ERROR_FILE_NOT_WRITABLE);
         $this->messageService->errorMessage('Error, file not writable', TRUE);
         return;
     }
     $fileObject = new SplFileObject($locationInfo->getFilePath());
     // If more than one line needs to be removed from the same file, only the
     // first would succeed as the line numbering will change after removing
     // the first line. Therefore we need to keep track of the number of lines
     // removed per file. We use this offset to read the file.
     $lineOffset = $this->locationCounters[$locationInfo->getFilePath()];
     foreach ($fileObject as $lineNumber => $lineContent) {
         if ($lineNumber + 1 + $lineOffset != $locationInfo->getLineNumber()) {
             $newFileContent .= $lineContent;
         } else {
             $newLineContent = str_replace($locationInfo->getMatchedString(), LF, $lineContent);
             if ($newLineContent == $lineContent) {
                 $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::ERROR_FILE_NOT_CHANGED);
                 $this->messageService->errorMessage($this->ll('migrationsstatus.4'), TRUE);
                 return;
             }
             $newFileContent .= $newLineContent;
         }
     }
     file_put_contents($locationInfo->getFilePath(), $newFileContent);
     $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::SUCCESS);
     $this->messageService->successMessage('Succes', TRUE);
     if (!isset($this->locationCounters[$locationInfo->getFilePath()])) {
         $this->locationCounters[$locationInfo->getFilePath()] = 1;
     } else {
         $this->locationCounters[$locationInfo->getFilePath()]++;
     }
 }
 /**
  * @param Tx_Smoothmigration_Domain_Model_Issue $issue
  *
  * @return string
  */
 public function getSolution(Tx_Smoothmigration_Domain_Model_Issue $issue)
 {
     return $this->ll('result.typo3-core-code-namespace.solution', array($issue->getLocation()->getMatchedString(), $issue->getLocation()->getFilePath(), $issue->getLocation()->getLineNumber()));
 }
 /**
  * Handle issue
  *
  * @param Tx_Smoothmigration_Domain_Model_Issue $issue
  * @return void
  */
 protected function handleIssue(Tx_Smoothmigration_Domain_Model_Issue $issue)
 {
     if (is_string($issue->getLocationInfo())) {
         $locationInfo = unserialize($issue->getLocationInfo());
     } else {
         $locationInfo = $issue->getLocationInfo();
     }
     if (is_string($issue->getAdditionalInformation())) {
         $additionalInformation = unserialize($issue->getAdditionalInformation());
     } else {
         $additionalInformation = $issue->getAdditionalInformation();
     }
     $allowedCollations = array('utf8_general_ci', 'utf8_unicode_ci', 'utf8_general_cs', 'utf8_unicode_cs', 'utf8_bin');
     switch ($additionalInformation['type']) {
         case 'configuration':
             $this->messageService->message($this->ll('result.typo3-database-database-utf8.databaseServerSetting', array($additionalInformation['setting'], $additionalInformation['actualValue'], $additionalInformation['preferredValue'])));
             $this->messageService->warningMessage($this->ll('migration.manualInterventionNeeded'), TRUE);
             $this->messageService->message();
             break;
         case 'databaseCollation':
             $this->messageService->message($this->ll('result.typo3-database-database-utf8.databaseCollation', array($additionalInformation['characterSet'], $additionalInformation['defaultCollation'])));
             $collation = 'utf8_general_ci';
             if (in_array($additionalInformation['defaultCollation'], $allowedCollations)) {
                 $collation = $additionalInformation['defaultCollation'];
             }
             if ($issue->getMigrationStatus() != 0) {
                 $this->messageService->successMessage($this->ll('migration.alreadyMigrated'), TRUE);
                 return;
             }
             $query = 'ALTER DATABASE CHARACTER SET utf8 COLLATE ' . $collation . ';';
             $this->messageService->message($this->ll('migration.executingQuery', array($query)));
             $GLOBALS['TYPO3_DB']->sql_query($query);
             if ($sqlError = $GLOBALS['TYPO3_DB']->sql_error()) {
                 $this->messageService->errorMessage($sqlError . LF, TRUE);
             }
             $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::SUCCESS);
             $this->messageService->successMessage($this->ll('migrationsstatus.1') . LF, TRUE);
             break;
         case 'tableCollation':
             $this->messageService->message($this->ll('result.typo3-database-database-utf8.databaseTableCollation', array($additionalInformation['tableName'], $additionalInformation['tableCollation'], 'utf8_general_ci')));
             if ($issue->getMigrationStatus() != 0) {
                 $this->messageService->successMessage($this->ll('migration.alreadyMigrated'), TRUE);
                 return;
             }
             $query = 'ALTER TABLE `' . $additionalInformation['tableName'] . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;';
             $this->messageService->message($this->ll('migration.executingQuery', array($query)));
             $GLOBALS['TYPO3_DB']->sql_query($query);
             if ($sqlError = $GLOBALS['TYPO3_DB']->sql_error()) {
                 $this->messageService->errorMessage($sqlError . LF, TRUE);
             } else {
                 $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::SUCCESS);
                 $this->messageService->successMessage($this->ll('migrationsstatus.1') . LF, TRUE);
             }
             break;
         case 'columnCollation':
             $this->messageService->message($this->ll('result.typo3-database-database-utf8.databaseColumnCollation', array($additionalInformation['tableName'], $additionalInformation['columnName'], $additionalInformation['characterSetName'], $additionalInformation['collationName'])));
             if ($issue->getMigrationStatus() != 0) {
                 $this->messageService->successMessage($this->ll('migration.alreadyMigrated'), TRUE);
                 return;
             }
             $query = 'ALTER TABLE `' . $additionalInformation['tableName'] . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;';
             $this->messageService->message($this->ll('migration.executingQuery', array($query)));
             $GLOBALS['TYPO3_DB']->sql_query($query);
             if ($sqlError = $GLOBALS['TYPO3_DB']->sql_error()) {
                 $this->messageService->errorMessage($sqlError . LF, TRUE);
             } else {
                 $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::SUCCESS);
                 $this->messageService->successMessage($this->ll('migrationsstatus.1') . LF, TRUE);
             }
             break;
         default:
     }
 }
 /**
  * @param string $context
  * @param string $targetClass
  * @param string $implementationClass
  * @param string $extKey
  *
  * @return Tx_Smoothmigration_Domain_Model_Issue
  */
 protected function createIssue($context, $targetClass, $implementationClass, $extKey)
 {
     $physicalLocation = new Tx_Smoothmigration_Domain_Model_IssueLocation_File($extKey, 'EXT:' . $extKey . '/ext_localconf.php');
     $details = new Tx_Smoothmigration_Domain_Model_IssueLocation_Configuration(Tx_Smoothmigration_Domain_Model_IssueLocation_Configuration::TYPE_PHP, '$GLOBALS[TYPO3_CONF_VARS][' . $context . '][XCLASS][' . $targetClass . ']', $implementationClass, $physicalLocation);
     // Cut off any possibly leading slash
     $targetClass = ltrim($targetClass, '/');
     if (file_exists(PATH_site . 'typo3conf/' . $targetClass)) {
         $originalFilePath = PATH_site . 'typo3conf/' . $targetClass;
     } elseif (file_exists(PATH_site . 'typo3/sys/' . $targetClass)) {
         $originalFilePath = PATH_site . 'typo3/sys/' . $targetClass;
     } elseif (file_exists(PATH_site . 'typo3/sysext/cms/' . $targetClass)) {
         $originalFilePath = PATH_site . 'typo3/sysext/cms/' . $targetClass;
     } else {
         $originalFilePath = PATH_site . $targetClass;
     }
     $originalClass = $this->getFirstClassInFile($originalFilePath);
     $xClass = $this->getFirstClassInFile($implementationClass);
     $issue = new Tx_Smoothmigration_Domain_Model_Issue($this->parentCheck->getIdentifier(), $details);
     $issue->setAdditionalInformation(array('ORIGINAL_CLASS_FILENAME' => $targetClass, 'IMPLEMENTATION_CLASS_FILENAME' => $implementationClass, 'ORIGINAL_CLASS' => $originalClass, 'IMPLEMENTATION_CLASS' => $xClass));
     return $issue;
 }
 /**
  * @param Tx_Smoothmigration_Domain_Model_Issue $issue
  *
  * @return string
  */
 public function getSolution(Tx_Smoothmigration_Domain_Model_Issue $issue)
 {
     return $this->ll('result.typo3-core-code-missingaddpluginparameter.solution', array($issue->getLocation()->getExtension(), $issue->getLocation()->getMinimumVersion(), $issue->getLocation()->getMaximumVersion()));
 }
 /**
  * Add an issue
  *
  * @param Tx_Smoothmigration_Domain_Model_Issue $object
  *
  * @return void
  */
 public function add($object)
 {
     if ($GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'tx_smoothmigration_domain_model_issue', 'inspection = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($object->getInspection(), 'tx_smoothmigration_domain_model_issue') . ' AND identifier = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($object->getIdentifier(), 'tx_smoothmigration_domain_model_issue')) == 0) {
         parent::add($object);
     }
 }
 /**
  *
  * @param Tx_Smoothmigration_Domain_Model_Issue $issue
  * @param object $locationInfo
  * @param array $additionalInformation
  * @return void
  */
 protected function performReplacement(Tx_Smoothmigration_Domain_Model_Issue $issue, $locationInfo, $additionalInformation)
 {
     $concatenator = '::';
     if ($additionalInformation['replacementClass'] == '$GLOBALS[\'TYPO3_DB\']') {
         $concatenator = '->';
     }
     // Some replacements are plain PHP functions
     if ($additionalInformation['replacementClass'] == '') {
         $concatenator = '';
     }
     $this->messageService->message($locationInfo->getFilePath() . ' line: ' . $locationInfo->getLineNumber() . LF . 'Replacing [' . trim($locationInfo->getMatchedString()) . '] =>' . ' [' . $additionalInformation['replacementClass'] . $concatenator . $additionalInformation['replacementMethod'] . '(]');
     if ($issue->getMigrationStatus() != 0) {
         $this->messageService->successMessage('already migrated', TRUE);
         return;
     }
     if (!file_exists($locationInfo->getFilePath())) {
         $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::ERROR_FILE_NOT_FOUND);
         $this->messageService->errorMessage('Error, file not found', TRUE);
         return;
     }
     if (!is_writable($locationInfo->getFilePath())) {
         $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::ERROR_FILE_NOT_WRITABLE);
         $this->messageService->errorMessage('Error, file not writable', TRUE);
         return;
     }
     $fileObject = new SplFileObject($locationInfo->getFilePath());
     $isRegexReplace = !empty($additionalInformation['regexSearch']) && !empty($additionalInformation['regexReplace']);
     if ($isRegexReplace) {
         // When we have a semi-colon, we should assume its a new line
         $linesToReplace = count(explode(';', $additionalInformation['regexSearch']));
     } else {
         $linesToReplace = 1;
     }
     $contentBefore = '';
     $contentToProcess = '';
     $contentAfter = '';
     foreach ($fileObject as $lineNumber => $lineContent) {
         if ($lineNumber + 1 < $locationInfo->getLineNumber()) {
             $contentBefore .= $lineContent;
         } elseif ($lineNumber + 1 < $locationInfo->getLineNumber() + $linesToReplace) {
             $contentToProcess .= $lineContent;
         } else {
             $contentAfter .= $lineContent;
         }
     }
     if ($isRegexReplace) {
         $newContent = preg_replace($additionalInformation['regexSearch'], $additionalInformation['regexReplace'], $contentToProcess);
     } else {
         $replacement = $additionalInformation['replacementClass'] . $concatenator . $additionalInformation['replacementMethod'] . '(';
         $newContent = str_replace($locationInfo->getMatchedString(), $replacement, $contentToProcess);
     }
     if ($newContent == $contentToProcess) {
         $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::ERROR_FILE_NOT_CHANGED);
         $this->messageService->errorMessage($this->ll('migrationsstatus.4'), TRUE);
         return;
     }
     file_put_contents($locationInfo->getFilePath(), $contentBefore . $newContent . $contentAfter);
     $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::SUCCESS);
     $this->messageService->successMessage('Succes' . LF, TRUE);
 }
 /**
  * @param Tx_Smoothmigration_Domain_Model_Issue $issue
  *
  * @return string
  */
 public function getSolution(Tx_Smoothmigration_Domain_Model_Issue $issue)
 {
     return $this->ll('result.typo3-extension-code-obsolete.solution', array($issue->getLocation()->getExtension()));
 }
 /**
  * @param Tx_Smoothmigration_Domain_Model_Issue $issue
  *
  * @return string
  */
 public function getSolution(Tx_Smoothmigration_Domain_Model_Issue $issue)
 {
     return $this->ll('result.typo3-extension-code-incompatiblewithlts.solution', array($issue->getLocation()->getExtension(), $issue->getLocation()->getMinimumVersion(), $issue->getLocation()->getMaximumVersion()));
 }