Пример #1
0
 public function __construct($keyPrefix = 'class:', $ttl = 60)
 {
     $this->_keyPrefix = $keyPrefix;
     $this->_ttl = $ttl;
     if (\function_exists('apc_fetch')) {
         autoloadManager::getInstance()->registerCacheLoader(array($this, 'loadClass'));
         autoloadManager::getInstance()->registerCache(array($this, 'cache'));
     }
 }
Пример #2
0
 public function loadClass($name)
 {
     foreach ($this->_map as $prefix => $path) {
         if (0 !== \strpos($name, $prefix)) {
             continue;
         }
         if (null !== $this->_path) {
             $path = $this->_path . \DIRECTORY_SEPARATOR . $path;
         }
         $fn = $path . '/' . \str_replace(array('\\', '_', ""), array('/', '/', ''), $name) . '.php';
         if (\is_file($fn)) {
             include $fn;
             autoloadManager::getInstance()->cache($name, $fn);
             return true;
         }
     }
     return false;
 }
Пример #3
0
 public function loadClass($class)
 {
     if ($this->_namespace !== null) {
         if (\substr($class, 0, \strlen($this->_namespace) + 1) != $this->_namespace . '\\') {
             return false;
         }
     }
     $left = null === $this->_namespace ? $class : \substr($class, \strlen($this->_namespace) + 1);
     if (isset($this->_map[$left])) {
         $fn = (string) ($this->_path === null ? '' : $this->_path . \DIRECTORY_SEPARATOR) . $this->_map[$left];
         if (\is_file($fn)) {
             include $fn;
             autoloadManager::getInstance()->cache($class, $fn);
             unset($this->_map[$left]);
             return true;
         } else {
             require $fn;
             \clearstatcache(true);
             throw new \Exception('File not found "' . $fn . '". Class: "' . $class . '".');
         }
     }
     return false;
 }
 /**
  * Refreshes an already generated cache file
  * This solves problems with previously unexistant classes that
  * have been made available after.
  * The optimize functionnality will look at all null values of 
  * the available classes and does a new parse. if it founds that 
  * there are classes that has been made available, it will update
  * the file.
  * 
  * @return bool true if there has been a change to the array, false otherwise
  */
 public static function refresh($saveToFile = true)
 {
     $existantClasses = self::$_classes;
     $nullClasses = array_filter($existantClasses, array('self', '_getNullElements'));
     $newClasses = self::parseFolders();
     // $newClasses will override $nullClasses if the same key exists
     // this allows new added classes (that were flagged as null) to be
     // added
     self::$_classes = array_merge($nullClasses, $newClasses);
     if ($saveToFile) {
         self::saveToFile(self::$_classes);
     }
     return true;
 }
Пример #5
0
<?php

/**
 * FILE: Init.php
 *
 * @AUTHOR: LTD shalvasoft
 * @AUTHOR: Shalva Kvaratskhelia
 * PROJECT: MVC
 * VERSION: 1.0.0
 */
require_once 'config/defines.php';
require_once 'config/processors.php';
$confFile = dirname(dirname(__FILE__)) . '/application/config/config.php';
if (file_exists($confFile)) {
    /** @noinspection PhpIncludeInspection */
    require_once $confFile;
}
require_once 'Api/AutoloadManager/autoloadManager_interface.php';
require_once 'Api/AutoloadManager/autoloadManager.php';
$autoloadManager = new autoloadManager();
/** @noinspection PhpInternalEntityUsedInspection */
$autoloadManager->setSaveFile(system_dir() . '/Cache/autoload.php');
$autoloadManager->register();
$autoloadManager->addFolder(system_dir());
$autoloadManager->excludeFolder(system_dir() . '/Api/AutoloadManager');
$autoloadManager->generate();
$app = new bootstrap();
$app->Init();
Пример #6
0
 protected function __construct()
 {
     autoloadManager::getInstance()->registerNamespaceLoader(array($this, 'autoload'));
 }
Пример #7
0
<?php

session_cache_limiter(false);
session_start();
require '../vendor/autoload.php';
require "../settings_routes.php";
$autoloadManager = new autoloadManager(null, autoloadManager::SCAN_ONCE);
$autoloadManager->addFolder('../app/controller');
$autoloadManager->addFolder('../app/model');
$autoloadManager->register();
if ($debug) {
    header('Access-Control-Allow-Origin: *');
}
$router = new Router();
$router->setBaseClass($baseClass);
$router->setBasePath($basePath);
$router->addRoutes($routes);
$router->set404Handler($erroHandler);
$router->run();
Пример #8
0
<?php

header('Content-Type=text/html; charset=UTF-8');
function exception_error_handler($errno, $errstr, $errfile, $errline)
{
    throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
//set_error_handler("exception_error_handler");
require_once dirname(__FILE__) . '/../conf/configuration_front.php';
require_once dirname(__FILE__) . '/../core/autoloadManager.php';
autoloadManager::setSaveFile(dirname(__FILE__) . '/../tmp/front.php');
autoloadManager::addFolder(CORE);
autoloadManager::addFolder(BUSINESS);
spl_autoload_register('autoloadManager::loadClass');
$_REQUEST['controller'] = Toolbox::getArrayParameter($_REQUEST, 'controller', 'Feed');
$_REQUEST['action'] = Toolbox::getArrayParameter($_REQUEST, 'action', 'index');
// jquery based ajax application
$from = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 'XMLHttpRequest' === $_SERVER['HTTP_X_REQUESTED_WITH'] ? 'ajax' : 'http';
try {
    $front = frontDispatcher::getInstance();
    // Init Session
    // Save header for ajax call, so that we can either root or return false for ajax calls
    $actions = AccessHelper::getActions();
    // authenticate
    $AuthManager = new AuthManager($actions);
    $AuthManager->authenticate($front, '/?controller=Feed&action=index', $from);
    // Inject Dynamically changing objects
    $Container = ContainerFactory::get('front');
    $Container['Access'] = $actions;
    $Container['AuthManager'] = $AuthManager;
    $Container['Request'] = $_REQUEST;