定制 hard2code/bitrix-utils 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hard2code/bitrix-utils

最新稳定版本:1.0.2

Composer 安装命令:

composer require hard2code/bitrix-utils

包简介

A set of classes for more convenient work with the Bitrix API

README 文档

README

Logo

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

Authors

统计信息

  • 总下载量: 112
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-27