• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/ui/component/templatehelper.php
  • Класс: BitrixTasksUIComponentcontains
  • Вызов: contains::__construct
public function __construct($name, $template, array $parameters = array())
{
	if(array_key_exists('METHODS', $parameters) && is_array($parameters['METHODS']))
	{
		foreach($parameters['METHODS'] as $methodName => $cb)
		{
			$this->addMethod($methodName, $cb);
		}
	}

	if($template instanceof CBitrixComponentTemplate)
	{
		$this->template = $template;
		$this->id = $this->pickId();
		$this->name = trim((string) $name);
		if(!$this->name)
		{
			$this->name = preg_replace('#Component$#', '', $template->__component->getComponentClassName());
		}

		Loc::loadMessages($_SERVER['DOCUMENT_ROOT'].'/'.$this->template->getFolder().'/js.php'); // make all js-messages available in php also

		$title = Loc::getMessage('TASKS_'.ToUpper($this->name).'_TEMPLATE_TITLE');
		if($title != '')
		{
			$this->setTitle($title);
		}

		if (!is_array($parameters['RELATION'] ?? null))
		{
			$parameters['RELATION'] = [];
		}
		$this->registerExtension($parameters['RELATION']);

		// dispatch runtime
		if(!empty($this->runtimeActions))
		{
			$trigger = $this->getComponent()->getDispatcherTrigger();
			if($trigger)
			{
				$component = $this->getComponent();

				// attach runtime operations to the dispatcher
				$dispatcher = $component->getDispatcher();
				$dispatcher->addRuntimeActions($this->getRunTimeActions());

				// execute again
				$result = $dispatcher->run($trigger->find(array('~ACTION' => '#^runtime:templateAction#i')));
				if(!$result->getErrors()->isEmpty())
				{
					$component->getErrors()->load($result->getErrors()->transform(array('TYPE' => Error::TYPE_WARNING)));
				}
			}
		}
	}
}