Extractor Factory
The ExtractorFactory is responsible for creating and managing extractor instances based on entity types.
Overview
The ExtractorFactory serves as the central point for:
- Determining which extractor class to use for a given entity type
- Creating properly configured extractor instances
- Providing information about supported entity types
Key features:
- Uses metadata configuration to map entity types to extractor classes
- Leverages EspoCRM's dependency injection system
- Provides validation before extractor creation
Typical usage scenarios:
- Checking if an entity type has an associated extractor
- Retrieving all supported entity types
- Creating a configured extractor instance
Technické informace
ExtractorFactory Class
- Namespace:
Espo\Modules\AiParsing\Tools\Parsing\Extractors - Dependencies:
MetadataInjectableFactory- Key Methods:
isExtractor(string|Entity $entityTypeOrEntity): bool- Checks if an extractor exists for the given entity
getClassName(string|Entity $entityTypeOrEntity): ?string- Returns the extractor class name for an entity type
getExtractTargetEntityTypes(): array- Returns all entity types with extractors
create(string|Entity $entityTypeOrEntity): ?AbstractExtractor- Creates and returns a configured extractor instance
- Throws
BadRequestif no extractor exists getEntityType(string|Entity $entityTypeOrEntity): string- Helper method to normalize entity type input
Metadata Configuration
The factory reads extractor mappings from:
['app', 'aiParsing', 'extractorClassNameMap']
Where keys are entity types and values are corresponding extractor class names.