campusdomar/pmk2-cmar-webtv-bundle
Install via Composer
Add the bundle to your composer.json:
composer require campusdomar/pmk2-cmar-webtv-bundle
Ensure CampusDomar\PuMuKIT2\CmarWebTVBundle\CmarWebTVBundle is registered in config/bundles.php:
return [
// ...
CampusDomar\PuMuKIT2\CmarWebTVBundle\CmarWebTVBundle::class => ['all' => true],
];
Configure the Bundle
Copy the default configuration to your config/packages/cmar_webtv.yaml:
php bin/console config:dump-reference CampusDomar\PuMuKIT2\CmarWebTVBundle\CmarWebTVBundle > config/packages/cmar_webtv.yaml
Override values (e.g., branding, API endpoints) in config/packages/cmar_webtv.yaml:
campusdomar_pumukit2_cmar_webtv:
branding:
logo_path: '%kernel.project_dir%/public/uploads/logos/cmar_logo.png'
theme_color: '#2E5B8A'
api:
base_url: 'https://your-pumukit-api.example.com'
First Use Case: Displaying the WebTV Portal
Clear the cache and access the WebTV route (default: /webtv):
php bin/console cache:clear
The bundle extends the base PuMuKIT2/WebTVBundle with Campus do Mar’s UI. Verify the portal loads with the custom theme.
Resources/doc/: Official documentation (e.g., InstallationGuide.md, AdminGuide.md).Resources/config/routing.yaml: WebTV routes (override if needed).Resources/views/: Twig templates for customizing the UI (e.g., default/index.html.twig).Customizing the UI
Override Twig templates in your project’s templates/bundles/CmarWebTV/ directory. Example:
{# templates/bundles/CmarWebTV/default/index.html.twig #}
{% extends 'CmarWebTVBundle:default:layout.html.twig' %}
{% block body %}
<div class="cmar-custom-header">
{{ parent() }}
</div>
{% endblock %}
Integrating with PuMuKIT2 API
Use the bundle’s configured API endpoint (campusdomar_pumukit2_cmar_webtv.api.base_url) to fetch video metadata:
// In a controller or service
$apiClient = $this->container->get('cmar_webtv.api_client');
$videos = $apiClient->get('/videos', ['limit' => 10]);
Adding Custom Video Fields
Extend the base Video entity by creating a custom form type and overriding the bundle’s VideoType:
# config/packages/cmar_webtv.yaml
campusdomar_pumukit2_cmar_webtv:
video:
custom_fields:
- { name: 'cmar_tags', type: 'text' }
Routing and Controllers Extend routes by creating a custom route loader:
# config/routes/cmar_webtv.yaml
cmar_webtv_custom:
resource: '@CmarWebTVBundle/Resources/config/routing/custom.yaml'
prefix: /webtv
Example custom.yaml:
cmar_webtv_playlist:
path: /playlist/{id}
controller: App\Controller\CmarWebTVController::playlistAction
symfony/flex recipes to automate bundle updates.dev/prod:
# config/packages/cmar_webtv_{env}.yaml
campusdomar_pumukit2_cmar_webtv:
debug: {% if app.environment == 'dev' %}true{% else %}false{% endif %}
VideoUploadEvent) to trigger custom logic:
// src/EventListener/CmarVideoListener.php
namespace App\EventListener;
use CampusDomar\PuMuKIT2\CmarWebTVBundle\Event\VideoUploadEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class CmarVideoListener implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return [
VideoUploadEvent::class => 'onVideoUpload',
];
}
public function onVideoUpload(VideoUploadEvent $event) {
// Custom logic (e.g., log, notify)
}
}
Missing API Configuration
/webtv.campusdomar_pumukit2_cmar_webtv.api.base_url is set correctly and the API is reachable.var/log/dev.log) for Guzzle or HttpClient errors.Template Override Conflicts
templates/bundles/CmarWebTV/default/ > vendor/campusdomar/pmk2-cmar-webtv-bundle/Resources/views/
{% debug %} in Twig to inspect loaded templates.Caching Issues
php bin/console cache:clear
php bin/console assetic:dump --watch --env=prod
Deprecated PuMuKIT2 Features
PuMuKIT2/WebTVBundle methods.Enable Debug Mode:
# config/packages/dev/cmar_webtv.yaml
campusdomar_pumukit2_cmar_webtv:
debug: true
This logs API requests/responses and template paths.
API Debugging:
Use the cmar_webtv.api_client service to inspect raw responses:
$response = $this->get('cmar_webtv.api_client')->get('/videos');
file_put_contents('debug_api_response.json', $response->getBody());
Twig Debugging: Dump variables in templates:
{% if app.debug %}
{{ dump(app.request.attributes) }}
{% endif %}
Custom Video Filters
Extend the VideoRepository by creating a custom service:
// src/Service/CmarVideoFilter.php
namespace App\Service;
use CampusDomar\PuMuKIT2\CmarWebTVBundle\Repository\VideoRepository;
class CmarVideoFilter extends VideoRepository {
public function filterByCustomTag($tag) {
// Custom logic
}
}
Register it in services.yaml:
services:
App\Service\CmarVideoFilter:
decorates: 'cmar_webtv.video_repository'
arguments: ['@cmar_webtv.video_repository.inner']
Custom Player Integration
Override the default player by extending the PlayerType:
{# templates/bundles/CmarWebTV/default/player.html.twig #}
{% extends 'CmarWebTVBundle:default:player.html.twig' %}
{% block player_script %}
{{ parent() }}
<script>
// Custom player logic (e.g., Campus do Mar analytics)
</script>
{% endblock %}
Webhook Integration Listen for PuMuKIT2 events to trigger external actions (e.g., Slack notifications):
// src/EventListener/CmarWebhookListener.php
use CampusDomar\PuMuKIT2\CmarWebTVBundle\Event\VideoUploadEvent;
use Symfony\Component\HttpClient\HttpClient;
class CmarWebhookListener {
public function __invoke(VideoUploadEvent $event) {
$client = HttpClient::create();
$client->request('POST', 'https://hooks.slack.com/...', [
'json' => ['text' => 'New video uploaded: ' . $event->getVideo()->getTitle()]
]);
}
}
How can I help you explore Laravel packages today?