public function attach()
    {
        $em = $this->getEventsManager();

        if (!empty($this->space)) {
            foreach ($this->space as $space) {
                $em->attach($space, $this);
            }
        }

        if (!empty($this->listen)) {
            foreach ($this->listen as $event => $callback) {
                if (!method_exists($this, $callback)) {
                    throw new \RuntimeException(
                        "Method '$callback' not exist in " . get_class($this)
                    );
                }

                $this->closures[$event] = $closure = function (Event $event, $handler, $data = null) use ($callback) {
                    return $this->$callback($event, $handler, $data);
                };

                $em->attach($event, $closure);
            }
        }
    }
public function attach()
    {
        $em = $this->getEventsManager();

        if (!empty($this->space)) {
            foreach ($this->space as $space) {
                $em->attach($space, $this);
            }
        }

        if (!empty($this->listen)) {
            foreach ($this->listen as $event => $callback) {
                if (!method_exists($this, $callback)) {
                    throw new \RuntimeException(
                        "Method '$callback' not exist in " . get_class($this)
                    );
                }

                $this->closures[$event] = $closure = function (Event $event, $handler, $data = null) use ($callback) {
                    return $this->$callback($event, $handler, $data);
                };

                $em->attach($event, $closure);
            }
        }
    }
public function attach ( ) { $ em = $ this -> getEventsManager ( ) ; if ( ! empty ( $ this -> space ) ) { foreach ( $ this -> space as $ space ) { $ em -> attach ( $ space , $ this ) ; } } if ( ! empty ( $ this -> listen ) ) { foreach ( $ this -> listen as $ event => $ callback ) { if ( ! method_exists ( $ this , $ callback ) ) { throw new \ RuntimeException ( "Method '$callback' not exist in " . get_class ( $ this ) ) ; } $ this -> closures [ $ event ] = $ closure = function ( Event $ event , $ handler , $ data = null ) use ( $ callback ) { return $ this -> $ callback ( $ event , $ handler , $ data ) ; } ; $ em -> attach ( $ event , $ closure ) ; } } }
Attach all require event to make the listener
Attach all require event to make the listener