Update
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Bitrix\UI\Integration\HumanResources;
|
||||
|
||||
use Bitrix\HumanResources;
|
||||
use Bitrix\Main\Loader;
|
||||
|
||||
Loader::requireModule('humanresources');
|
||||
|
||||
class DepartmentQueries
|
||||
{
|
||||
private HumanResources\Service\Container $hrServiceLocator;
|
||||
|
||||
public static function getInstance(): self
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
$this->hrServiceLocator = HumanResources\Service\Container::instance();
|
||||
}
|
||||
|
||||
public function getDepartmentByAccessCode(string $accessCode): ?HumanResources\Item\Node
|
||||
{
|
||||
return $this->hrServiceLocator::getNodeRepository()->getByAccessCode($accessCode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Bitrix\UI\Integration\HumanResources;
|
||||
|
||||
use Bitrix\HumanResources\Config\Storage;
|
||||
use Bitrix\HumanResources\Type\AccessCodeType;
|
||||
use Bitrix\Main\Loader;
|
||||
use COption;
|
||||
|
||||
final class HumanResources
|
||||
{
|
||||
public const IS_CONVERTED_OPTION_NAME = 'entity_editor_config_access_codes_is_converted';
|
||||
|
||||
public static function getInstance(): self
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function buildAccessCode(string $value, int $nodeId): ?string
|
||||
{
|
||||
if ($this->isUsed())
|
||||
{
|
||||
return AccessCodeType::tryFrom($value)?->buildAccessCode($nodeId);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function isUsed(): bool
|
||||
{
|
||||
return Loader::includeModule('humanresources') && Storage::instance()->isCompanyStructureConverted(false);
|
||||
}
|
||||
|
||||
private function isEntityEditorConfigAccessCodesConverted(): bool
|
||||
{
|
||||
return COption::GetOptionString('ui', self::IS_CONVERTED_OPTION_NAME, 'Y') === 'Y';
|
||||
}
|
||||
|
||||
public function isAccessCodesCanBeUsed(): bool
|
||||
{
|
||||
return $this->isUsed() && $this->isEntityEditorConfigAccessCodesConverted();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user