original_string: protected function getNewServiceId($oldServiceId)
      {
          if (empty($oldServiceId)) {
              return null;
          }
  
          $services = $this->package->getResourceFromZip('system/service.json');
          $serviceName = null;
          foreach ($services as $service) {
              if ($oldServiceId === $service['id']) {
                  $serviceName = $service['name'];
                  break;
              }
          }
  
          if (!empty($serviceName)) {
              if (!empty($id = ServiceManager::getServiceIdByName($serviceName))) {
                  return $id;
              }
          } else {
              if (!empty($serviceName = ServiceManager::getServiceNameById($oldServiceId))) {
                  if (in_array($serviceName, ['system', 'api_docs', 'files', 'db', 'email', 'user'])) {
                      // If service is one of the pre-defined system services
                      // then new id is most likely the same as the old id.
                      return $oldServiceId;
                  }
              }
          }
  
          return null;
      }
code: protected function getNewServiceId($oldServiceId)
      {
          if (empty($oldServiceId)) {
              return null;
          }
  
          $services = $this->package->getResourceFromZip('system/service.json');
          $serviceName = null;
          foreach ($services as $service) {
              if ($oldServiceId === $service['id']) {
                  $serviceName = $service['name'];
                  break;
              }
          }
  
          if (!empty($serviceName)) {
              if (!empty($id = ServiceManager::getServiceIdByName($serviceName))) {
                  return $id;
              }
          } else {
              if (!empty($serviceName = ServiceManager::getServiceNameById($oldServiceId))) {
                  if (in_array($serviceName, ['system', 'api_docs', 'files', 'db', 'email', 'user'])) {
                      // If service is one of the pre-defined system services
                      // then new id is most likely the same as the old id.
                      return $oldServiceId;
                  }
              }
          }
  
          return null;
      }
code_tokens: protected function getNewServiceId ( $ oldServiceId ) { if ( empty ( $ oldServiceId ) ) { return null ; } $ services = $ this -> package -> getResourceFromZip ( 'system/service.json' ) ; $ serviceName = null ; foreach ( $ services as $ service ) { if ( $ oldServiceId === $ service [ 'id' ] ) { $ serviceName = $ service [ 'name' ] ; break ; } } if ( ! empty ( $ serviceName ) ) { if ( ! empty ( $ id = ServiceManager :: getServiceIdByName ( $ serviceName ) ) ) { return $ id ; } } else { if ( ! empty ( $ serviceName = ServiceManager :: getServiceNameById ( $ oldServiceId ) ) ) { if ( in_array ( $ serviceName , [ 'system' , 'api_docs' , 'files' , 'db' , 'email' , 'user' ] ) ) { // If service is one of the pre-defined system services // then new id is most likely the same as the old id. return $ oldServiceId ; } } } return null ; }
docstring: Finds and returns the new service id by old id.
  
  @param int $oldServiceId
  
  @return int|null
docstring_tokens: Finds and returns the new service id by old id .