/** * Registers all object's events to matching methods * * @param vBuilder\Object $object */ public function register(Nette\Object $object) { $rc = $object->getReflection(); $rc2 = $this->getReflection(); $publicProperties = $rc->getProperties(\ReflectionProperty::IS_PUBLIC); foreach ($publicProperties as $property) { $eventName = $property->getName(); if (!preg_match('#^on[A-Z]#', $eventName)) { continue; } if ($rc2->hasMethod($eventName)) { array_push($object->{$eventName}, array($this, $eventName)); } } }
/** * Call method of object * @param \Nette\Object $obj * @param string $method * @param array $params * @return bool */ protected function tryCall(\Nette\Object $obj, $method, array $params) { $rc = $obj->getReflection(); $rm = $rc->getMethod($method); if ($rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic()) { $rm->invokeArgs($obj, $this->combineArgs($rm, $params)); return TRUE; } return FALSE; }