当前位置: 首页>>代码示例>>PHP>>正文


PHP Env::set方法代码示例

本文整理汇总了PHP中Env::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Env::set方法的具体用法?PHP Env::set怎么用?PHP Env::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Env的用法示例。


在下文中一共展示了Env::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetAfterSet

 function testGetAfterSet()
 {
     Env::set(Env::PROD);
     $this->assertEquals(Env::get(), Env::PROD);
     $this->assertTrue(Env::isProd());
     $this->assertFalse(Env::isTest());
 }
开发者ID:inad9300,项目名称:bed.php,代码行数:7,代码来源:EnvTest.php

示例2: preInit

 public function preInit(\Cx\Core\Core\Controller\Cx $cx)
 {
     global $_CONFIG;
     $domainRepo = new \Cx\Core\Net\Model\Repository\DomainRepository();
     $_CONFIG['domainUrl'] = $domainRepo->getMainDomain()->getName();
     \Env::set('config', $_CONFIG);
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:7,代码来源:ComponentController.class.php

示例3: MAL_EVAL

function MAL_EVAL($ast, $env)
{
    #echo "MAL_EVAL: " . _pr_str($ast) . "\n";
    if (!_list_Q($ast)) {
        return eval_ast($ast, $env);
    }
    if ($ast->count() === 0) {
        return $ast;
    }
    // apply list
    $a0 = $ast[0];
    $a0v = _symbol_Q($a0) ? $a0->value : $a0;
    switch ($a0v) {
        case "def!":
            $res = MAL_EVAL($ast[2], $env);
            return $env->set($ast[1], $res);
        case "let*":
            $a1 = $ast[1];
            $let_env = new Env($env);
            for ($i = 0; $i < count($a1); $i += 2) {
                $let_env->set($a1[$i], MAL_EVAL($a1[$i + 1], $let_env));
            }
            return MAL_EVAL($ast[2], $let_env);
        default:
            $el = eval_ast($ast, $env);
            $f = $el[0];
            return call_user_func_array($f, array_slice($el->getArrayCopy(), 1));
    }
}
开发者ID:joostkremers,项目名称:mal,代码行数:29,代码来源:step3_env.php

示例4: bootstrap

/**
 * Example of function that defines a setup process common to all the
 * application. May be take as a template, or used as-is. Suggestions on new
 * things to include or ways to improve it are welcome :)
 */
function bootstrap(int $env = Env::PROD)
{
    // Set the encoding of the mb_* functions
    mb_internal_encoding('UTF-8');
    // Set the same timezone as the one used by the database
    date_default_timezone_set('UTC');
    // Get rid of PHP's default custom header
    header_remove('X-Powered-By');
    // Determine the current environment
    Env::set($env);
    // Control which errors are fired depending on the environment
    if (Env::isProd()) {
        error_reporting(0);
        ini_set('display_errors', '0');
    } else {
        error_reporting(E_ALL & ~E_NOTICE);
        ini_set('display_errors', '1');
    }
    // Handling errors from exceptions
    set_exception_handler(function (\Throwable $e) {
        $data = ['title' => 'Unexpected exception', 'detail' => $e->getMessage() ?: ''];
        if (Env::isDev()) {
            $data['debug'] = ['exception' => get_class($e) . ' (' . $e->getCode() . ')', 'file' => $e->getFile() . ':' . $e->getLine(), 'trace' => $e->getTrace()];
        }
        (new Response(HttpStatus::InternalServerError, [], $data))->send();
    });
    // Handling errors from trigger_error and the alike
    set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline, array $errcontext) {
        $data = ['title' => 'Unexpected error', 'detail' => $errstr ?: ''];
        if (Env::isDev()) {
            $data['debug'] = ['error' => $errno, 'file' => $errfile . ':' . $errline, 'context' => $errcontext];
        }
        (new Response(HttpStatus::InternalServerError, [], $data))->send();
    });
}
开发者ID:inad9300,项目名称:bed.php,代码行数:40,代码来源:bootstrap.php

示例5: MAL_EVAL

function MAL_EVAL($ast, $env)
{
    #echo "MAL_EVAL: " . _pr_str($ast) . "\n";
    if (!_list_Q($ast)) {
        return eval_ast($ast, $env);
    }
    if ($ast->count() === 0) {
        return $ast;
    }
    // apply list
    $a0 = $ast[0];
    $a0v = _symbol_Q($a0) ? $a0->value : $a0;
    switch ($a0v) {
        case "def!":
            $res = MAL_EVAL($ast[2], $env);
            return $env->set($ast[1], $res);
        case "let*":
            $a1 = $ast[1];
            $let_env = new Env($env);
            for ($i = 0; $i < count($a1); $i += 2) {
                $let_env->set($a1[$i], MAL_EVAL($a1[$i + 1], $let_env));
            }
            return MAL_EVAL($ast[2], $let_env);
        case "do":
            #$el = eval_ast(array_slice($ast->getArrayCopy(), 1), $env);
            $el = eval_ast($ast->slice(1), $env);
            return $el[count($el) - 1];
        case "if":
            $cond = MAL_EVAL($ast[1], $env);
            if ($cond === NULL || $cond === false) {
                if (count($ast) === 4) {
                    return MAL_EVAL($ast[3], $env);
                } else {
                    return NULL;
                }
            } else {
                return MAL_EVAL($ast[2], $env);
            }
        case "fn*":
            return function () use($env, $ast) {
                $fn_env = new Env($env, $ast[1], func_get_args());
                return MAL_EVAL($ast[2], $fn_env);
            };
        default:
            $el = eval_ast($ast, $env);
            $f = $el[0];
            return call_user_func_array($f, array_slice($el->getArrayCopy(), 1));
    }
}
开发者ID:joostkremers,项目名称:mal,代码行数:49,代码来源:step4_if_fn_do.php

示例6: handler_search

 function handler_search(PlPage $page, PlUser $authUser, $payload, $mode = 'quick')
 {
     if (!isset($payload['quick'])) {
         $page->trigError('Malformed search query');
         return PL_BAD_REQUEST;
     }
     $query = trim($payload['quick']);
     if (@$payload['allow_special']) {
         if (starts_with($query, 'admin:')) {
             $page->jsonAssign('link_type', 'admin');
             $query = substr($query, 6);
         } else {
             if (starts_with($query, 'adm:')) {
                 $page->jsonAssign('link_type', 'admin');
                 $query = substr($query, 4);
             } else {
                 if (starts_with('admin', $query) || strpos($query, ':') !== false) {
                     $page->jsonAssign('profile_count', -1);
                     $page->jsonAssign('profiles', array());
                     return PL_JSON;
                 } else {
                     $page->jsonAssign('link_type', 'profile');
                 }
             }
         }
     }
     if (strlen($query) < 3) {
         $page->jsonAssign('profile_count', -1);
         $page->jsonAssign('profiles', array());
         return PL_JSON;
     }
     Env::set('quick', $query);
     foreach (array('with_soundex', 'exact') as $key) {
         if (isset($payload[$key])) {
             Env::set($key, $payload[$key]);
         }
     }
     require_once 'userset.inc.php';
     $view = new QuickSearchSet();
     $view->addMod('json', 'JSon', true, $payload);
     $view->apply('api/1/search', $page, 'json');
     return PL_JSON;
 }
开发者ID:Ekleog,项目名称:platal,代码行数:43,代码来源:api.php

示例7: prepareSidebarList

 public function prepareSidebarList()
 {
     $entity = $this->entity;
     $items = $entity::all('navPositionLeft');
     $itemsByCategory = [];
     $itemsByCategory['main'] = (object) ['name' => 'Main Navigation', 'items' => []];
     Env::set('additional_nav_categores', [], -1);
     $additionalCats = Env::get('additional_nav_categores');
     foreach (Env::get('additional_nav_categores') as $identifier => $name) {
         $itemsByCategory[$identifier] = (object) ['name' => $name, 'items' => []];
     }
     $itemsByCategory['not_linked'] = (object) ['name' => 'Not Linked', 'items' => []];
     foreach ($items as $item) {
         if (!isset($item->nav) || !isset($itemsByCategory[@$item->nav])) {
             continue;
         }
         $itemsByCategory[$item->nav]->items[] = $item;
     }
     View::set('itemsByCategory', $itemsByCategory);
 }
开发者ID:fierce,项目名称:fierce,代码行数:20,代码来源:PagesController.php

示例8: updatePhpCache

 /**
  * Write all settings to the config file
  *
  */
 public static function updatePhpCache()
 {
     global $_ARRAYLANG, $_CONFIG;
     if (!\Cx\Lib\FileSystem\FileSystem::makeWritable(self::getSettingsFile())) {
         \Message::add(self::getSettingsFile() . ' ' . $_ARRAYLANG['TXT_SETTINGS_ERROR_WRITABLE'], \Message::CLASS_ERROR);
         return false;
     }
     //get values from ymlsetting
     \Cx\Core\Setting\Controller\Setting::init('Config', NULL, 'Yaml');
     $ymlArray = \Cx\Core\Setting\Controller\Setting::getArray('Config', null);
     $intMaxLen = 0;
     $ymlArrayValues = array();
     foreach ($ymlArray as $key => $ymlValue) {
         $_CONFIG[$key] = $ymlValue['value'];
         $ymlArrayValues[$ymlValue['group']][$key] = $ymlValue['value'];
         // special case to add legacy domainUrl configuration option
         if ($key == 'mainDomainId') {
             $domainRepository = new \Cx\Core\Net\Model\Repository\DomainRepository();
             $objMainDomain = $domainRepository->findOneBy(array('id' => $ymlArray[$key]['value']));
             if ($objMainDomain) {
                 $domainUrl = $objMainDomain->getName();
             } else {
                 $domainUrl = $_SERVER['SERVER_NAME'];
             }
             $ymlArrayValues[$ymlValue['group']]['domainUrl'] = $domainUrl;
             if ($_CONFIG['xmlSitemapStatus'] == 'on') {
                 \Cx\Core\PageTree\XmlSitemapPageTree::write();
             }
         }
         $intMaxLen = strlen($key) > $intMaxLen ? strlen($key) : $intMaxLen;
     }
     $intMaxLen += strlen('$_CONFIG[\'\']') + 1;
     //needed for formatted output
     // update environment
     \Env::set('config', $_CONFIG);
     $strHeader = "<?php\n";
     $strHeader .= "/**\n";
     $strHeader .= "* This file is generated by the \"settings\"-menu in your CMS.\n";
     $strHeader .= "* Do not try to edit it manually!\n";
     $strHeader .= "*/\n\n";
     $strFooter = "?>";
     //Write values
     $data = $strHeader;
     $strBody = '';
     foreach ($ymlArrayValues as $group => $sectionValues) {
         $strBody .= "/**\n";
         $strBody .= "* -------------------------------------------------------------------------\n";
         $strBody .= "* " . ucfirst($group) . "\n";
         $strBody .= "* -------------------------------------------------------------------------\n";
         $strBody .= "*/\n";
         foreach ($sectionValues as $sectionName => $sectionNameValue) {
             $strBody .= sprintf("%-" . $intMaxLen . "s", '$_CONFIG[\'' . $sectionName . '\']');
             $strBody .= "= ";
             $strBody .= (self::isANumber($sectionNameValue) ? $sectionNameValue : '"' . str_replace('"', '\\"', $sectionNameValue) . '"') . ";\n";
         }
         $strBody .= "\n";
     }
     $data .= $strBody;
     $data .= $strFooter;
     try {
         $objFile = new \Cx\Lib\FileSystem\File(self::getSettingsFile());
         $objFile->write($data);
         return true;
     } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
         \DBG::msg($e->getMessage());
     }
     return false;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:72,代码来源:Config.class.php

示例9: catch

<?php

namespace Fierce;

try {
    Env::get('_test_foo');
    $this->assert(false, 'Exception accessing unknown Env value');
} catch (\Exception $e) {
    $this->assert(true, 'Exception accessing unknown Env value');
}
Env::set('_test_foo', 'bar');
$this->assertEqual(Env::get('_test_foo'), 'bar', 'Read Env value');
Env::set('_test_foo', 'a', 10);
$this->assertEqual(Env::get('_test_foo'), 'a', 'Apply higher priority value');
Env::set('_test_foo', 'b', -5);
$this->assertEqual(Env::get('_test_foo'), 'a', 'Ignore low priority value');
Env::push('_test_foo', 'c');
$this->assertEqual(Env::get('_test_foo'), 'c', 'Push env value');
Env::push('_test_foo', 'd');
$this->assertEqual(Env::get('_test_foo'), 'd', 'Push another env value');
Env::pop('_test_foo');
$this->assertEqual(Env::get('_test_foo'), 'c', 'Pop env value');
Env::pop('_test_foo');
$this->assertEqual(Env::get('_test_foo'), 'a', 'Pop another env value');
try {
    Env::pop('_test_foo');
    $this->assert(false, 'Exception popping too many times');
} catch (\Exception $e) {
    $this->assert(true, 'Exception popping too many times');
}
try {
开发者ID:fierce,项目名称:fierce,代码行数:31,代码来源:fierce-test-env.php

示例10: MAL_EVAL

function MAL_EVAL($ast, $env)
{
    while (true) {
        #echo "MAL_EVAL: " . _pr_str($ast) . "\n";
        if (!_list_Q($ast)) {
            return eval_ast($ast, $env);
        }
        // apply list
        $ast = macroexpand($ast, $env);
        if (!_list_Q($ast)) {
            return eval_ast($ast, $env);
        }
        if ($ast->count() === 0) {
            return $ast;
        }
        $a0 = $ast[0];
        $a0v = _symbol_Q($a0) ? $a0->value : $a0;
        switch ($a0v) {
            case "def!":
                $res = MAL_EVAL($ast[2], $env);
                return $env->set($ast[1], $res);
            case "let*":
                $a1 = $ast[1];
                $let_env = new Env($env);
                for ($i = 0; $i < count($a1); $i += 2) {
                    $let_env->set($a1[$i], MAL_EVAL($a1[$i + 1], $let_env));
                }
                $ast = $ast[2];
                $env = $let_env;
                break;
                // Continue loop (TCO)
            // Continue loop (TCO)
            case "quote":
                return $ast[1];
            case "quasiquote":
                $ast = quasiquote($ast[1]);
                break;
                // Continue loop (TCO)
            // Continue loop (TCO)
            case "defmacro!":
                $func = MAL_EVAL($ast[2], $env);
                $func->ismacro = true;
                return $env->set($ast[1], $func);
            case "macroexpand":
                return macroexpand($ast[1], $env);
            case "php*":
                $res = eval($ast[1]);
                switch (gettype($res)) {
                    case "array":
                        if ($res !== array_values($res)) {
                            $new_res = _hash_map();
                            $new_res->exchangeArray($res);
                            return $new_res;
                        } else {
                            return call_user_func_array('_list', $res);
                        }
                    default:
                        return $res;
                }
            case "try*":
                $a1 = $ast[1];
                $a2 = $ast[2];
                if ($a2[0]->value === "catch*") {
                    try {
                        return MAL_EVAL($a1, $env);
                    } catch (Error $e) {
                        $catch_env = new Env($env, array($a2[1]), array($e->obj));
                        return MAL_EVAL($a2[2], $catch_env);
                    } catch (Exception $e) {
                        $catch_env = new Env($env, array($a2[1]), array($e->getMessage()));
                        return MAL_EVAL($a2[2], $catch_env);
                    }
                } else {
                    return MAL_EVAL($a1, $env);
                }
            case "do":
                eval_ast($ast->slice(1, -1), $env);
                $ast = $ast[count($ast) - 1];
                break;
                // Continue loop (TCO)
            // Continue loop (TCO)
            case "if":
                $cond = MAL_EVAL($ast[1], $env);
                if ($cond === NULL || $cond === false) {
                    if (count($ast) === 4) {
                        $ast = $ast[3];
                    } else {
                        $ast = NULL;
                    }
                } else {
                    $ast = $ast[2];
                }
                break;
                // Continue loop (TCO)
            // Continue loop (TCO)
            case "fn*":
                return _function('MAL_EVAL', 'native', $ast[2], $env, $ast[1]);
            default:
                $el = eval_ast($ast, $env);
                $f = $el[0];
//.........这里部分代码省略.........
开发者ID:joostkremers,项目名称:mal,代码行数:101,代码来源:stepA_mal.php

示例11: executeContrexxUpdate

function executeContrexxUpdate()
{
    global $_CORELANG, $_CONFIG, $objDatabase, $objUpdate, $_DBCONFIG;
    /**
     * These are the modules which MUST have new template in order for Cloudrexx
     * to work correctly. CSS definitions for these modules will get updated too.
     */
    $viewUpdateTable = array('newsletter' => array('version' => '3.1.0.0', 'dependencies' => array('forms')), 'calendar' => array('version' => '3.1.0.0', 'dependencies' => array()), 'shop' => array('version' => '3.0.0.0', 'dependencies' => array('forms')), 'voting' => array('version' => '2.1.0.0', 'dependencies' => array()), 'access' => array('version' => '2.0.0.0', 'dependencies' => array('forms', 'captcha', 'uploader')), 'podcast' => array('version' => '2.0.0.0', 'dependencies' => array()), 'login' => array('version' => '3.0.2.0', 'dependencies' => array('forms', 'captcha')), 'media1' => array('version' => '3.0.0.0', 'dependencies' => array()), 'media2' => array('version' => '3.0.0.0', 'dependencies' => array()), 'media3' => array('version' => '3.0.0.0', 'dependencies' => array()), 'media4' => array('version' => '3.0.0.0', 'dependencies' => array()));
    $_SESSION['contrexx_update']['copyFilesFinished'] = !empty($_SESSION['contrexx_update']['copyFilesFinished']) ? $_SESSION['contrexx_update']['copyFilesFinished'] : false;
    // Copy cx files to the root directory
    if (!$_SESSION['contrexx_update']['copyFilesFinished']) {
        if (!loadMd5SumOfOriginalCxFiles()) {
            return false;
        }
        $copyFilesStatus = copyCxFilesToRoot(dirname(__FILE__) . '/cx_files', ASCMS_PATH . ASCMS_PATH_OFFSET);
        if ($copyFilesStatus !== true) {
            if ($copyFilesStatus === 'timeout') {
                setUpdateMsg(1, 'timeout');
            }
            return false;
        }
        if (extension_loaded('apc') && ini_get('apc.enabled')) {
            apc_clear_cache();
        }
        $_SESSION['contrexx_update']['copyFilesFinished'] = true;
        // log modified files
        DBG::msg('MODIFIED FILES:');
        if (isset($_SESSION['contrexx_update']['modified_files'])) {
            DBG::dump($_SESSION['contrexx_update']['modified_files']);
        }
        // we need to stop the script here to force a reinitialization of the update system
        // this is required so that the new constants from config/set_constants.php are loaded
        //setUpdateMsg($_CORELANG['TXT_UPDATE_PROCESS_HALTED'], 'title');
        //setUpdateMsg($_CORELANG['TXT_UPDATE_PROCESS_HALTED_TIME_MSG'].'<br />', 'msg');
        //setUpdateMsg('Installation der neuen Dateien abgeschlossen.<br /><br />', 'msg');
        //setUpdateMsg('<input type="submit" value="'.$_CORELANG['TXT_CONTINUE_UPDATE'].'" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button');
        setUpdateMsg(1, 'timeout');
        return false;
    }
    unset($_SESSION['contrexx_update']['copiedCxFilesIndex']);
    /**
     * This needs to be initialized before loading config/doctrine.php
     * Because we overwrite the Gedmo model (so we need to load our model
     * before doctrine loads the Gedmo one)
     */
    require_once ASCMS_CORE_PATH . '/ClassLoader/ClassLoader.class.php';
    $cl = new \Cx\Core\ClassLoader\ClassLoader(ASCMS_DOCUMENT_ROOT, true);
    Env::set('ClassLoader', $cl);
    FWLanguage::init();
    if (!isset($_SESSION['contrexx_update']['update'])) {
        $_SESSION['contrexx_update']['update'] = array();
    }
    if (!isset($_SESSION['contrexx_update']['update']['done'])) {
        $_SESSION['contrexx_update']['update']['done'] = array();
    }
    /////////////////////
    // UTF-8 MIGRATION //
    /////////////////////
    if (!(include_once dirname(__FILE__) . '/components/core/core.php')) {
        setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UNABLE_LOAD_UPDATE_COMPONENT'], dirname(__FILE__) . '/components/core/core.php'));
        return false;
    }
    if (!(include_once dirname(__FILE__) . '/components/core/utf8.php')) {
        setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_UNABLE_LOAD_UPDATE_COMPONENT'], dirname(__FILE__) . '/components/core/utf8.php'));
        return false;
    }
    if (!in_array('utf8', ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['done']))) {
        $result = _utf8Update();
        if ($result === 'timeout') {
            setUpdateMsg(1, 'timeout');
            return false;
        } elseif (!$result) {
            if (empty($objUpdate->arrStatusMsg['title'])) {
                setUpdateMsg(sprintf($_CORELANG['TXT_UPDATE_COMPONENT_BUG'], $_CORELANG['TXT_UTF_CONVERSION']), 'title');
            }
            return false;
        }
        if ($result === 'charset_changed') {
            // write new charset/collation definition to config file
            if (!_writeNewConfigurationFile()) {
                return false;
            }
        }
        $_SESSION['contrexx_update']['update']['done'][] = 'utf8';
        // _utf8Update() might have changed the charset/collation and migrated some tables,
        // therefore, we will force a reinitialization of the update system
        // to ensure that all db-connections are using the proper charset/collation
        \DBG::msg('Changed collation to: ' . $_DBCONFIG['collation']);
        \DBG::msg('Force reinitialization of update...');
        setUpdateMsg(1, 'timeout');
        return false;
    }
    /////////////////////
    /////////////////////////////
    // Session Table MIGRATION //
    /////////////////////////////
    $isSessionVariableTableExists = \Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'session_variable');
    if ($isSessionVariableTableExists) {
        createOrAlterSessionVariableTable();
    }
//.........这里部分代码省略.........
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:101,代码来源:update.php

示例12: getEntityManager

 /**
  * Returns the doctrine entity manager
  * @return \Doctrine\ORM\EntityManager 
  */
 public function getEntityManager()
 {
     if ($this->em) {
         return $this->em;
     }
     global $objCache;
     $config = new \Doctrine\ORM\Configuration();
     $userCacheEngine = $objCache->getUserCacheEngine();
     if (!$objCache->getUserCacheActive()) {
         $userCacheEngine = \Cx\Core_Modules\Cache\Controller\Cache::CACHE_ENGINE_OFF;
     }
     $arrayCache = new \Doctrine\Common\Cache\ArrayCache();
     switch ($userCacheEngine) {
         case \Cx\Core_Modules\Cache\Controller\Cache::CACHE_ENGINE_APC:
             $cache = new \Doctrine\Common\Cache\ApcCache();
             $cache->setNamespace($this->db->getName() . '.' . $this->db->getTablePrefix());
             break;
         case \Cx\Core_Modules\Cache\Controller\Cache::CACHE_ENGINE_MEMCACHE:
             $memcache = $objCache->getMemcache();
             if ($memcache instanceof \Memcache) {
                 $cache = new \Doctrine\Common\Cache\MemcacheCache();
                 $cache->setMemcache($memcache);
             } elseif ($memcache instanceof \Memcached) {
                 $cache = new \Doctrine\Common\Cache\MemcachedCache();
                 $cache->setMemcache($memcache);
             }
             $cache->setNamespace($this->db->getName() . '.' . $this->db->getTablePrefix());
             break;
         case \Cx\Core_Modules\Cache\Controller\Cache::CACHE_ENGINE_XCACHE:
             $cache = new \Doctrine\Common\Cache\XcacheCache();
             $cache->setNamespace($this->db->getName() . '.' . $this->db->getTablePrefix());
             break;
         case \Cx\Core_Modules\Cache\Controller\Cache::CACHE_ENGINE_FILESYSTEM:
             $cache = new \Cx\Core_Modules\Cache\Controller\Doctrine\CacheDriver\FileSystemCache(ASCMS_CACHE_PATH);
             break;
         default:
             $cache = $arrayCache;
             break;
     }
     \Env::set('cache', $cache);
     //$config->setResultCacheImpl($cache);
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     $config->setProxyDir(ASCMS_MODEL_PROXIES_PATH);
     $config->setProxyNamespace('Cx\\Model\\Proxies');
     /**
      * This should be set to true if workbench is present and active.
      * Just checking for workbench.config is not really a good solution.
      * Since ConfigurationFactory used by EM caches auto generation
      * config value, there's no possibility to set this later.
      */
     $config->setAutoGenerateProxyClasses(file_exists(ASCMS_DOCUMENT_ROOT . '/workbench.config'));
     $connectionOptions = array('pdo' => $this->getPdoConnection(), 'dbname' => $this->db->getName());
     $evm = new \Doctrine\Common\EventManager();
     $chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $driverImpl = new \Cx\Core\Model\Controller\YamlDriver(array(ASCMS_CORE_PATH . '/Core' . '/Model/Yaml'));
     $chainDriverImpl->addDriver($driverImpl, 'Cx');
     //loggable stuff
     $loggableDriverImpl = $config->newDefaultAnnotationDriver(ASCMS_LIBRARY_PATH . '/doctrine/Gedmo/Loggable/Entity');
     $chainDriverImpl->addDriver($loggableDriverImpl, 'Gedmo\\Loggable');
     $this->loggableListener = new \Cx\Core\Model\Model\Event\LoggableListener();
     $this->loggableListener->setUsername('currently_loggedin_user');
     // in real world app the username should be loaded from session, example:
     // Session::getInstance()->read('user')->getUsername();
     $evm->addEventSubscriber($this->loggableListener);
     //tree stuff
     $treeListener = new \Gedmo\Tree\TreeListener();
     $evm->addEventSubscriber($treeListener);
     $config->setMetadataDriverImpl($chainDriverImpl);
     //table prefix
     $prefixListener = new \DoctrineExtension\TablePrefixListener($this->db->getTablePrefix());
     $evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $prefixListener);
     $config->setSqlLogger(new \Cx\Lib\DBG\DoctrineSQLLogger());
     $em = \Cx\Core\Model\Controller\EntityManager::create($connectionOptions, $config, $evm);
     //resolve enum, set errors
     $conn = $em->getConnection();
     $conn->setCharset($this->db->getCharset());
     $conn->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     $conn->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string');
     $this->em = $em;
     return $this->em;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:86,代码来源:Db.class.php

示例13: resolvePage

 /**
  * Does the resolving work, extends $this->url with targetPath and params.
  */
 public function resolvePage($internal = false)
 {
     // Abort here in case we're handling a legacy request.
     // The legacy request will be handled by $this->legacyResolve().
     // Important: We must check for $internal == FALSE here, to abort the resolving process
     //            only when we're resolving the initial (original) request.
     //            Internal resolving requests might be called by $this->legacyResolve()
     //            and shall therefore be processed.
     if (!$internal && isset($_REQUEST['section'])) {
         throw new ResolverException('Legacy request');
     }
     $path = $this->url->getSuggestedTargetPath();
     if (!$this->page || $internal) {
         if ($this->pagePreview) {
             if (!empty($this->sessionPage) && !empty($this->sessionPage['pageId'])) {
                 $this->getPreviewPage();
             }
         }
         //(I) see what the model has for us
         $result = $this->pageRepo->getPagesAtPath($this->url->getLangDir() . '/' . $path, null, $this->lang, false, \Cx\Core\ContentManager\Model\Repository\PageRepository::SEARCH_MODE_PAGES_ONLY);
         if (isset($result['page']) && $result['page'] && $this->pagePreview) {
             if (empty($this->sessionPage)) {
                 if (\Permission::checkAccess(6, 'static', true)) {
                     $result['page']->setActive(true);
                     $result['page']->setDisplay(true);
                     if ($result['page']->getEditingStatus() == 'hasDraft' || $result['page']->getEditingStatus() == 'hasDraftWaiting') {
                         $logEntries = $this->logRepo->getLogEntries($result['page']);
                         $this->logRepo->revert($result['page'], $logEntries[1]->getVersion());
                     }
                 }
             }
         }
         //(II) sort out errors
         if (!$result) {
             throw new ResolverException('Unable to locate page (tried path ' . $path . ').');
         }
         if (!$result['page']) {
             throw new ResolverException('Unable to locate page for this language. (tried path ' . $path . ').');
         }
         if (!$result['page']->isActive()) {
             throw new ResolverException('Page found, but it is not active.');
         }
         // if user has no rights to see this page, we redirect to login
         $this->checkPageFrontendProtection($result['page']);
         // If an older revision was requested, revert to that in-place:
         if (!empty($this->historyId) && \Permission::checkAccess(6, 'static', true)) {
             $this->logRepo->revert($result['page'], $this->historyId);
         }
         //(III) extend our url object with matched path / params
         $this->url->setTargetPath($result['matchedPath'] . $result['unmatchedPath']);
         $this->url->setParams($this->url->getSuggestedParams());
         $this->page = $result['page'];
     }
     if (!$this->urlPage) {
         $this->urlPage = clone $this->page;
     }
     /*
      the page we found could be a redirection.
      in this case, the URL object is overwritten with the target details and
      resolving starts over again.
     */
     $target = $this->page->getTarget();
     $isRedirection = $this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_REDIRECT;
     $isAlias = $this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS;
     //handles alias redirections internal / disables external redirection
     $this->forceInternalRedirection = $this->forceInternalRedirection || $isAlias;
     if ($target && ($isRedirection || $isAlias)) {
         // Check if page is a internal redirection and if so handle it
         if ($this->page->isTargetInternal()) {
             //TODO: add check for endless/circular redirection (a -> b -> a -> b ... and more complex)
             $nId = $this->page->getTargetNodeId();
             $lId = $this->page->getTargetLangId();
             $module = $this->page->getTargetModule();
             $cmd = $this->page->getTargetCmd();
             $qs = $this->page->getTargetQueryString();
             $langId = $lId ? $lId : $this->lang;
             // try to find the redirection target page
             if ($nId) {
                 $targetPage = $this->pageRepo->findOneBy(array('node' => $nId, 'lang' => $langId));
                 // revert to default language if we could not retrieve the specified langauge by the redirection.
                 // so lets try to load the redirection of the current language
                 if (!$targetPage) {
                     if ($langId != 0) {
                         //make sure we weren't already retrieving the default language
                         $targetPage = $this->pageRepo->findOneBy(array('node' => $nId, 'lang' => $this->lang));
                         $langId = $this->lang;
                     }
                 }
             } else {
                 $targetPage = $this->pageRepo->findOneByModuleCmdLang($module, $cmd, $langId);
                 // in case we were unable to find the requested page, this could mean that we are
                 // trying to retrieve a module page that uses a string with an ID (STRING_ID) as CMD.
                 // therefore, lets try to find the module by using the string in $cmd and INT in $langId as CMD.
                 // in case $langId is really the requested CMD then we will have to set the
                 // resolved language back to our original language $this->lang.
                 if (!$targetPage) {
                     $targetPage = $this->pageRepo->findOneBymoduleCmdLang($module, $cmd . '_' . $langId, $this->lang);
//.........这里部分代码省略.........
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:101,代码来源:Resolver.class.php

示例14: die

if (!$objDatabase) {
    die($errorMsg);
}
Env::set('db', $objDatabase);
if (!\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'session_variable')) {
    require_once UPDATE_CORE . '/session.class.php';
    // Start session
    $sessionObj = new cmsSession();
} else {
    require_once UPDATE_CORE . '/session32.class.php';
    $sessionObj = \cmsSession::getInstance();
}
$sessionObj->cmsSessionStatusUpdate('backend');
// Initialize base system
$objInit = new InitCMS('update', \Env::get('em'));
Env::set('init', $objInit);
JS::activate('cx');
JS::activate('jquery-tools');
JS::registerJS('lib/contrexxUpdate.php');
JS::registerJS('lib/javascript/html2dom.js');
// Debugging
try {
    // load file classes
    require_once dirname(__FILE__) . '/lib/FRAMEWORK/FileSystem/FileInterface.interface.php';
    require_once dirname(__FILE__) . '/lib/FRAMEWORK/FileSystem/FileSystem.class.php';
    require_once dirname(__FILE__) . '/lib/FRAMEWORK/FileSystem/FileSystemFile.class.php';
    require_once dirname(__FILE__) . '/lib/FRAMEWORK/FileSystem/FTPFile.class.php';
    require_once dirname(__FILE__) . '/lib/FRAMEWORK/FileSystem/File.class.php';
    activateDebugging();
} catch (\Exception $e) {
    // don't handle this exception here because we can't print a nice error message
开发者ID:Niggu,项目名称:cloudrexx,代码行数:31,代码来源:index.php

示例15: postResolve

 /**
  * Do something after resolving is done
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function postResolve(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_BACKEND:
             global $objInit, $_LANGID, $_FRONTEND_LANGID, $_CORELANG, $_ARRAYLANG, $plainCmd;
             $objInit->_initBackendLanguage();
             $objInit->getUserFrontendLangId();
             $_LANGID = $objInit->getBackendLangId();
             $_FRONTEND_LANGID = $objInit->userFrontendLangId;
             /**
              * Language constants
              *
              * Defined as follows:
              * - BACKEND_LANG_ID is set to the visible backend language
              *   in the backend *only*.  In the frontend, it is *NOT* defined!
              *   It indicates a backend user and her currently selected language.
              *   Use this in methods that are intended *for backend use only*.
              *   It *MUST NOT* be used to determine the language for any kind of content!
              * - FRONTEND_LANG_ID is set to the selected frontend or content language
              *   both in the back- and frontend.
              *   It *always* represents the language of content being viewed or edited.
              *   Use FRONTEND_LANG_ID for that purpose *only*!
              * - LANG_ID is set to the same value as BACKEND_LANG_ID in the backend,
              *   and to the same value as FRONTEND_LANG_ID in the frontend.
              *   It *always* represents the current users' selected language.
              *   It *MUST NOT* be used to determine the language for any kind of content!
              * @since 2.2.0
              */
             define('FRONTEND_LANG_ID', $_FRONTEND_LANGID);
             define('BACKEND_LANG_ID', $_LANGID);
             define('LANG_ID', $_LANGID);
             /**
              * Core language data
              * @ignore
              */
             // Corelang might be initialized by CSRF already...
             if (!is_array($_CORELANG) || !count($_CORELANG)) {
                 $_CORELANG = $objInit->loadLanguageData('core');
             }
             /**
              * Module specific language data
              * @ignore
              */
             $_ARRAYLANG = $objInit->loadLanguageData($plainCmd);
             $_ARRAYLANG = array_merge($_ARRAYLANG, $_CORELANG);
             \Env::set('lang', $_ARRAYLANG);
             break;
         default:
             break;
     }
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:56,代码来源:ComponentController.class.php


注:本文中的Env::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。