當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MauticFactory::getEnvironment方法代碼示例

本文整理匯總了PHP中Mautic\CoreBundle\Factory\MauticFactory::getEnvironment方法的典型用法代碼示例。如果您正苦於以下問題:PHP MauticFactory::getEnvironment方法的具體用法?PHP MauticFactory::getEnvironment怎麽用?PHP MauticFactory::getEnvironment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mautic\CoreBundle\Factory\MauticFactory的用法示例。


在下文中一共展示了MauticFactory::getEnvironment方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->devMode = $factory->getEnvironment() == 'dev';
     $this->imageDir = $factory->getSystemPath('images');
     $this->assetHelper = $factory->getHelper('template.assets');
     $this->avatarHelper = $factory->getHelper('template.avatar');
 }
開發者ID:Jandersolutions,項目名稱:mautic,代碼行數:10,代碼來源:GravatarHelper.php

示例2: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->factory = $factory;
     $this->cacheDir = $factory->getSystemPath('cache', true);
     $this->env = $factory->getEnvironment();
     $this->configFile = $this->factory->getLocalConfigFile(false);
     $this->containerFile = $this->factory->getKernel()->getContainerFile();
 }
開發者ID:HomeRefill,項目名稱:mautic,代碼行數:11,代碼來源:CacheHelper.php

示例3: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->devMode = $factory->getEnvironment() == 'dev';
     $this->imageDir = $factory->getSystemPath('images');
     $this->assetHelper = $factory->getHelper('template.assets');
     $this->avatarHelper = $factory->getHelper('template.avatar');
     $this->request = $factory->getRequest();
     $this->devHosts = (array) $factory->getParameter('dev_hosts');
 }
開發者ID:dongilbert,項目名稱:mautic,代碼行數:12,代碼來源:GravatarHelper.php

示例4: getAssets

 /**
  * Generates and returns assets
  *
  * @param bool $forceRegeneration
  *
  * @return array
  */
 public function getAssets($forceRegeneration = false)
 {
     static $assets = array();
     if (empty($assets)) {
         $loadAll = true;
         $env = $forceRegeneration ? 'prod' : $this->factory->getEnvironment();
         $rootPath = $this->factory->getSystemPath('assets_root');
         $assetsPath = $this->factory->getSystemPath('assets');
         $assetsFullPath = "{$rootPath}/{$assetsPath}";
         if ($env == 'prod') {
             $loadAll = false;
             //by default, loading should not be required
             //check for libraries and app files and generate them if they don't exist if in prod environment
             $prodFiles = array('css/libraries.css', 'css/app.css', 'js/libraries.js', 'js/app.js');
             foreach ($prodFiles as $file) {
                 if (!file_exists("{$assetsFullPath}/{$file}")) {
                     $loadAll = true;
                     //it's missing so compile it
                     break;
                 }
             }
         }
         if ($loadAll || $forceRegeneration) {
             if ($env == 'prod') {
                 ini_set('max_execution_time', 300);
                 $inProgressFile = "{$assetsFullPath}/generation_in_progress.txt";
                 if (!$forceRegeneration) {
                     while (file_exists($inProgressFile)) {
                         //dummy loop to prevent conflicts if one process is actively regenerating assets
                     }
                 }
                 file_put_contents($inProgressFile, date('r'));
             }
             $modifiedLast = array();
             //get a list of all core asset files
             $bundles = $this->factory->getParameter('bundles');
             $fileTypes = array('css', 'js');
             foreach ($bundles as $bundle) {
                 foreach ($fileTypes as $ft) {
                     if (!isset($modifiedLast[$ft])) {
                         $modifiedLast[$ft] = array();
                     }
                     $dir = "{$bundle['directory']}/Assets/{$ft}";
                     if (file_exists($dir)) {
                         $modifiedLast[$ft] = array_merge($modifiedLast[$ft], $this->findAssets($dir, $ft, $env, $assets));
                     }
                 }
             }
             $modifiedLast = array_merge($modifiedLast, $this->findOverrides($env, $assets));
             //combine the files into their corresponding name and put in the root media folder
             if ($env == "prod") {
                 $checkPaths = array($assetsFullPath, "{$assetsFullPath}/css", "{$assetsFullPath}/js");
                 array_walk($checkPaths, function ($path) {
                     if (!file_exists($path)) {
                         mkdir($path);
                     }
                 });
                 $useMinify = class_exists('\\Minify');
                 foreach ($assets as $type => $groups) {
                     foreach ($groups as $group => $files) {
                         $assetFile = "{$assetsFullPath}/{$type}/{$group}.{$type}";
                         //only refresh if a change has occurred
                         $modified = $forceRegeneration || !file_exists($assetFile) ? true : filemtime($assetFile) < $modifiedLast[$type][$group];
                         if ($modified) {
                             if (file_exists($assetFile)) {
                                 //delete it
                                 unlink($assetFile);
                             }
                             if ($type == 'css') {
                                 $out = fopen($assetFile, 'w');
                                 foreach ($files as $relPath => $details) {
                                     $cssRel = '../../' . dirname($relPath) . '/';
                                     if ($useMinify) {
                                         $content = \Minify::combine(array($details['fullPath']), array('rewriteCssUris' => false, 'minifierOptions' => array('text/css' => array('currentDir' => '', 'prependRelativePath' => $cssRel))));
                                     } else {
                                         $content = file_get_contents($details['fullPath']);
                                         $search = '#url\\((?!\\s*([\'"]?(((?:https?:)?//)|(?:data\\:?:))))\\s*([\'"])?#';
                                         $replace = "url(\$4{$cssRel}";
                                         $content = preg_replace($search, $replace, $content);
                                     }
                                     fwrite($out, $content);
                                 }
                                 fclose($out);
                             } else {
                                 array_walk($files, function (&$file) {
                                     $file = $file['fullPath'];
                                 });
                                 file_put_contents($assetFile, \Minify::combine($files));
                             }
                         }
                     }
                 }
                 unlink($inProgressFile);
//.........這裏部分代碼省略.........
開發者ID:HomeRefill,項目名稱:mautic,代碼行數:101,代碼來源:AssetGenerationHelper.php

示例5: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     self::$devMode = $factory->getEnvironment() == 'dev';
 }
開發者ID:woakes070048,項目名稱:mautic,代碼行數:7,代碼來源:GravatarHelper.php

示例6: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->factory = $factory;
     $this->cacheDir = $factory->getSystemPath('cache', true);
     $this->env = $factory->getEnvironment();
 }
開發者ID:Jandersolutions,項目名稱:mautic,代碼行數:9,代碼來源:CacheHelper.php


注:本文中的Mautic\CoreBundle\Factory\MauticFactory::getEnvironment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。