Container
Methods
Service container is a source of service instances in the new CRM API.
It also serves as service itself.
Instance of this service (as well as the majority of others) are located in в DI\ServiceLocator.
If desired, you can re-define the container to modify business logic, without updating product kernel.
Method | Description | Available from version |
---|---|---|
public static function getInstance(): Container |
Method returns container instance. | |
public static function getIdentifierByClassName (string $className, array $parameters = null): string |
Method returns string identifier for ServiceLocator by class name and additional string parameters. | |
public function getFactory(int $entityTypeId): ?Factory |
Method returns a factory instance for the type $entityTypeId , if available.
Not all entity types have factories. If no factory is available, you can pass entityTypeId of non-existing SPA. | |
public function getDynamicFactoryByType(Type $type): Dynamic |
Method returns a factory instance of SPA fororm-object. | |
public function getUserPermissions (?int $userId = null): UserPermissions |
Method returns an access permission service instance for user with $userId.
When $userId is not specified, access permissions will be retrieved from global context. | |
public function getType(int $id): ?Type |
Method returns SPA ORM object by its $id. Note that column is for ID, not for ENTITY_TYPE_ID . | |
public function getType(int $id): ?Type |
Method returns SPA ORM object by its $id. Note that column is for ID, not for ENTITY_TYPE_ID . | |
public function getTypeByEntityTypeId (int $entityTypeId): ?Type |
Method returns SPA ORM object by its $entityTypeId. Note, that column is ENTITY_TYPE_ID specifically. | |
public function getLocalization(): Localization |
Method returns localization service instance. | |
public function getRouter(): Router |
Method returns routing service instance. | |
public function getContext(): Context |
Method returns global context instance. | |
public function getOrmObjectConverter(): Converter\OrmObject |
Method returns ORM object converter instance. | |
public function getItemConverter(): Converter\Item |
Method returns Item converter instance. | |
public function getStageConverter(): Converter\Stage |
Method returns Stage converter instance. | |
public function getTypeConverter(): Converter\Type |
Method returns SPA converter instance. | |
public function getUserBroker(): Broker\User |
Method returns user broker instance. | |
public function getCompanyBroker(): Broker\Company |
Method returns company broker instance. | |
public function getContactBroker(): Broker\Contact |
Method returns contact broker instance. | |
public function getDirector(): Director |
Method returns scenario service. | |
public function getDynamicTypeDataClass(): string |
Method returns SPA table. | |
public function getEventHistory(): EventHistory |
Method returns History service instance. | |
public function getTypesMap(): TypesMap |
Method returns CRM types map instance. | |
public function getDynamicTypesMap(): DynamicTypesMap |
Method returns SPA map instance. | |
public function getRelationManager(): RelationManager |
Method returns Binding manager instance. | |
public function getTypePresetBroker(): Broker\TypePreset |
Method returns SPA preset broker. | |
public function getParentFieldManager(): ParentFieldManager |
Method returns binding fields manager. | |
public function getPullManager(): PullManager |
Method returns push manager. | |
public function getFilterFactory(): Filter\Factory |
Method returns class factory when handling filter. | |
public function getAccounting(): Accounting |
Method returns total calculation service. | |
public function getFileUploader(): FileUploader |
Method returns file loading service. |
Example
use Bitrix\Crm\Service; $container = Service\Container::getInstance (); $router = $container->getRouter(); // идентично // $router = DI\ServiceLocator::getInstance()->get('crm.service.router'); $entityTypeId = \CCrmOwnerType::Deal; $factory = $container->getFactory($entityTypeId ); if (!$factory) { echo 'factory not found' ; }
© «Bitrix24», 2001-2024