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


PHP Env类代码示例

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


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

示例1: 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

示例2: 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

示例3: mediasourceLoad

 /**
  * @param MediaSourceManager $mediaBrowserConfiguration
  */
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('MediaBrowser');
     $mediaType = new MediaSource('files', $_ARRAYLANG['TXT_FILEBROWSER_FILES'], array($this->cx->getWebsiteImagesContentPath(), $this->cx->getWebsiteImagesContentWebPath()), array(), 1);
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:10,代码来源:MediaBrowserEventListener.class.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: registerYamlSettingEventListener

 public static function registerYamlSettingEventListener()
 {
     $evm = \Env::get('cx')->getEvents();
     $yamlSettingEventListener = new \Cx\Core\Config\Model\Event\YamlSettingEventListener();
     $evm->addModelListener(\Doctrine\ORM\Events::preUpdate, 'Cx\\Core\\Setting\\Model\\Entity\\YamlSetting', $yamlSettingEventListener);
     $evm->addModelListener('postFlush', 'Cx\\Core\\Setting\\Model\\Entity\\YamlSetting', $yamlSettingEventListener);
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:7,代码来源:ComponentController.class.php

示例6: preFinalize

 /**
  * @param Sigma $template
  */
 public function preFinalize(Sigma $template)
 {
     if (count($this->mediaBrowserInstances) == 0) {
         return;
     } else {
         global $_ARRAYLANG;
         /**
          * @var $init \InitCMS
          */
         $init = \Env::get('init');
         $init->loadLanguageData('MediaBrowser');
         foreach ($_ARRAYLANG as $key => $value) {
             if (preg_match("/TXT_FILEBROWSER_[A-Za-z0-9]+/", $key)) {
                 \ContrexxJavascript::getInstance()->setVariable($key, $value, 'mediabrowser');
             }
         }
         $thumbnailsTemplate = new Sigma();
         $thumbnailsTemplate->loadTemplateFile($this->cx->getCoreModuleFolderName() . '/MediaBrowser/View/Template/Thumbnails.html');
         $thumbnailsTemplate->setVariable('TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE', sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE']));
         foreach (UploaderConfiguration::getInstance()->getThumbnails() as $thumbnail) {
             $thumbnailsTemplate->setVariable(array('THUMBNAIL_NAME' => sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_' . strtoupper($thumbnail['name']) . '_SIZE'], $thumbnail['size']), 'THUMBNAIL_ID' => $thumbnail['id'], 'THUMBNAIL_SIZE' => $thumbnail['size']));
             $thumbnailsTemplate->parse('thumbnails');
         }
         \ContrexxJavascript::getInstance()->setVariable('thumbnails_template', $thumbnailsTemplate->get(), 'mediabrowser');
         \JS::activate('mediabrowser');
         \JS::registerJS('core_modules/MediaBrowser/View/Script/mediabrowser.js');
     }
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:31,代码来源:ComponentController.class.php

示例7: 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)
 {
     global $plainCmd, $cmd, $_CORELANG;
     // CSRF code needs to be even in the login form. otherwise, we
     // could not do a super-generic check later.. NOTE: do NOT move
     // this above the "new cmsSession" line!
     Csrf::add_code();
     // CSRF protection.
     // Note that we only do the check as long as there's no
     // cmd given; this is so we can reload the main screen if
     // the check has failed somehow.
     // fileBrowser is an exception, as it eats CSRF codes like
     // candy. We're doing \Cx\Core\Csrf\Controller\Csrf::check_code() in the relevant
     // parts in the module instead.
     // The CSRF code needn't to be checked in the login module
     // because the user isn't logged in at this point.
     // TODO: Why is upload excluded? The CSRF check doesn't take place in the upload module!
     if (!empty($plainCmd) && !empty($cmd) and !in_array($plainCmd, array('FileBrowser', 'Upload', 'Login', 'Home'))) {
         // Since language initialization in in the same hook as this
         // and we cannot define the order of module-processing,
         // we need to check if language is already initialized:
         if (!is_array($_CORELANG) || !count($_CORELANG)) {
             $objInit = \Env::get('init');
             $objInit->_initBackendLanguage();
             $_CORELANG = $objInit->loadLanguageData('core');
         }
         Csrf::check_code();
     }
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:34,代码来源:ComponentController.class.php

示例8: langA

function langA($name, $args)
{
    static $base = null;
    $value = Localization::instance()->lang($name);
    if (is_null($value)) {
        if (!Env::isDebugging()) {
            if (!$base instanceof Localization) {
                $base = new Localization();
                $base->loadSettings("en_us", ROOT . "/language");
            }
            $value = $base->lang($name);
        }
        if (is_null($value)) {
            $value = Localization::instance()->lang(str_replace(" ", "_", $name));
            if (is_null($value)) {
                $value = Localization::instance()->lang(str_replace("_", " ", $name));
                if (is_null($value)) {
                    return "Missing lang: {$name}";
                }
            }
        }
    }
    // We have args? Replace all {x} with arguments
    if (is_array($args) && count($args)) {
        $i = 0;
        foreach ($args as $arg) {
            $value = str_replace('{' . $i . '}', $arg, $value);
            $i++;
        }
        // foreach
    }
    // if
    // Done here...
    return $value;
}
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:35,代码来源:localization.php

示例9: __construct

 /**
  * Initialize this interface
  * 
  * Loads all commands
  * @param \Cx\Core\Core\Controller\Cx $cx Cloudrexx main class
  */
 public function __construct($cx)
 {
     $this->cx = $cx;
     \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/Typing/Model/Entity/AutoBoxedObject.class.php');
     \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/Typing/Model/Entity/Primitives.class.php');
     $this->commands = array('db' => new DbCommand($this), 'import' => new ImportCommand($this), 'create' => new CreateCommand($this), 'uninstall' => new UninstallCommand($this), 'activate' => new ActivateCommand($this), 'deactivate' => new DeactivateCommand($this), 'move' => new MoveCommand($this), 'copy' => new CopyCommand($this), 'remove' => new RemoveCommand($this), 'test' => new TestCommand($this), 'export' => new ExportCommand($this));
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:13,代码来源:UserInterface.class.php

示例10: __construct

 /**
  * Constructor
  * the class JsonLink handles, the link status whether the link is resolved or not.
  */
 public function __construct()
 {
     $this->em = \Env::get('em');
     if ($this->em) {
         $this->linkRepo = $this->em->getRepository('\\Cx\\Core_Modules\\LinkManager\\Model\\Entity\\Link');
     }
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:11,代码来源:JsonLink.class.php

示例11: find_cinemas_brazil

function find_cinemas_brazil()
{
    $start = microtime(true);
    $cinemas_br = Env::path('temp/brasil.json');
    $cinemas_br = file_get_contents($cinemas_br);
    $cinemas_br = json_decode($cinemas_br);
    //loop em todos os estados e cidades do estado
    $new_cinemas = array();
    $invalid_cinemas = array();
    foreach ($cinemas_br as $value) {
        $estado = $value->nome;
        $uf = $value->codigo;
        $cidades = $value->cidades;
        $cinema_finder = new CinemaFinder('br', $uf, $cidades);
        $cinemas = $cinema_finder->get_all_cinemas();
        $template = new CinemaTemplate();
        foreach ($cinemas as $cinema) {
            $base_dir = "cinema/br/";
            //passa o codigo do estado temporariamente para depois alterar e verificar se o cinema é realmente desse local
            $cinema->state_code = $uf;
            $template->create($base_dir, $cinema);
        }
        $new_cinemas = array_merge($new_cinemas, $template->get_new_cinemas());
        $invalid_cinemas = array_merge($invalid_cinemas, $template->get_invalid_cinemas());
    }
    $total = Helper::elapsed_time($start);
    Log::write("Tempo total procurando cinemas: {$total}");
    Sendmail::to_admin(count($new_cinemas) . " cinemas novos", $new_cinemas);
    Sendmail::to_admin(count($invalid_cinemas) . " cinemas sem cidade", $invalid_cinemas);
}
开发者ID:xxdf,项目名称:showtimes,代码行数:30,代码来源:discover-cinemas.php

示例12: preContentLoad

 public function preContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $_CONFIG, $objNewsML, $arrMatches, $page_template, $themesPages, $cl;
     // Set NewsML messages
     if ($_CONFIG['feedNewsMLStatus'] == '1') {
         if (preg_match_all('/{NEWSML_([0-9A-Z_-]+)}/', \Env::get('cx')->getPage()->getContent(), $arrMatches)) {
             /** @ignore */
             if ($cl->loadFile(\Env::get('cx')->getCodeBaseModulePath() . '/Feed/Controller/NewsML.class.php')) {
                 $objNewsML = new NewsML();
                 $objNewsML->setNews($arrMatches[1], \Env::get('cx')->getPage()->getContent());
             }
         }
         if (preg_match_all('/{NEWSML_([0-9A-Z_-]+)}/', $page_template, $arrMatches)) {
             /** @ignore */
             if ($cl->loadFile(\Env::get('cx')->getCodeBaseModulePath() . '/Feed/Controller/NewsML.class.php')) {
                 $objNewsML = new NewsML();
                 $objNewsML->setNews($arrMatches[1], $page_template);
             }
         }
         if (preg_match_all('/{NEWSML_([0-9A-Z_-]+)}/', $themesPages['index'], $arrMatches)) {
             /** @ignore */
             if ($cl->loadFile(\Env::get('cx')->getCodeBaseModulePath() . '/Feed/Controller/NewsML.class.php')) {
                 $objNewsML = new NewsML();
                 $objNewsML->setNews($arrMatches[1], $themesPages['index']);
             }
         }
     }
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:28,代码来源:ComponentController.class.php

示例13: __construct

 /**
  * Construct the MailController
  *
  * @access public
  * @param void
  * @return MailController
  */
 function __construct()
 {
     parent::__construct();
     prepare_company_website_controller($this, 'website');
     Env::useHelper('MailUtilities.class', $this->plugin_name);
     require_javascript("AddMail.js", $this->plugin_name);
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:14,代码来源:MailController.class.php

示例14: 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

示例15: preRender

 protected function preRender($lang)
 {
     if ($this->template->placeholderExists('LEVELS_FULL') || $this->template->placeholderExists('levels_full')) {
         $this->rootNode = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node')->getRoot();
     }
     $this->realPreRender($lang);
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:7,代码来源:SigmaPageTree.class.php


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