/**
  * Register your event
  * @param string $eventName
  * @param $className
  * @param int $priority
  * @param bool $queued
  */
 public function register($eventName, $className, $priority = 0, $queued = false)
 {
     $eventName = $this->getDefaultEventName() . $eventName;
     LoggerSphring::getInstance()->debug(sprintf("Registering event '%s' for class '%s'", $eventName, $className));
     $this->registers[$eventName] = $className;
     $this->sphringEventDispatcher->addListener($eventName, array($this, 'onEvent'), $priority, $queued);
 }
 /**
  * Method which will be called for extend the current Sphring
  * @return mixed
  */
 public function extend()
 {
     LoggerSphring::getInstance()->debug("Running sphring global extend");
     foreach ($this->nodes as $node) {
         $this->getSphringEventDispatcher()->getSphringBoot()->getSphringGlobalListener()->register($node->getEventName(), $node->getClassName(), $node->getPriority());
     }
 }
 public function initReader()
 {
     LoggerSphring::getInstance()->info("Initiating registering annotation");
     $file = $this->sphring->getRootProject() . DIRECTORY_SEPARATOR . SphringComposerEnum::AUTLOADER_FILE;
     if (!is_file($file)) {
         $file = $this->sphring->getContextRoot() . DIRECTORY_SEPARATOR . SphringComposerEnum::AUTLOADER_FILE;
     }
     if (!is_file($file)) {
         $file = $this->getAutoloaderFromLibrary();
     }
     if (!is_file($file)) {
         $file = $_SERVER['CONTEXT_DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . SphringComposerEnum::AUTLOADER_FILE;
     }
     if (!is_file($file)) {
         $file = dirname($this->composerManager->getComposerLockFile()) . DIRECTORY_SEPARATOR . SphringComposerEnum::AUTLOADER_FILE;
     }
     if (!is_file($file)) {
         throw new SphringAnnotationException("Can't found autoloader for annotation reading.");
     }
     $loader = (require $file);
     AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
 }
<?php

include_once __DIR__ . '/config.php';
$loader = (require_once __DIR__ . '/../vendor/autoload.php');
$loader->add($namespace, __DIR__);
$logger = new \Monolog\Logger("Sphring{$pluginName}Test");
$logger->pushHandler(new \Monolog\Handler\StreamHandler('php://stdout', \Monolog\Logger::DEBUG));
$loggerSphring = \Arthurh\Sphring\Logger\LoggerSphring::getInstance();
$loggerSphring->setLogger($logger);
$loggerSphring->setWithFile(false);
$loggerSphring->setWithClass(false);
ini_set("variables_order", "EGPCS");
return $loader;
 /**
  * @see EventDispatcher::removeListener
  * @param string $eventName
  * @param callable $listener
  */
 public function removeListener($eventName, $listener)
 {
     $listenerName = "";
     if (!empty($listener[0]) && is_object($listener[0])) {
         $listenerName = get_class($listener[0]);
     }
     LoggerSphring::getInstance()->debug(sprintf("Remove listener '%s on event '%s'", $listenerName, $eventName));
     parent::removeListener($eventName, $listener);
 }
Example #6
0
 /**
  * @param LoggerInterface $logger
  */
 public function setLogger(LoggerInterface $logger)
 {
     LoggerSphring::getInstance()->setLogger($logger);
 }
Example #7
0
 /**
  * @return LoggerSphring
  */
 protected function getLogger()
 {
     return LoggerSphring::getInstance();
 }
Example #8
0
 /**
  * Parse from composer.lock extra properties to extend the current sphring
  */
 private function loadSphringPlugin(array $packageSphring)
 {
     $extras = $packageSphring[SphringComposerEnum::EXTRA_COMPOSER_KEY];
     if (empty($extras)) {
         return;
     }
     $sphringExtra = $extras[SphringComposerEnum::EXTRA_SPHRING_COMPOSER_KEY];
     if (empty($sphringExtra)) {
         return;
     }
     if (empty($sphringExtra[SphringComposerEnum::EXTRA_SPHRING_EXTEND_COMPOSER_KEY]) || empty($sphringExtra[SphringComposerEnum::EXTRA_SPHRING_ISPLUGIN_COMPOSER_KEY])) {
         return;
     }
     LoggerSphring::getInstance()->info(sprintf("Extending from composer plugin '%s'.", $packageSphring['name']));
     $this->extendFromComposer($sphringExtra[SphringComposerEnum::EXTRA_SPHRING_EXTEND_COMPOSER_KEY]);
 }