PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.2.9
Yatra – Travel Booking & Tour Operator Software v3.0.2.9
3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 All 83 releases
yatra / app / Providers / BlockServiceProvider.php

BlockServiceProvider.php in Yatra – Travel Booking & Tour Operator Software 3.0.2.9, at app/Providers/BlockServiceProvider.php

75 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Yatra\Providers;
6
7 use Yatra\Blocks\TourBlock;
8 use Yatra\Blocks\ActivityBlock;
9 use Yatra\Blocks\DestinationBlock;
10 use Yatra\Core\Container;
11 use Yatra\Core\ServiceProvider;
12
13 /**
14 * Block Service Provider
15 *
16 * Registers all Gutenberg blocks for Yatra
17 * Maintains backward compatibility with old plugin blocks
18 *
19 * @package Yatra\Providers
20 * @since 3.0.0
21 */
22 class BlockServiceProvider extends ServiceProvider
23 {
24 public function __construct(Container $container)
25 {
26 parent::__construct($container);
27 }
28
29 /**
30 * Register blocks
31 */
32 public function register(): void
33 {
34 // Priority 100 so other plugins (or old stubs) register first; we reclaim + register full assets last.
35 if (did_action('init')) {
36 $this->registerBlocksOnInit();
37 } else {
38 add_action('init', [$this, 'registerBlocksOnInit'], 100);
39 }
40
41 // Register Yatra block category
42 add_filter('block_categories_all', [$this, 'registerBlockCategory'], 10, 2);
43 }
44
45 /**
46 * Register blocks on init hook
47 */
48 public function registerBlocksOnInit(): void
49 {
50 // Initialize all blocks
51 new TourBlock();
52 new ActivityBlock();
53 new DestinationBlock();
54 }
55
56 /**
57 * Register Yatra block category
58 *
59 * @param array $categories Existing block categories
60 * @param \WP_Block_Editor_Context $context Block editor context
61 * @return array Modified categories
62 */
63 public function registerBlockCategory(array $categories, \WP_Block_Editor_Context $context): array
64 {
65 // Add Yatra category at the beginning
66 array_unshift($categories, [
67 'slug' => 'yatra',
68 'title' => __('Yatra', 'yatra'),
69 '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>',
70 ]);
71
72 return $categories;
73 }
74 }
75