7class Tpl extends Entity\EO_WorkflowTemplate
18 return CBPWorkflowTemplateLoader::FindActivityByName($this->
getActivities(), $activityName);
23 return [$this->getModuleId(), $this->getEntity(), $this->getDocumentType()];
28 return $this->getTemplate();
35 public function collectUsages()
40 $rootActivity = CBPWorkflowTemplateLoader::GetLoader()->LoadWorkflow($this->getId())[0];
44 $rootActivity = CBPWorkflowTemplateLoader::GetLoader()->loadWorkflowFromArray([
46 'TEMPLATE' => $this->getTemplate(),
47 'VARIABLES' => $this->getVariables(),
48 'PARAMETERS' => $this->getParameters(),
52 $rootActivity->SetProperties($this->getParameters());
53 $rootActivity->SetVariablesTypes($this->getVariables());
55 $usages =
new Collection\Usages();
56 $this->findActivityUsagesRecursive($rootActivity, $usages);
68 $usages = $this->collectUsages();
69 return array_unique(array_column($usages->getBySourceType($sourceType), 1));
72 private function findActivityUsagesRecursive(\CBPActivity $activity,
Collection\Usages $usages)
74 $sources = $activity->collectUsages();
75 $usages->addOwnerSources($activity->GetName(), $sources);
77 $children = $activity->CollectNestedActivities();
78 if (is_array($children))
80 foreach ($children as $child)
82 $this->findActivityUsagesRecursive($child, $usages);
90 return array_unique($this->getActivityTypes($this->getTemplate()));
93 private function getActivityTypes(array $activities)
96 foreach ($activities as $activity)
98 $types[] = $activity[
'Type'];
100 if (!empty($activity[
'Children']))
102 $types = array_merge($types, $this->getActivityTypes($activity[
'Children']));