public function getCode()
 {
     if (null === $this->_code) {
         $this->_code = Engine_File_Diff::getCodeKey($this->_status);
         if (null === $this->_code) {
             $this->_code = false;
         }
     }
     return $this->_code;
 }
Example #2
0
 protected function _buildFileOperations($showAll = false)
 {
     $rightFiles = $this->getDiffTargetFiles();
     $originalFiles = $this->getDiffCurrentFiles();
     //$leftFiles = $this->getDiffMasterFiles();
     $leftFiles = array_unique(array_merge(array_keys($originalFiles), array_keys($rightFiles)));
     sort($leftFiles);
     $leftPath = $this->getManager()->getBasePath();
     $rightPath = null !== $this->getTargetPackage() ? $this->getTargetPackage()->getBasePath() : null;
     $originalPath = null !== $this->getCurrentPackage() ? $this->getCurrentPackage()->getBasePath() : null;
     $hasErrors = false;
     $fileOperations = array();
     foreach ($leftFiles as $file) {
         // Format left
         $left = $file;
         // Format right
         $right = null;
         if (isset($rightFiles[$file])) {
             if (isset($rightFiles[$file]['dir']) && $rightFiles[$file]['dir']) {
                 continue;
             }
             $right = $rightFiles[$file];
         }
         // Format original
         $original = null;
         if (!empty($originalFiles) && isset($originalFiles[$file])) {
             if (isset($originalFiles[$file]['dir']) && $originalFiles[$file]['dir']) {
                 continue;
             }
             $original = $originalFiles[$file];
         }
         $leftFormatted = $this->_formatFileData($left, $leftPath, $file);
         $rightFormatted = $this->_formatFileData($right, $rightPath, $file);
         $originalFormatted = null;
         if (!empty($originalFiles)) {
             $originalFormatted = $this->_formatFileData($original, $originalPath, $file);
         }
         // Diff
         if (null === $originalFormatted) {
             $diffResult = Engine_File_Diff::compare($leftFormatted, $rightFormatted);
         } else {
             $diffResult = Engine_File_Diff3::compare($leftFormatted, $rightFormatted, $originalFormatted);
         }
         // Show all?
         if (!$showAll && ($diffResult == Engine_File_Diff::IDENTICAL || $diffResult == Engine_File_Diff::IGNORE)) {
             continue;
         }
         // Err
         $hasError = null !== Engine_File_Diff::getErrorCodeKey($diffResult);
         $hasErrors = $hasErrors || $hasError;
         $diffInfo = array('error' => (bool) $hasError, 'key' => Engine_File_Diff::getCodeKey($diffResult), 'result' => $diffResult, 'relPath' => $left, 'leftPath' => is_array($leftFormatted) ? $leftFormatted['path'] : (is_string($leftFormatted) ? $leftFormatted : null), 'rightPath' => is_array($rightFormatted) ? $rightFormatted['path'] : (is_string($rightFormatted) ? $rightFormatted : null), 'originalPath' => is_array($originalFormatted) ? $originalFormatted['path'] : (is_string($originalFormatted) ? $originalFormatted : null));
         $fileOperations[$left] = $diffInfo;
     }
     return array('key' => $this->getKey(), 'error' => (bool) $hasErrors, 'operations' => $fileOperations);
 }