campusdomar/pmk2-cmar-sonar-bundle
Install via Composer
composer require campusdomar/pmk2-cmar-sonar-bundle
Enable the Bundle
Add to config/bundles.php:
CampusDomar\PuMuKIT2\CmarSonarBundle\CmarSonarBundle::class => ['all' => true],
Configure the Bundle
Copy default config to config/packages/cmar_sonar.yaml:
php artisan config:dump
Edit config/packages/cmar_sonar.yaml to match your PuMuKIT2 Video Platform setup.
First Use Case: Sub-Portal Integration
php artisan doctrine:migrations:migrate
/sonar (or configured route) to verify integration with the CMAR Web TV Portal.Sub-Portal Routing
config/routes/cmar_sonar.yaml:
cmar_sonar_homepage:
path: /sonar
controller: CampusDomar\PuMuKIT2\CmarSonarBundle\Controller\SonarController::index
templates/cmar_sonar/ to customize UI.Data Synchronization
SonarService to sync content with PuMuKIT2:
use CampusDomar\PuMuKIT2\CmarSonarBundle\Service\SonarService;
$sonarService = $this->container->get(SonarService::class);
$syncedContent = $sonarService->syncWithCmarPortal($portalId);
app/Console/Kernel.php):
protected function schedule(Schedule $schedule)
{
$schedule->call([$this->container->get(SonarService::class), 'syncAllPortals'])
->dailyAt('03:00');
}
Event-Driven Extensions
sonar.content.synced) in your EventSubscriber:
use CampusDomar\PuMuKIT2\CmarSonarBundle\Event\ContentSyncedEvent;
public static function getSubscribedEvents()
{
return [
ContentSyncedEvent::class => 'onContentSynced',
];
}
public function onContentSynced(ContentSyncedEvent $event)
{
// Custom logic (e.g., log, notify, or transform data)
}
API Integration
SonarApiClient to interact with CMAR Web TV Portal APIs:
$apiClient = $this->container->get('cmar_sonar.api_client');
$response = $apiClient->fetchPortalData($portalId);
Configuration Overrides
config/packages/cmar_sonar.yaml is properly merged with defaults. Use php artisan config:dump after changes.php artisan config:validate
Doctrine Migrations
php artisan doctrine:migrations:execute --up
EntityManager errors when accessing sub-portal data.Caching Quirks
php artisan cache:clear
config/packages/cmar_sonar.yaml for debugging:
cache_enabled: false
Dependency Conflicts
campusdomar/pmukit2-core-bundle. Install it first:
composer require campusdomar/pmukit2-core-bundle
composer.json:
"campusdomar/pmukit2-core-bundle": "2.1.*",
"campusdomar/pmk2-cmar-sonar-bundle": "dev-main"
Template Overrides
templates/cmar_sonar/ before clearing cache to avoid stale views.parent() function to extend base templates:
{% extends 'cmar_sonar/base.html.twig' %}
{% block content %}
{{ parent() }}
<div class="custom-content">{{ customData }}</div>
{% endblock %}
Logging and Debugging
config/packages/cmar_sonar.yaml:
debug: true
var/log/cmar_sonar.log for sync errors or API issues.Extension Points
SonarService by creating a decorator:
use CampusDomar\PuMuKIT2\CmarSonarBundle\Service\SonarServiceInterface;
class CustomSonarService implements SonarServiceInterface
{
private $decorated;
public function __construct(SonarService $decorated)
{
$this->decorated = $decorated;
}
public function syncWithCmarPortal($portalId)
{
$result = $this->decorated->syncWithCmarPortal($portalId);
// Add custom logic here
return $result;
}
}
Register the decorator in services.yaml:
services:
CampusDomar\PuMuKIT2\CmarSonarBundle\Service\SonarServiceInterface: '@custom_sonar_service'
custom_sonar_service:
class: App\Service\CustomSonarService
arguments: ['@cmar_sonar.sonar_service']
Performance
$sonarService->syncWithCmarPortal($portalId, ['batch_size' => 50]);
```markdown
## Documentation Note
The bundle’s `Resources/doc/` folder is the primary source of truth. For advanced use cases, refer to:
- `InstallationGuide.md` for environment setup.
- `Usage.md` for API/service details.
- `Events.md` for event-driven extensions.
How can I help you explore Laravel packages today?