/** * Get the instances of the object that were stored in container. * * @param none * @return void */ public function __construct() { $this->view = new View(); $this->container = ObjectContainer::getInstance(); $this->session = $this->container->offsetGet('SESSION'); $this->lang = $this->container->offsetGet('LOCALIZATION'); }
/** * Returns the instance of type IDatabase and also makes connection. * * @param string $databaseType * @throws FrameworkException * @return Instance of IDatabase */ public static function create($databaseType = 'MYSQLI') { $container = ObjectContainer::getInstance(); $bean = $container->offsetGet($databaseType); $instance = NULL; switch ($databaseType) { case 'MYSQL': $instance = MYSQLDriver::getInstance(); break; case 'MYSQLI': $instance = MYSQLIDriver::getInstance(); break; case 'PDO': $instance = PDODriver::getInstance(); break; case 'ORACLE': $instance = ORACLEDriver::getInstance(); break; case 'MSSQL': $instance = MSSQLDriver::getInstance(); break; case 'PGSQL': $instance = POSTGREDriver::getInstance(); break; case 'SQLITE': $instance = SQLITEDriver::getInstance(); break; case 'MARIA': break; case 'MONGO': break; default: throw new FrameworkException("Unsupported database driver {$databaseType}"); } if (!$instance instanceof IDatabase) { throw new FrameworkException("Make sure {$databaseType} Driver class is of type IDatabase"); } $instance->getConnection($bean); return $instance; }
private function loadLocalization() { // $temp = \explode('-', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $locObj = Localization::getInstance(); // $language = include $locObj->loadLanguage(trim(strtolower($temp[0]))); $language = (include $locObj->loadLanguage(\trim(\strtolower('en')))); ObjectContainer::getInstance()->offsetSet('LOCALIZATION', $language); }
include_once 'configuration/application.inc'; ########################################################################################################################### # Settings for Application - End # /** * Autoload method for dynamically loading classes. * * @param object $object Name of Class * @return void */ function __autoload($object) { $split = explode("\\", $object); $className = end($split); require_once "{$className}.php"; } $container = ObjectContainer::getInstance(); $container->offsetSet('FRAMEWORK', Framework::getInstance()); // Create the instance of framework and let your handlers initialized. $container->offsetSet('SESSION', Session::getInstance()); $container->offsetSet('MYSQLI', new DatabaseBean("MYSQLI", "localhost", "root", "nitesha", "phpmyadmin", 3306)); //$container->offsetSet('ORACLE', new DatabaseBean("ORACLE", "localhost", "root", "nitesha", "thebookmarker", "3306")); $container->offsetSet('LOGGER', Logger::getInstance()); //$container->offsetSet('MYSQLI-2', new DatabaseBean("MYSQLI", "localhost", "root", "nitesha", "musicplus", "3306")); // another mysql database //$container->offsetSet('PDO', new DatabaseBean("mysql", "localhost", "root", "nitesha", "musicplus", "3306")); # Do this when site is in maintenance or offline - Start # ########################################################################################################################### /* $default = array( 'controller' => 'Error', 'action' => 'default', 'params' => array('408') ); */
/** * {@inheritDoc} * @see \Define\Core\IView::removeObjectInSession() */ public function removeObjectInSession($objectName) { $container = ObjectContainer::getInstance(); $session = $container->offsetGet('SESSION'); $session->removeData($objectName); }