public function __construct($message = null, $code = 0, \Exception $previous = null)
 {
     parent::__construct($message, $code, $previous);
     if (Configuration::getVerbose() >= 1) {
         Sonic::getLogger()->addError($message);
     }
 }
 /**
  * for demonstration purposes, only one rule is created for a specific data object for a specific user
  * 
  * @param $gid The GlobalID requesting entitiy
  * @param $uoid The UOID of the content or wildcard (*)
  * 
  * @return array of AccessControlRuleObjects, NULL if no rules were found
  */
 protected function loadAccessControlRulesForUOID($gid, $uoid)
 {
     $rules = array();
     if ($gid == '28B6TE8T9NUO202C5NZIUTNQSP88E70B8JAWH4FQ58OJOB8LIF' && $uoid == '4802C8DE6UZZ5BICQI830A8P8BW3YB5EBPGXWNRH1EP7H838V7:a9ddbc2102bf86d1') {
         $rules[] = (new AccessControlRuleObjectBuilder())->owner(Sonic::getContextGlobalID())->index(1)->directive(AccessControlRuleObject::DIRECTIVE_ALLOW)->entityType(AccessControlRuleObject::ENTITY_TYPE_INDIVIDUAL)->entityID('28B6TE8T9NUO202C5NZIUTNQSP88E70B8JAWH4FQ58OJOB8LIF')->targetType(AccessControlRuleObject::TARGET_TYPE_CONTENT)->target('4802C8DE6UZZ5BICQI830A8P8BW3YB5EBPGXWNRH1EP7H838V7:a9ddbc2102bf86d1')->accessType(AccessControlRuleObject::WILDCARD)->build();
     }
     return $rules;
 }
 /**
  * Deal with an exception
  * @param Exception $exception Exception
  * @return void
  */
 public function Exception($exception)
 {
     // Auditlog
     $auditlog = Sonic::getResource('auditlog');
     if ($auditlog instanceof Resource\Audit\Log) {
         $auditlog::_Log(get_called_class() . '\\' . $this->action, 7, $this->request, array('file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage()));
     }
     // Display message
     echo 'Uncaught exception `' . $exception->getMessage() . '` in ' . $exception->getFile() . ' on line ' . $exception->getLine();
 }
Example #4
0
 /**
  * Return random database resource object
  * @param string $group Group name
  * @return boolean|\Sonic\Model\PDO
  */
 public static function &_getRandomDbResource($group)
 {
     $obj = FALSE;
     while (Sonic::countResourceGroup($group) > 0) {
         $name = Sonic::selectRandomResource($group);
         $obj =& Sonic::getResource(array($group, $name));
         // If a PDO object
         if ($obj instanceof \PDO) {
             // Attempt to connect to the resource
             // This will throw an exception if it fails or break the loop if it succeeds
             if ($obj instanceof Resource\Db) {
                 try {
                     $obj->Connect();
                     // Set as default group object for persistence
                     Sonic::setSelectedResource($group, $name);
                     break;
                 } catch (\PDOException $e) {
                     // Do nothing
                 }
             } else {
                 break;
             }
         }
         // Remove resource from the framework as its not valid
         // then continue to the next object
         Sonic::removeResource($group, $name);
         $obj = FALSE;
     }
     return $obj;
 }
<?php

// Define namespace
namespace Sonic;

// Directory seperator
if (!defined('DS')) {
    @define('DS', defined('DIRECTORY_SEPARATOR') ? DIRECTORY_SEPARATOR : '/');
}
// Require global paths
require_once 'paths.php';
// Setup config
require_once 'config.php';
// Autoloader
require_once ABS_VENDOR . 'autoload.php';
// Set framework resources
Sonic::newResource('parser', new Resource\Parser());
// Load config
require_once CONFIG_DIR . 'config.php';