fix(structure): Correct case-sensitivity for Linux compatibility
Rename folders to match PHP PSR-4 autoloading conventions: - schemas → Schemas - shared → Shared - Wordpress → WordPress (in all locations) Fixes deployment issues on Linux servers where filesystem is case-sensitive. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
133
Shared/Infrastructure/README.md
Normal file
133
Shared/Infrastructure/README.md
Normal file
@@ -0,0 +1,133 @@
|
||||
# Capa de Infraestructura
|
||||
|
||||
## 📋 Propósito
|
||||
|
||||
La **Capa de Infraestructura** contiene las implementaciones concretas de las interfaces definidas en el Dominio. Conecta la lógica de negocio con el mundo exterior (WordPress, MySQL, cache, HTTP).
|
||||
|
||||
## 🎯 Responsabilidades
|
||||
|
||||
- ✅ Implementar interfaces del Dominio
|
||||
- ✅ Conectar con frameworks (WordPress)
|
||||
- ✅ Persistencia (MySQL via wpdb)
|
||||
- ✅ Cache (WordPress Transients)
|
||||
- ✅ HTTP (AJAX endpoints)
|
||||
- ✅ Contiene detalles de implementación
|
||||
|
||||
## 📦 Estructura
|
||||
|
||||
```
|
||||
Infrastructure/
|
||||
├── Persistence/
|
||||
│ └── WordPress/
|
||||
│ ├── WordPressComponentRepository.php (MySQL)
|
||||
│ └── WordPressDefaultsRepository.php (Schemas)
|
||||
├── Services/
|
||||
│ ├── WordPressValidationService.php (Validación)
|
||||
│ ├── WordPressCacheService.php (Transients)
|
||||
│ ├── SchemaSyncService.php (JSON → BD)
|
||||
│ └── CleanupService.php (Limpieza)
|
||||
├── API/
|
||||
│ └── WordPress/
|
||||
│ └── AjaxController.php (Endpoints AJAX)
|
||||
├── Facades/
|
||||
│ └── ComponentManager.php (API unificada)
|
||||
├── DI/
|
||||
│ └── DIContainer.php (Dependency Injection)
|
||||
└── README.md
|
||||
```
|
||||
|
||||
## 🔌 Implementaciones
|
||||
|
||||
### Repositories
|
||||
|
||||
#### WordPressComponentRepository
|
||||
Persiste componentes en `wp_roi_theme_components`.
|
||||
|
||||
**Métodos**:
|
||||
- `save(Component)`: INSERT o UPDATE
|
||||
- `findByName(string)`: Buscar por nombre
|
||||
- `findAll()`: Obtener todos
|
||||
- `delete(string)`: Eliminar
|
||||
|
||||
#### WordPressDefaultsRepository
|
||||
Gestiona schemas en `wp_roi_theme_defaults`.
|
||||
|
||||
### Services
|
||||
|
||||
#### WordPressValidationService
|
||||
Valida datos contra schemas.
|
||||
|
||||
**Estrategia**:
|
||||
1. Obtener schema de BD
|
||||
2. Validar estructura
|
||||
3. Sanitizar con funciones WordPress
|
||||
|
||||
#### WordPressCacheService
|
||||
Cache con WordPress Transients API.
|
||||
|
||||
**TTL default**: 1 hora (3600 segundos)
|
||||
|
||||
#### SchemaSyncService
|
||||
Sincroniza schemas desde JSON a BD.
|
||||
|
||||
#### CleanupService
|
||||
Elimina componentes obsoletos.
|
||||
|
||||
### API
|
||||
|
||||
#### AjaxController
|
||||
Endpoints AJAX de WordPress.
|
||||
|
||||
**Endpoints disponibles**:
|
||||
- `roi_theme_save_component` (POST)
|
||||
- `roi_theme_get_component` (GET)
|
||||
- `roi_theme_delete_component` (POST)
|
||||
- `roi_theme_sync_schema` (POST)
|
||||
|
||||
**Seguridad**:
|
||||
- Nonce verification
|
||||
- Capability check (manage_options)
|
||||
|
||||
### Facade
|
||||
|
||||
#### ComponentManager
|
||||
API unificada para todo el sistema.
|
||||
|
||||
**Uso**:
|
||||
```php
|
||||
$manager = new ComponentManager($container);
|
||||
$result = $manager->saveComponent('top_bar', $data);
|
||||
```
|
||||
|
||||
## 📐 Principios Arquitectónicos
|
||||
|
||||
### Dependency Inversion
|
||||
|
||||
Infrastructure implementa interfaces del Domain:
|
||||
|
||||
```php
|
||||
class WordPressComponentRepository implements ComponentRepositoryInterface
|
||||
{
|
||||
// Implementación específica de WordPress
|
||||
}
|
||||
```
|
||||
|
||||
### Separación de Concerns
|
||||
|
||||
- **Repositories**: Solo persistencia
|
||||
- **Services**: Lógica de infraestructura
|
||||
- **Controller**: Solo HTTP
|
||||
- **Facade**: Orquestación simple
|
||||
|
||||
## 🧪 Testing
|
||||
|
||||
Tests de **integración** (usan BD real de WordPress):
|
||||
|
||||
```bash
|
||||
vendor\bin\phpunit tests\Integration\Infrastructure
|
||||
```
|
||||
|
||||
## 🔗 Referencias
|
||||
|
||||
- Domain Layer: `../Domain/README.md`
|
||||
- Application Layer: `../Application/README.md`
|
||||
Reference in New Issue
Block a user