public function attachEvents(EventManagerInterface $events, array $eventsSpec = null)
    {
        if (null === $eventsSpec) {
            $eventsSpec = $this->eventsProvider();
        }
		
        foreach ($eventsSpec as $spec) {
            if (!is_array($spec) || 2 > count($spec)) {
                throw new \UnexpectedValueException('Event specification must be an array with at least two entries: event name and method name.');
            }

            $event  = $spec[0];
            $method = $spec[1];
            $priority = isset($spec[2]) ? $spec[2] : 0;

            $this->listeners[] = $events->attach($event, [ $this, $method ], $priority);
        }

        return $this;
    }
public function attachEvents(EventManagerInterface $events, array $eventsSpec = null)
    {
        if (null === $eventsSpec) {
            $eventsSpec = $this->eventsProvider();
        }
		
        foreach ($eventsSpec as $spec) {
            if (!is_array($spec) || 2 > count($spec)) {
                throw new \UnexpectedValueException('Event specification must be an array with at least two entries: event name and method name.');
            }

            $event  = $spec[0];
            $method = $spec[1];
            $priority = isset($spec[2]) ? $spec[2] : 0;

            $this->listeners[] = $events->attach($event, [ $this, $method ], $priority);
        }

        return $this;
    }
public function attachEvents ( EventManagerInterface $ events , array $ eventsSpec = null ) { if ( null === $ eventsSpec ) { $ eventsSpec = $ this -> eventsProvider ( ) ; } foreach ( $ eventsSpec as $ spec ) { if ( ! is_array ( $ spec ) || 2 > count ( $ spec ) ) { throw new \ UnexpectedValueException ( 'Event specification must be an array with at least two entries: event name and method name.' ) ; } $ event = $ spec [ 0 ] ; $ method = $ spec [ 1 ] ; $ priority = isset ( $ spec [ 2 ] ) ? $ spec [ 2 ] : 0 ; $ this -> listeners [ ] = $ events -> attach ( $ event , [ $ this , $ method ] , $ priority ) ; } return $ this ; }
Attachs the events to the provided event manager.

@param EventManagerInterface $events
@param array                 $eventsSpec

@return $this
@throws \UnexpectedValueException
Attachs the events to the provided event manager .