/** * The constructor for this repository * Accepts the fully qulaified type of the IContentDataContext implemting * data context for this repository * * @param string $dataContext */ public function __construct($dataContext = null) { if (!isset($dataContext)) { $dataContext = \Swiftriver\Core\Setup::DALConfiguration()->DataContextType; } $classType = (string) $dataContext; $this->dataContext = new $classType(); }
/** * The constructor for this repository * Accepts the fully qulaified type of the IAPIKeyDataContext implemting * data context for this repository * * @param string $dataContext */ public function __construct($dataContext = null) { //if the data context is null ten set it to the one in config if (!isset($dataContext)) { $dataContext = \Swiftriver\Core\Setup::DALConfiguration()->DataContextType; } $classType = (string) $dataContext; $this->dataContext = new $classType(); }
/** * This function should allow calling classes to run basic sql select * statements and switch the implmentation based on the data content * type. * * @param string $sql * @return array["results","errors"] */ public function RunGenericQuery($sql) { $dataContext = \Swiftriver\Core\Setup::DALConfiguration()->DataContextType; switch ($dataContext) { case "\\Swiftriver\\Core\\Modules\\DataContext\\MySql_V2\\DataContext": $db = \Swiftriver\Core\Modules\DataContext\MySql_V2\DataContext::PDOConnection(); $statement = $db->prepare($sql); $result = $statement->execute(); return $result == false ? array("results" => array(), "errors" => $statement->errorInfo()) : array("results" => $statement->fetchAll(), "errors" => null); } }
/** * Function that takes in an instance of the AnalyticsRequest object * and attempts to match this to an instance of the IAnalyticsProvider * interface. * * @param AnalyticsRequest $request * @return AnalyticsRequest */ public function RunAnalyticsRequest($request) { $logger = \Swiftriver\Core\Setup::GetLogger(); $logger->log("Core::Analytics::AnalyticsEngine::__construct [Method invoked]", \PEAR_LOG_DEBUG); if ($request == null) { $logger->log("Core::Analytics::AnalyticsEngine::__construct [The request parameter was null]", \PEAR_LOG_DEBUG); $logger->log("Core::Analytics::AnalyticsEngine::__construct [Method finished]", \PEAR_LOG_DEBUG); return $request; } $dataContextType = \Swiftriver\Core\Setup::DALConfiguration()->DataContextType; $request->DataContextType = $dataContextType; $providerType = $request->RequestType; $logger->log("Core::Analytics::AnalyticsEngine::__construct [START: Looking for matching provider]", \PEAR_LOG_DEBUG); foreach ($this->analyticsProviders as $analyticsProvider) { if ($providerType != $analyticsProvider->ProviderType()) { continue; } try { $logger->log("Core::Analytics::AnalyticsEngine::__construct [START: Running provider]", \PEAR_LOG_DEBUG); $return = $analyticsProvider->ProvideAnalytics($request); $logger->log("Core::Analytics::AnalyticsEngine::__construct [END: Running provider]", \PEAR_LOG_DEBUG); $logger->log("Core::Analytics::AnalyticsEngine::__construct [Method finished]", \PEAR_LOG_DEBUG); return $return; } catch (\Exception $e) { $logger->log("Core::Analytics::AnalyticsEngine::__construct [An exception was thrown]", \PEAR_LOG_ERR); $logger->log("Core::Analytics::AnalyticsEngine::__construct [{$e}]", \PEAR_LOG_ERR); $logger->log("Core::Analytics::AnalyticsEngine::__construct [Method finished]", \PEAR_LOG_DEBUG); return $request; } } $logger->log("Core::Analytics::AnalyticsEngine::__construct [END: Looking for matching provider - No Provider found for {$providerType}]", \PEAR_LOG_ERR); $logger->log("Core::Analytics::AnalyticsEngine::__construct [Method finished]", \PEAR_LOG_DEBUG); return $request; }