proklung/bitrix-containerable-boilerplate

PHP boilerplate для работы с контейнерами Symfony в Битриксе

1.1.6 2021-08-20 05:43 UTC

This package is auto-updated.

Last update: 2024-04-20 11:08:08 UTC


README

INTERNAL

Установка

composer.json:

    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/proklung/bitrix.containerable.boilerplate"
        }
    ]
composer require proklung/bitrix-containerable-boilerplate

Прочее

Как загружать бандлы

  1. Из файла:

Конфигурационный файл как в Symfony:

return [
    Prokl\MyBundle\MyBundle::class => ['all' => true],
]
 $bundlesConfigFile = __DIR_. '../../config/bundles.php'
 
 //...
 // Важно - перед загрузкой сервисов!
  $loaderBundles = new LoaderBundles(
      static::$container,
      $this->environment
 );

 $loaderBundles->fromFile($bundlesConfigFile);
  1. Из секции bundles целевого модуля:
 use Bitrix\Main\Config\Configuration;
 //...
 $this->config = Configuration::getInstance()->get('my.module') ?? ['my.module' => []];
 $this->bundles = $this->config['bundles'] ?? [];
 
 //...
 // Важно - перед загрузкой сервисов!
  $loaderBundles = new LoaderBundles(
      static::$container,
      $this->environment
 );

 $loaderBundles->fromArray($this->bundles);