Example #1
0
 /**
  * provides aspect functionality
  * @param object $pObj object to configure
  * @param AOP\AJoinPoint $pJoinPoint joinpoint
  */
 public static function advice($pObj, AOP\AJoinPoint $pJoinPoint)
 {
     $method = \property_exists($pJoinPoint, 'METHOD') ? $pJoinPoint->METHOD : '';
     $args = \property_exists($pJoinPoint, 'ARGS') ? $pJoinPoint->ARGS : array();
     switch ($pJoinPoint->DIRECTION) {
         case AOP\AJoinPoint::DIRECTION_IN:
             $indent = \str_repeat(CFileLogging::LOG_INDENT, CFileLogging::$INDENT_COUNT);
             CFileLogging::$INDENT_COUNT += 1;
             switch (true) {
                 case $pJoinPoint instanceof AOP\JoinPoints\CConstructor:
                 case $pJoinPoint instanceof AOP\JoinPoints\CDestructor:
                     $content = sprintf('%s%s %s', $indent, $pJoinPoint->LABEL, $pJoinPoint->CLASS);
                     break;
                 case $pJoinPoint instanceof AOP\JoinPoints\CException:
                     $content = sprintf('%s%s %s %s', $indent, $pJoinPoint->LABEL, $pJoinPoint->CLASS, $pJoinPoint->MESSAGE);
                     break;
                 case $pJoinPoint instanceof AOP\JoinPoints\CClassLoader:
                     $content = sprintf('%s%s %s from frile %s', $indent, $pJoinPoint->LABEL, $pJoinPoint->CLASS, $pJoinPoint->file);
                     break;
                 case $pJoinPoint instanceof AOP\JoinPoints\CMethodCall:
                     $strArgs = array();
                     foreach ($args as $argument) {
                         if (\is_object($argument)) {
                             $strArgs[] = \get_class($argument);
                         } else {
                             $strArgs[] = (string) $argument;
                         }
                     }
                     $content = sprintf('%senter %s %s->%s(%s)', $indent, $pJoinPoint->LABEL, $pJoinPoint->CLASS, $method, \implode(',', $strArgs));
                     break;
                 default:
                     $content = sprintf('%senter %s->%s(%s)', $indent, $pJoinPoint->CLASS, $method, \implode(',', $args));
             }
             break;
         case AOP\AJoinPoint::DIRECTION_OUT:
             CFileLogging::$INDENT_COUNT -= 1;
             $indent = \str_repeat(CFileLogging::LOG_INDENT, CFileLogging::$INDENT_COUNT);
             switch (true) {
                 case $pJoinPoint instanceof AOP\JoinPoints\CMethodCall:
                     $content = sprintf('%sleave %s %s->%s', $indent, $pJoinPoint->LABEL, $pJoinPoint->CLASS, $method);
                     break;
                 case $pJoinPoint instanceof AOP\JoinPoints\CConstructor:
                 case $pJoinPoint instanceof AOP\JoinPoints\CDestructor:
                 case $pJoinPoint instanceof AOP\JoinPoints\CClassLoader:
                 case $pJoinPoint instanceof AOP\JoinPoints\CException:
                 default:
                     break;
             }
             break;
     }
     if (isset($content) && $content != '') {
         \Savant\CBootstrap::log($content);
     }
 }
Example #2
0
 /**
  * connect to defined database driver
  * @param string $pConn
  */
 public function _connect()
 {
     if (!$this->isConnected()) {
         try {
             $this->con = \Savant\AGenericCallInterface::call((string) $this->DRIVER_CLASS, 'connect', array($this));
             \Savant\CBootstrap::log(\Savant\Utils\CFileLogging::getIndent() . "connect to " . $this->confSection . " as " . $this->USERNAME);
         } catch (EDatabase $e) {
             throw $e;
         }
     } else {
         return;
     }
 }
Example #3
0
 /**
  * handle request
  * @param string $pData optional, data from standard input will be used as
  * default
  * @param boolean $displayReponse
  * @return mixed
  */
 public function _handle($pData = null, $displayReponse = true)
 {
     if (\is_null($pData)) {
         $pData = \Savant\Protocol\CHttp::getPostData();
     }
     if (empty($pData)) {
         throw new EXMLRPCServer("invalid xml rpc call without data");
     }
     \Savant\CBootstrap::setContentType(\Savant\CBootstrap::CONTENT_TYPE_XMLRPC);
     $response = \xmlrpc_server_call_method($this->server, $pData, '');
     if ($displayReponse) {
         print $response;
     }
     return $response;
 }
Example #4
0
 /**
  * Constructor
  * @param string $pMessage error message
  * @param string $pLevel error level
  * @param array $pArgs arguments used by message
  */
 public function __construct()
 {
     $args = \func_get_args();
     $message = \array_shift($args);
     if (count($args) > 0) {
         parent::__construct(vsprintf($message, $args));
     } else {
         parent::__construct($message);
     }
     if (CBootstrap::$PERMANENT_LOG) {
         if (CBootstrap::$STATUS == CBootstrap::STATUS_ACTIVE) {
             $joinPoint = new AOP\JoinPoints\CException($this);
             AOP\AFramework::weave(null, $joinPoint);
         } else {
             CBootstrap::log($this->getMessage());
         }
     }
 }
Example #5
0
 /**
  * returns configuration from given class
  * @param string $pClass
  * @param string $pSection
  * @return SimpleXMLElement
  */
 public static function getClassConfig($pClass, $pSection = 'default')
 {
     $configFile = CBootstrap::getConfigFile($pClass);
     if (!\file_exists($configFile)) {
         throw new EConfigure("no config file for class %s found", $pClass);
     }
     $config = self::load($configFile, false);
     //deactivate dtd validation while fixing bug
     $section = $config->configurations->xpath("//section[@name='" . $pSection . "']");
     return self::getConfigFromSection($section[0]);
 }
Example #6
0
 /**
  * build request from uri and method
  * @param string $pUri
  * @param string $pMethod
  * @return \Savant\MVC\CRequest
  */
 public function build()
 {
     $environment = \Savant\CBootstrap::getInstance('Savant\\Utils\\CEnvironment');
     $request = new CRequest();
     $request->setEnvironment($environment);
     return $request;
 }
Example #7
0
 /**
  * creates xmlrpc client instance and initiates http handler. the config
  * section parameter has to be defined in both config files:
  * - conf/Savant/Webservice/CXMLRPCClient.conf.xml
  * - conf/Savant/Protocol/CHttp.conf.xml
  * @param string $pSection
  */
 public function __construct($pSection = 'default')
 {
     \Savant\CBootstrap::extensionLoaded('xmlrpc');
     parent::__construct($pSection);
     $this->httpHandler = new \Savant\Protocol\CHttp($pSection);
 }
Example #8
0
 public function testGetClassesWithInterface()
 {
     $classes = \Savant\CBootstrap::getClassesWithInterface('\\Savant\\Template\\IEngine');
     print_r($classes);
 }
Example #9
0
 /**
  * create class instance, without using the constructor directly
  * @return object
  */
 public static function invoke()
 {
     return CBootstrap::invoke(\get_class());
 }