Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
factory.php
1<?
2
4
6
7class Factory
8{
9 public static function create($object, $type, $parameters = null)
10 {
11 $spaceList = explode('\\', $object);
12 $objectClassName = array_pop($spaceList);
13 array_push($spaceList, 'Services', $objectClassName);
14 $className = implode('\\', $spaceList).mb_strtoupper(mb_substr($type, 0, 1)).mb_strtolower(mb_substr($type, 1));
15
16 if (!class_exists($object))
17 {
18 throw new ArgumentOutOfRangeException('Object');
19 }
20
21 if (!class_exists($className))
22 {
23 throw new ArgumentOutOfRangeException('Type');
24 }
25
26 $instance = new $className($parameters);
27
28 return $instance;
29 }
30}
static create($object, $type, $parameters=null)
Definition factory.php:9