Kdy se volá detach? monitor v componentě v constructoru

Isigarek
Člen | 74
+
0
-

Mám komponentu, která má v sobě monitor na IPresenter s attached, detached attach funguje ale detach se nějak nevolá nebo spíše to nevypadá, že by se volal. Kdy přesně má dojít k tomu callu?

$this->monitor(IPresenter::class,function (){
            $this->section = $this->presenter->getSession(self::SESSION_KEY . $this->presenter->getUser()->getId());
        },function (){
            $this->section->remove();
        });
Ondřej Kubíček
Člen | 494
+
0
-

This method will be called before the component (or component's parent) becomes detached from a monitored object. Do not call this method yourself.

Isigarek
Člen | 74
+
0
-

Ondřej Kubíček napsal(a):

This method will be called before the component (or component's parent) becomes detached from a monitored object. Do not call this method yourself.

Ano to je napsané v doc funkce detach, která je deprecated a u ní je napsáno, že máš použít funkci monitor :)

Component.php

	/**
	 * This method will be called when the component (or component's parent)
	 * becomes attached to a monitored object. Do not call this method yourself.
	 * @param  IComponent  $obj
	 * @return void
	 * @deprecated  use monitor($type, $attached)
	 */
	protected function attached($obj)
	{
	}


	/**
	 * This method will be called before the component (or component's parent)
	 * becomes detached from a monitored object. Do not call this method yourself.
	 * @param  IComponent  $obj
	 * @return void
	 * @deprecated  use monitor($type, null, $detached)
	 */
	protected function detached($obj)
	{
	}