# yatra/3.0.8/app/Providers/BlockServiceProvider.php

Yatra – Travel Booking &amp; Tour Operator Software, version 3.0.8. 77 lines.

- Page: https://pluginprobe.com/plugins/yatra/3.0.8/code/app/Providers/BlockServiceProvider.php
- Raw: https://pluginprobe.com/plugins/yatra/3.0.8/raw/app/Providers/BlockServiceProvider.php
- Modified: 2026-05-12T14:25:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/yatra/3.0.8/code/app/Providers/BlockServiceProvider.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace Yatra\Providers;

use Yatra\Blocks\TourBlock;
use Yatra\Blocks\ActivityBlock;
use Yatra\Blocks\DestinationBlock;
use Yatra\Blocks\TripCategoryBlock;
use Yatra\Core\Container;
use Yatra\Core\ServiceProvider;

/**
 * Block Service Provider
 * 
 * Registers all Gutenberg blocks for Yatra
 * Maintains backward compatibility with old plugin blocks
 * 
 * @package Yatra\Providers
 * @since 3.0.0
 */
class BlockServiceProvider extends ServiceProvider
{
    public function __construct(Container $container)
    {
        parent::__construct($container);
    }

    /**
     * Register blocks
     */
    public function register(): void
    {
        // Priority 100 so other plugins (or old stubs) register first; we reclaim + register full assets last.
        if (did_action('init')) {
            $this->registerBlocksOnInit();
        } else {
            add_action('init', [$this, 'registerBlocksOnInit'], 100);
        }
        
        // Register Yatra block category
        add_filter('block_categories_all', [$this, 'registerBlockCategory'], 10, 2);
    }
    
    /**
     * Register blocks on init hook
     */
    public function registerBlocksOnInit(): void
    {
        // Initialize all blocks
        new TourBlock();
        new ActivityBlock();
        new DestinationBlock();
        new TripCategoryBlock();
    }
    
    /**
     * Register Yatra block category
     * 
     * @param array $categories Existing block categories
     * @param \WP_Block_Editor_Context|null $context Block editor context
     * @return array Modified categories
     */
    public function registerBlockCategory(array $categories, ?\WP_Block_Editor_Context $context = null): array
    {
        // Add Yatra category at the beginning
        array_unshift($categories, [
            'slug' => 'yatra',
            'title' => __('Yatra', 'yatra'),
            'icon' => '<svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M12 2L2 7v10c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V7l-10-5z" fill="currentColor"/></svg>',
        ]);
        
        return $categories;
    }
}

```
