hard2code / bitrix-utils
A set of classes for more convenient work with the Bitrix API
Installs: 112
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 1
Open Issues: 0
pkg:composer/hard2code/bitrix-utils
This package is auto-updated.
Last update: 2025-12-31 00:26:55 UTC
README
Bitrix utils
This library contains various classes for working with templates, components, allowing you to speed up development working with OOP style*.
*The library is intended for use exclusively in conjunction with 1C Bitrix: Site Management
Library purpose:
- encapsulation of work with arrays of the $arResult array coming from Bitrix components
- minimization of the combination of php and html code
Данная библиотека содержит набор различных вспомогательных классов для работы с компонентами и шаблонами в 1С Битрикс "Управление сайтом" в ООП стиле*
*Библиотека предназначенная исключительно для совместного использования с 1С Битрикс "Управление сайтом".
Назначение библиотеки:
- инкапсуляция работы с массивами вида $arResult, приходящими из компонентов Битрикса
- минимализация мешанины php и html кода
Authors
Installation
Install my-project with composer
composer require hard2code/bitrix-utils
Usage/Examples
See more in examples directory
Более подробные примеры находятся в директории examples
Working with sections as OOP style:
Работа с разделами в ООП стиле:
<?php /*----------------------------------------------------* Some example of usage ArraySection in template *----------------------------------------------------*/ use Hard2Code\Util\Entities; use Hard2Code\Util\Images; protectBitrixPrologInclude(); $sections = Entities::getSections($arResult, $this); ?> <div class="container"> <?php foreach ($sections as $i => $section): $sectionPageUrl = $section->getSectionPageUrl(); $picture = Images::getResizedImage($section->getUfProperty("image"), true, 400, 300); $name = $section->getName(); $url = $section->getSectionPageUrl(); $code = $section->getCode(); $someProperty = $section->getUfProperty("some_uf_property"); $description = $section->getDescription(); ?> <?php if ($section->hasDescription()): ?> <div class="description"><?= $description ?></div> <?php endif ?> <?php endforeach; ?> </div>
Working with links as OOP style:
Работа с ссылками в ООП стиле:
<?php /*----------------------------------------------------* Some example of usage ArrayLink in template *----------------------------------------------------*/ use Hard2Code\Util\Entities; use Hard2Code\Util\Links; protectBitrixPrologInclude(); ?> <div id="category_menu"> <div class="container"> <div class="swiper"> <div class="swiper-wrapper"> <?php foreach (Entities::getLinks($arResult) as $link): $src = $link->getSource(); $title = $link->getTitle(); $isSelected = $link->isSelected(); $isAbsolute = $link->isRelative(); $isRelative = $link->isAbsolute(); ?> <div class="swiper-slide"> <div class="category"> <a class="category_title" href="<?= $src ?>" target="<?= Links::getTargetAttribute($src) ?>"> <div class="title"> <?= $title ?></div> </a> </div> </div> <?php endforeach ?> </div> </div> </div> </div>
Including assets:
Подключение асетов:
<?php use Hard2Code\Util\Assets; Assets::includeDefaultMeta(); Assets::includeManifest("/assets/site.webmanifest"); Assets::includeJs( "/vendor/jquery.min.js", "/vendor/swiper-bundle.min.js", "/vendor/bootstrap.bundle.min.js", "/vendor/validate.min.js", "/vendor/fotorama.js", "/vendor/fontawesome.js", ); Assets::includeJs("https://kit.fontawesome.com/90a47ca9b8.js"); Assets::includeJsRecursively("/directory"); Assets::includeCssRecursively("/vendor", "/air2hut");
Список доступных методов вы можете найти в соответствующих интерфейсах:
- ArraySection
- ArrayItem
- ArrayLink
При необходимости, вы можете создать свои реализации данных интерфейсов в пользовательском коде
Installation
Install my-project with composer
composer require hard2code/bitrix-utils