예제 #1
0
 public function read()
 {
     $file = $this->generatedPath . '/' . $this->configFilename;
     if (file_exists($file)) {
         return (array) (require $file);
     } else {
         $this->signal->getLogger()->debug('Config file "{file}" does not exists, have you generated signals config file?', ['file' => $file]);
     }
 }
예제 #2
0
 public static function create(Signal $signals, $signal, $fqn, $injection)
 {
     // Clone signal, as it might be modified by slot
     $cloned = clone $signal;
     // Constructor injection
     if (true === $injection) {
         $slot = new $fqn($cloned);
         // Slot aware call
         if ($cloned instanceof SlotAwareInterface) {
             $cloned->setSlot($slot);
         }
         return $cloned;
     }
     // Check if class exists and log if doesn't
     // @codeCoverageIgnoreStart
     if (!ClassChecker::exists($fqn)) {
         $signals->getLogger()->debug(sprintf("Class `%s` not found while emiting signal `%s`", $fqn, get_class($signal)));
         return false;
     }
     // @codeCoverageIgnoreEnd
     // Other type injection
     $slot = new $fqn();
     // Slot aware call
     if ($cloned instanceof SlotAwareInterface) {
         $cloned->setSlot($slot);
     }
     if (strstr($injection, '()')) {
         // Method injection
         $methodName = str_replace('()', '', $injection);
         $slot->{$methodName}($cloned);
     } else {
         // field injection
         $slot->{$injection} = $cloned;
     }
     return $cloned;
 }
예제 #3
0
 private function log(Exception $e, $file)
 {
     $msg = sprintf('Exception: "%s" while scanning file `%s`', $e->getMessage(), $file);
     $this->signal->getLogger()->warning($msg);
 }