Index: branches/5.2.x/core/units/scheduled_tasks/scheduled_tasks_config.php
===================================================================
diff -u -r15033 -r15250
--- branches/5.2.x/core/units/scheduled_tasks/scheduled_tasks_config.php (.../scheduled_tasks_config.php) (revision 15033)
+++ branches/5.2.x/core/units/scheduled_tasks/scheduled_tasks_config.php (.../scheduled_tasks_config.php) (revision 15250)
@@ -1,6 +1,6 @@
Array (
'type' => 'string', 'max_len' => 255,
- 'formatter' => 'kFormatter', 'regexp' => '/^[a-z-]*[.]{0,1}[a-z-]*:On[A-Za-z0-9]*$/',
'required' => 1, 'not_null' => 1, 'default' => ''
),
'RunInterval' => Array ('type' => 'int', 'required' => 1, 'not_null' => 1, 'default' => 0),
Index: branches/5.2.x/core/units/scheduled_tasks/scheduled_task_eh.php
===================================================================
diff -u -r15145 -r15250
--- branches/5.2.x/core/units/scheduled_tasks/scheduled_task_eh.php (.../scheduled_task_eh.php) (revision 15145)
+++ branches/5.2.x/core/units/scheduled_tasks/scheduled_task_eh.php (.../scheduled_task_eh.php) (revision 15250)
@@ -1,6 +1,6 @@
getObject();
+ /* @var $object kDBItem */
+
+ $event_string = $object->GetDBField('Event');
+
+ if ( !$event_string ) {
+ return;
+ }
+
+ try {
+ $this->Application->eventImplemented(new kEvent($event_string));
+ }
+ catch (Exception $e) {
+ $object->SetError('Event', 'invalid_event', '+' . $e->getMessage());
+ }
+ }
+
+ /**
* [HOOK] Refreshes scheduled task list in database based on cached data from unit configs
*
* @param kEvent $event
Index: branches/5.2.x/core/kernel/utility/unit_config_reader.php
===================================================================
diff -u -r15226 -r15250
--- branches/5.2.x/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 15226)
+++ branches/5.2.x/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 15250)
@@ -1,6 +1,6 @@
prefixFiles[$prefix]) ) {
- throw new Exception('Configuration file for prefix ' . $prefix . ' is unknown');
+ throw new Exception('Configuration file for prefix "' . $prefix . '" is unknown');
return ;
}
Index: branches/5.2.x/core/kernel/application.php
===================================================================
diff -u -r15246 -r15250
--- branches/5.2.x/core/kernel/application.php (.../application.php) (revision 15246)
+++ branches/5.2.x/core/kernel/application.php (.../application.php) (revision 15250)
@@ -1,6 +1,6 @@
EventManager->eventImplemented($event);
+ }
+
+ /**
* Registers new class in the factory
*
* @param string $real_class Real name of class as in class declaration
Index: branches/5.2.x/core/kernel/event_handler.php
===================================================================
diff -u -r15137 -r15250
--- branches/5.2.x/core/kernel/event_handler.php (.../event_handler.php) (revision 15137)
+++ branches/5.2.x/core/kernel/event_handler.php (.../event_handler.php) (revision 15250)
@@ -1,6 +1,6 @@
getEventMethod($event);
+
+ $this->$event_name($event);
+ }
+
+ /**
+ * Returns method name, that should called to process given event.
+ * When no such method exists and exception is thrown.
+ *
+ * @param kEvent $event
+ * @return string
+ * @throws Exception
+ */
+ public function getEventMethod(kEvent $event)
+ {
$event_name = $event->Name;
if ( array_key_exists($event_name, $this->eventMethods) ) {
$event_name = $this->eventMethods[$event_name];
}
if ( method_exists($this, $event_name) ) {
- $this->$event_name($event);
+ return $event_name;
}
- else {
- throw new Exception('Event ' . $event->Name . ' not implemented in class ' . get_class($this) . '');
- }
+
+ throw new Exception('Event "' . $event->Name . '" not implemented in class "' . get_class($this) . '"');
}
/**
Index: branches/5.2.x/core/kernel/utility/event.php
===================================================================
diff -u -r15145 -r15250
--- branches/5.2.x/core/kernel/utility/event.php (.../event.php) (revision 15145)
+++ branches/5.2.x/core/kernel/utility/event.php (.../event.php) (revision 15250)
@@ -1,6 +1,6 @@
Name = $regs[3];
}
else {
- throw new Exception('Invalid event string: ' . $params . '. $params should be "prefix[.special]:OnEvent" format');
+ throw new Exception('Invalid event string: "' . $params . '". Should be in "prefix[.special]:OnEvent" format');
}
}
}
Index: branches/5.2.x/core/kernel/event_manager.php
===================================================================
diff -u -r15137 -r15250
--- branches/5.2.x/core/kernel/event_manager.php (.../event_manager.php) (revision 15137)
+++ branches/5.2.x/core/kernel/event_manager.php (.../event_manager.php) (revision 15250)
@@ -1,6 +1,6 @@
verifyEventPrefix($event, true) ) {
+ return false;
+ }
+
+ $event_handler = $this->Application->recallObject($event->Prefix . '_EventHandler');
+ /* @var $event_handler kEventHandler */
+
+ return $event_handler->getEventMethod($event) != '';
+ }
+
+ /**
* Checks if event prefix is valid
*
* @param kEvent $event
@@ -282,10 +301,11 @@
public function verifyEventPrefix($event, $is_fatal = false)
{
if ( !$this->Application->prefixRegistred($event->Prefix) ) {
+ // when "l-cdata" is requested, then load "l", that will clone "l-cdata" unit config
$this->Application->UnitConfigReader->loadConfig($event->Prefix);
if ( !$this->Application->prefixRegistred($event->Prefix) ) {
- $error_msg = 'Prefix ' . $event->Prefix . ' not registred (requested event ' . $event->Name . ')';
+ $error_msg = 'Prefix "' . $event->Prefix . '" not registred (requested event "' . $event->Name . '")';
if ($is_fatal) {
throw new Exception($error_msg);