Files
crm.clientright.ru/modules/SPCMLConnector/AbstractCMLParser.php
Fedor ac7467f0b4 Major CRM updates: AI Assistant, Court Status API, S3 integration improvements, and extensive file storage system
- Added comprehensive AI Assistant system (aiassist/ directory):
  * Vector search and embedding capabilities
  * Typebot proxy integration
  * Elastic search functionality
  * Message classification and chat history
  * MCP proxy for external integrations

- Implemented Court Status API (GetCourtStatus.php):
  * Real-time court document status checking
  * Integration with external court systems
  * Comprehensive error handling and logging

- Enhanced S3 integration:
  * Improved file backup system with metadata
  * Batch processing capabilities
  * Enhanced error logging and recovery
  * Copy operations with URL fixing

- Added Telegram contact creation API
- Improved error logging across all modules
- Enhanced callback system for AI responses
- Extensive backup file storage with timestamps
- Updated documentation and README files

- File storage improvements:
  * Thousands of backup files with proper metadata
  * Fix operations for broken file references
  * Project-specific backup and recovery systems
  * Comprehensive file integrity checking

Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
2025-10-16 11:17:21 +03:00

131 lines
4.1 KiB
PHP

<?php
abstract class AbstractCMLParser {
/**
* Parse offer of catalog described in xml and return CmlCatalog
* representation of parsed documents. If error on parse - throw Exception.
* @param SimpleXMLElement $offerXml
* @return CmlCatalog
*/
public abstract function parseOffer($offerXml);
/**
* Parse offer of catalog described in xml and return CmlCatalog
* representation of parsed documents. If error on parse - throw Exception.
* @param SimpleXMLElement $importXml
* @return CmlCatalog
*/
public abstract function parseImport($importXml);
/**
* Parse orders described in xml and return array of CmlSalesOrder
* @param SimpleXMLElement $ordersXml
* @return CmlSalesOrder[]
*/
public abstract function parseOrders($ordersXml);
/**
* If $rootXmlElement not have child with name $childName or it empty - return false.
* @param SimpleXmlElement $rootXmlElement
* @param String $childName
* @return boolean
*/
protected function isChildExists($rootXmlElement, $childName) {
$element = $rootXmlElement->$childName;
if(!empty($element)) {
return true;
}
return false;
}
/**
* Return child entity content. if no entity - return null.
* @param SimpleXMLElement $rootXmlElement
* @param String $childName
* @return null|String
*/
protected function getChildContent($rootXmlElement, $childName) {
if($this->isChildExists($rootXmlElement, $childName)) {
return strip_tags($rootXmlElement->$childName->asXML());
}
return null;
}
/**
* Check by props of xmlElement product type of current product.
* If no props or - product will be service.
* @param SimpleXMLElement $product
* @return boolean
*/
protected function isProduct($product) {
if($this->isChildExists($product,'ЗначенияРеквизитов')) {
$props = $product->ЗначенияРеквизитов;
foreach($props->ЗначениеРеквизита as $prop) {
$propName = $this->getChildContent($prop, 'Наименование');
$propValue = $this->getChildContent($prop, 'Значение');
if($propName == 'ТипНоменклатуры' && $propValue == 'Товар' ) {
return true;
}
}
}
return false;
}
/**
* Get first child contenct without tags. If no child or empty content -
* throw exception.
* @param SimpleXMLElement $rootXmlElement
* @param String $childName
* @param String $errorMessage
* @return String
* @throws ParseException
*/
protected function getMandatoryChildContent($rootXmlElement, $childName, $errorMessage) {
/* If tag exists but empty - condition will be true*/
if($this->isChildExists($rootXmlElement, $childName)) {
return strip_tags($rootXmlElement->$childName->asXML());
}
/* If no field or it empty */
throw new ParseException($errorMessage);
}
/**
* Returns content of xml node
* @param type $node
* @return type
*/
protected function getNodeContent($node) {
return strip_tags($node->asXML());
}
protected function filter($value) {
return str_replace("'", "", $value);
}
/*
* Check field as mandatory. If field not exists or it content empty - throw exception.
* @param SimpleXMLElement $rootXmlElement
* @param String $childName
* @param String $errorMessage
* @throws ParseException
*/
protected function checkMandatoryChildElement($rootXmlElement, $childName, $errorMessage) {
/* If tag exists but empty - condition will be true*/
if($this->isChildExists($rootXmlElement, $childName)) {
return;
}
/* If no field or it empty */
throw new ParseException($errorMessage);
}
}