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


PHP MauticFactory::getSystemPath方法代码示例

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


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

示例1: __construct

 /**
  * @param MauticFactory $factory
  * @param string        $theme
  *
  * @throws BadConfigurationException
  * @throws FileNotFoundException
  */
 public function __construct(MauticFactory $factory, $theme = 'current')
 {
     $this->factory = $factory;
     $this->theme = $theme == 'current' ? $factory->getParameter('theme') : $theme;
     if ($this->theme == null) {
         $this->theme = 'Mauve';
     }
     $this->themeDir = $factory->getSystemPath('themes') . '/' . $this->theme;
     $this->themePath = $factory->getSystemPath('themes_root') . '/' . $this->themeDir;
     //check to make sure the theme exists
     if (!file_exists($this->themePath)) {
         throw new FileNotFoundException($this->theme . ' not found!');
     }
     //get the config
     if (file_exists($this->themePath . '/config.json')) {
         $this->config = json_decode(file_get_contents($this->themePath . '/config.json'), true);
     } elseif (file_exists($this->themePath . '/config.php')) {
         $this->config = (include $this->themePath . '/config.php');
     } else {
         throw new BadConfigurationException($this->theme . ' is missing a required config file');
     }
     if (!isset($this->config['name'])) {
         throw new BadConfigurationException($this->theme . ' does not have a valid config file');
     }
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:32,代码来源:ThemeHelper.php

示例2: fetchData

 /**
  * Retrieves the update data from our home server
  *
  * @param bool $overrideCache
  *
  * @return array
  */
 public function fetchData($overrideCache = false)
 {
     $cacheFile = $this->factory->getSystemPath('cache') . '/lastUpdateCheck.txt';
     // Check if we have a cache file and try to return cached data if so
     if (!$overrideCache && is_readable($cacheFile)) {
         $update = (array) json_decode(file_get_contents($cacheFile));
         // Check if the user has changed the update channel, if so the cache is invalidated
         if ($update['stability'] == $this->factory->getParameter('update_stability')) {
             // If we're within the cache time, return the cached data
             if ($update['checkedTime'] > strtotime('-3 hours')) {
                 return $update;
             }
         }
     }
     // Before processing the update data, send up our metrics
     try {
         // Generate a unique instance ID for the site
         $instanceId = hash('sha1', $this->factory->getParameter('secret_key') . 'Mautic' . $this->factory->getParameter('db_driver'));
         $data = array('application' => 'Mautic', 'version' => $this->factory->getVersion(), 'phpVersion' => PHP_VERSION, 'dbDriver' => $this->factory->getParameter('db_driver'), 'serverOs' => php_uname('s') . ' ' . php_uname('r'), 'instanceId' => $instanceId, 'installSource' => $this->factory->getParameter('install_source', 'Mautic'));
         $this->connector->post('https://updates.mautic.org/stats/send', $data, array(), 10);
     } catch (\Exception $exception) {
         // Not so concerned about failures here, move along
     }
     // Get the update data
     try {
         $appData = array('appVersion' => $this->factory->getVersion(), 'phpVersion' => PHP_VERSION, 'stability' => $this->factory->getParameter('update_stability'));
         $data = $this->connector->post('https://updates.mautic.org/index.php?option=com_mauticdownload&task=checkUpdates', $appData, array(), 10);
         $update = json_decode($data->body);
     } catch (\Exception $exception) {
         // Log the error
         $logger = $this->factory->getLogger();
         $logger->addError('An error occurred while attempting to fetch updates: ' . $exception->getMessage());
         return array('error' => true, 'message' => 'mautic.core.updater.error.fetching.updates');
     }
     if ($data->code != 200) {
         // Log the error
         $logger = $this->factory->getLogger();
         $logger->addError(sprintf('An unexpected %1$s code was returned while attempting to fetch updates.  The message received was: %2$s', $data->code, is_string($data->body) ? $data->body : implode('; ', $data->body)));
         return array('error' => true, 'message' => 'mautic.core.updater.error.fetching.updates');
     }
     // If the user's up-to-date, go no further
     if ($update->latest_version) {
         return array('error' => false, 'message' => 'mautic.core.updater.running.latest.version');
     }
     // Last sanity check, if the $update->version is older than our current version
     if (version_compare($this->factory->getVersion(), $update->version, 'ge')) {
         return array('error' => false, 'message' => 'mautic.core.updater.running.latest.version');
     }
     // The user is able to update to the latest version, cache the data first
     $data = array('error' => false, 'message' => 'mautic.core.updater.update.available', 'version' => $update->version, 'announcement' => $update->announcement, 'package' => $update->package, 'checkedTime' => time(), 'stability' => $this->factory->getParameter('update_stability'));
     file_put_contents($cacheFile, json_encode($data));
     return $data;
 }
开发者ID:Yame-,项目名称:mautic,代码行数:60,代码来源:UpdateHelper.php

示例3: getPath

 /**
  * {@inheritdoc}
  */
 public function getPath()
 {
     $controller = str_replace('\\', '/', $this->get('controller'));
     if (!empty($this->themeOverride)) {
         try {
             $theme = $this->factory->getTheme($this->themeOverride);
             $themeDir = $theme->getThemePath();
         } catch (\Exception $e) {
         }
     } else {
         $theme = $this->factory->getTheme();
         $themeDir = $theme->getThemePath();
     }
     $fileName = $this->get('name') . '.' . $this->get('format') . '.' . $this->get('engine');
     $path = (empty($controller) ? '' : $controller . '/') . $fileName;
     if (!empty($this->parameters['bundle'])) {
         $bundleRoot = $this->factory->getSystemPath('bundles', true);
         $pluginRoot = $this->factory->getSystemPath('plugins', true);
         // @deprecated 1.1.4; to be removed in 2.0; BC support for MauticAddon
         $addonRoot = $this->factory->getSystemPath('root') . '/addons';
         // Check for a system-wide override
         $themePath = $this->factory->getSystemPath('themes', true);
         $systemTemplate = $themePath . '/system/' . $this->parameters['bundle'] . '/' . $path;
         if (file_exists($systemTemplate)) {
             $template = $systemTemplate;
         } else {
             //check for an override and load it if there is
             if (!empty($themeDir) && file_exists($themeDir . '/html/' . $this->parameters['bundle'] . '/' . $path)) {
                 // Theme override
                 $template = $themeDir . '/html/' . $this->parameters['bundle'] . '/' . $path;
             } else {
                 preg_match('/Mautic(.*?)Bundle/', $this->parameters['bundle'], $match);
                 if (!empty($match[1]) && file_exists($bundleRoot . '/' . $match[1] . 'Bundle/Views/' . $path) || file_exists($pluginRoot . '/' . $this->parameters['bundle'] . '/Views/' . $path) || file_exists($addonRoot . '/' . $this->parameters['bundle'] . '/Views/' . $path)) {
                     // Mautic core template
                     $template = '@' . $this->get('bundle') . '/Views/' . $path;
                 }
             }
         }
     } else {
         $themes = $this->factory->getInstalledThemes();
         if (isset($themes[$controller])) {
             //this is a file in a specific Mautic theme folder
             $theme = $this->factory->getTheme($controller);
             $template = $theme->getThemePath() . '/html/' . $fileName;
         }
     }
     if (empty($template)) {
         //try the parent
         return parent::getPath();
     }
     return $template;
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:55,代码来源:TemplateReference.php

示例4: fetchPackage

 /**
  * Fetches a language package from the remote server
  *
  * @param string $languageCode
  *
  * @return array
  */
 public function fetchPackage($languageCode)
 {
     // Check if we have a cache file, generate it if not
     if (!is_readable($this->cacheFile)) {
         $this->fetchLanguages();
     }
     $cacheData = json_decode(file_get_contents($this->cacheFile), true);
     // Make sure the language actually exists
     if (!isset($cacheData['languages'][$languageCode])) {
         return array('error' => true, 'message' => 'mautic.core.language.helper.invalid.language');
     }
     // GET the update data
     try {
         $data = $this->connector->get('https://updates.mautic.org/index.php?option=com_mauticdownload&task=downloadLanguagePackage&langCode=' . $languageCode);
     } catch (\Exception $exception) {
         $logger = $this->factory->getLogger();
         $logger->addError('An error occurred while attempting to fetch the package: ' . $exception->getMessage());
         return array('error' => true, 'message' => 'mautic.core.language.helper.error.fetching.package');
     }
     if ($data->code != 200) {
         return array('error' => true, 'message' => 'mautic.core.language.helper.error.fetching.package');
     }
     // Set the filesystem target
     $target = $this->factory->getSystemPath('cache') . '/' . $languageCode . '.zip';
     // Write the response to the filesystem
     file_put_contents($target, $data->body);
     // Return an array for the sake of consistency
     return array('error' => false);
 }
开发者ID:Chris8080,项目名称:mautic,代码行数:36,代码来源:LanguageHelper.php

示例5: __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

示例6: findOverrides

 /**
  * Find asset overrides in the template
  *
  * @param $env
  * @param $assets
  *
  * @return array
  */
 protected function findOverrides($env, &$assets)
 {
     $rootPath = $this->factory->getSystemPath('assets_root');
     $currentTheme = $this->factory->getSystemPath('current_theme');
     $modifiedLast = array();
     $types = array('css', 'js');
     $overrideFiles = array("libraries" => "libraries_custom", "app" => "app_custom");
     foreach ($types as $ext) {
         foreach ($overrideFiles as $group => $of) {
             if (file_exists("{$rootPath}/{$currentTheme}/{$ext}/{$of}.{$ext}")) {
                 $fullPath = "{$rootPath}/{$currentTheme}/{$ext}/{$of}.{$ext}";
                 $relPath = "{$currentTheme}/{$ext}/{$of}.{$ext}";
                 $details = array('fullPath' => $fullPath, 'relPath' => $relPath);
                 if ($env == 'prod') {
                     $lastModified = filemtime($fullPath);
                     if (!isset($modifiedLast[$ext][$group]) || $lastModified > $modifiedLast[$ext][$group]) {
                         $modifiedLast[$ext][$group] = $lastModified;
                     }
                     $assets[$ext][$group][$relPath] = $details;
                 } else {
                     $assets[$ext][$relPath] = $details;
                 }
             }
         }
     }
     return $modifiedLast;
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:35,代码来源:AssetGenerationHelper.php

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

示例8: load

 /**
  * {@inheritdoc}
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $bundles = $this->factory->getMauticBundles(true);
     $catalogue = new MessageCatalogue($locale);
     //Bundle translations
     foreach ($bundles as $name => $bundle) {
         //load translations
         $translations = $bundle['directory'] . '/Translations/' . $locale;
         if (file_exists($translations)) {
             $iniFiles = new Finder();
             $iniFiles->files()->in($translations)->name('*.ini');
             foreach ($iniFiles as $file) {
                 $this->loadTranslations($catalogue, $locale, $file);
             }
         }
     }
     //Theme translations
     $themeDir = $this->factory->getSystemPath('current_theme', true);
     if (file_exists($themeTranslation = $themeDir . '/translations/' . $locale)) {
         $iniFiles = new Finder();
         $iniFiles->files()->in($themeTranslation)->name('*.ini');
         foreach ($iniFiles as $file) {
             $this->loadTranslations($catalogue, $locale, $file);
         }
     }
     //3rd Party translations
     $translationsDir = $this->factory->getSystemPath('translations', true) . '/' . $locale;
     if (file_exists($translationsDir)) {
         $iniFiles = new Finder();
         $iniFiles->files()->in($translationsDir)->name('*.ini');
         foreach ($iniFiles as $file) {
             $this->loadTranslations($catalogue, $locale, $file);
         }
     }
     //Overrides
     $overridesDir = $this->factory->getSystemPath('translations', true) . '/overrides/' . $locale;
     if (file_exists($overridesDir)) {
         $iniFiles = new Finder();
         $iniFiles->files()->in($overridesDir)->name('*.ini');
         foreach ($iniFiles as $file) {
             $this->loadTranslations($catalogue, $locale, $file);
         }
     }
     return $catalogue;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:48,代码来源:TranslationLoader.php

示例9: __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

示例10: getParameters

 /**
  * Helper method can load $parameters array from a config file.
  *
  * @param string $path (relative from the root dir)
  *
  * @return array
  */
 public function getParameters($path = null)
 {
     $paramsFile = $this->factory->getSystemPath('app') . $path;
     if (file_exists($paramsFile)) {
         // Import the bundle configuration, $parameters is defined in this file
         include $paramsFile;
     }
     if (!isset($parameters)) {
         $parameters = array();
     }
     return $parameters;
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:19,代码来源:ConfigBuilderEvent.php

示例11: getIcon

 /**
  * Get icon for Integration
  *
  * @return string
  */
 public function getIcon()
 {
     $systemPath = $this->factory->getSystemPath('root');
     $bundlePath = $this->factory->getSystemPath('bundles');
     $pluginPath = $this->factory->getSystemPath('plugins');
     $genericIcon = $bundlePath . '/PluginBundle/Assets/img/generic.png';
     $name = $this->getName();
     $bundle = $this->settings->getPlugin()->getBundle();
     $icon = $pluginPath . '/' . $bundle . '/Assets/img/' . strtolower($name) . '.png';
     if (file_exists($systemPath . '/' . $icon)) {
         return $icon;
     }
     return $genericIcon;
 }
开发者ID:Yame-,项目名称:mautic,代码行数:19,代码来源:AbstractIntegration.php

示例12: getIconPath

 /**
  * Get the path to the integration's icon relative to the site root
  *
  * @param $integration
  *
  * @return string
  */
 public function getIconPath($integration)
 {
     $systemPath = $this->factory->getSystemPath('root');
     $genericIcon = 'app/bundles/AddonBundle/Assets/img/generic.png';
     $name = $integration->getIntegrationSettings()->getName();
     // For non-core bundles, we need to extract out the bundle's name to figure out where in the filesystem to look for the icon
     $className = get_class($integration);
     $exploded = explode('\\', $className);
     $icon = 'addons/' . $exploded[1] . '/Assets/img/' . strtolower($name) . '.png';
     if (file_exists($systemPath . '/' . $icon)) {
         return $icon;
     }
     return $genericIcon;
 }
开发者ID:Jornve,项目名称:mautic,代码行数:21,代码来源:IntegrationHelper.php

示例13: getCountryFlag

 /**
  * @param           $country
  * @param bool|true $urlOnly
  * @param string    $class
  *
  * @return string
  */
 public function getCountryFlag($country, $urlOnly = true, $class = '')
 {
     $flagPath = $this->factory->getSystemPath('assets', true) . '/images/flags/';
     $relpath = $this->factory->getSystemPath('assets') . '/images/flags/';
     $country = ucwords(str_replace(' ', '-', $country));
     $flagImg = '';
     if (file_exists($flagPath . $country . '.png')) {
         if (file_exists($flagPath . $country . '.png')) {
             $flagImg = $this->getUrl($relpath . $country . '.png');
         }
     }
     if ($urlOnly) {
         return $flagImg;
     } else {
         return '<img src="' . $flagImg . '" class="' . $class . '" />';
     }
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:24,代码来源:AssetsHelper.php

示例14: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->factory = $factory;
     $this->mailboxes = $this->factory->getParameter('monitored_email');
     if (isset($this->mailboxes['general'])) {
         $this->settings = $this->mailboxes['general'];
     } else {
         $this->settings = array('host' => '', 'port' => '', 'password' => '', 'user' => '', 'encryption' => '');
     }
     // Check that cache attachments directory exists
     $cacheDir = $factory->getSystemPath('cache');
     $this->attachmentsDir = $cacheDir . '/attachments';
     if (!file_exists($this->attachmentsDir)) {
         mkdir($this->attachmentsDir);
     }
     if ($this->settings['host'] == 'imap.gmail.com') {
         $this->isGmail = true;
     }
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:22,代码来源:Mailbox.php

示例15: getIconPath

 /**
  * Get the path to the integration's icon relative to the site root
  *
  * @param $integration
  *
  * @return string
  */
 public function getIconPath($integration)
 {
     $systemPath = $this->factory->getSystemPath('root');
     $bundlePath = $this->factory->getSystemPath('bundles');
     $pluginPath = $this->factory->getSystemPath('plugins');
     $genericIcon = $bundlePath . '/PluginBundle/Assets/img/generic.png';
     if (is_array($integration)) {
         // A bundle so check for an icon
         $icon = $pluginPath . '/' . $integration['bundle'] . '/Assets/img/icon.png';
     } elseif ($integration instanceof Plugin) {
         // A bundle so check for an icon
         $icon = $pluginPath . '/' . $integration->getBundle() . '/Assets/img/icon.png';
     } elseif ($integration instanceof AbstractIntegration) {
         return $integration->getIcon();
     }
     if (file_exists($systemPath . '/' . $icon)) {
         return $icon;
     }
     return $genericIcon;
 }
开发者ID:Yame-,项目名称:mautic,代码行数:27,代码来源:IntegrationHelper.php


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