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


PHP System::getContainer方法代码示例

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


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

示例1: load

 /**
  * Load a set of DCA files
  *
  * @param boolean $blnNoCache If true, the cache will be bypassed
  */
 public function load($blnNoCache = false)
 {
     // Return if the data has been loaded already
     if (isset($GLOBALS['loadDataContainer'][$this->strTable]) && !$blnNoCache) {
         return;
     }
     $GLOBALS['loadDataContainer'][$this->strTable] = true;
     // see #6145
     $strCacheDir = \System::getContainer()->getParameter('kernel.cache_dir');
     // Try to load from cache
     if (file_exists($strCacheDir . '/contao/dca/' . $this->strTable . '.php')) {
         include $strCacheDir . '/contao/dca/' . $this->strTable . '.php';
     } else {
         try {
             $files = \System::getContainer()->get('contao.resource_locator')->locate('dca/' . $this->strTable . '.php', null, false);
         } catch (\InvalidArgumentException $e) {
             $files = array();
         }
         foreach ($files as $file) {
             include $file;
         }
     }
     // HOOK: allow to load custom settings
     if (isset($GLOBALS['TL_HOOKS']['loadDataContainer']) && is_array($GLOBALS['TL_HOOKS']['loadDataContainer'])) {
         foreach ($GLOBALS['TL_HOOKS']['loadDataContainer'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback[0]}->{$callback[1]}($this->strTable);
         }
     }
     // Local configuration file
     if (file_exists(TL_ROOT . '/system/config/dcaconfig.php')) {
         include TL_ROOT . '/system/config/dcaconfig.php';
     }
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:39,代码来源:DcaLoader.php

示例2: checkPermission

 /**
  * Check permissions to edit table tl_content
  */
 public function checkPermission()
 {
     /** @var Symfony\Component\HttpFoundation\Session\SessionInterface $objSession */
     $objSession = System::getContainer()->get('session');
     // Prevent deleting referenced elements (see #4898)
     if (Input::get('act') == 'deleteAll') {
         $objCes = $this->Database->prepare("SELECT cteAlias FROM tl_content WHERE (ptable='tl_article' OR ptable='') AND type='alias'")->execute();
         $session = $objSession->all();
         $session['CURRENT']['IDS'] = array_diff($session['CURRENT']['IDS'], $objCes->fetchEach('cteAlias'));
         $objSession->replace($session);
     }
     if ($this->User->isAdmin) {
         return;
     }
     // Get the pagemounts
     $pagemounts = array();
     foreach ($this->User->pagemounts as $root) {
         $pagemounts[] = $root;
         $pagemounts = array_merge($pagemounts, $this->Database->getChildRecords($root, 'tl_page'));
     }
     $pagemounts = array_unique($pagemounts);
     // Check the current action
     switch (Input::get('act')) {
         case 'paste':
             // Allow
             break;
         case '':
             // empty
         // empty
         case 'create':
         case 'select':
             // Check access to the article
             $this->checkAccessToElement(CURRENT_ID, $pagemounts, true);
             break;
         case 'editAll':
         case 'deleteAll':
         case 'overrideAll':
         case 'cutAll':
         case 'copyAll':
             // Check access to the parent element if a content element is moved
             if (Input::get('act') == 'cutAll' || Input::get('act') == 'copyAll') {
                 $this->checkAccessToElement(Input::get('pid'), $pagemounts, Input::get('mode') == 2);
             }
             $objCes = $this->Database->prepare("SELECT id FROM tl_content WHERE (ptable='tl_article' OR ptable='') AND pid=?")->execute(CURRENT_ID);
             $session = $objSession->all();
             $session['CURRENT']['IDS'] = array_intersect($session['CURRENT']['IDS'], $objCes->fetchEach('id'));
             $objSession->replace($session);
             break;
         case 'cut':
         case 'copy':
             // Check access to the parent element if a content element is moved
             $this->checkAccessToElement(Input::get('pid'), $pagemounts, Input::get('mode') == 2);
             // NO BREAK STATEMENT HERE
         // NO BREAK STATEMENT HERE
         default:
             // Check access to the content element
             $this->checkAccessToElement(Input::get('id'), $pagemounts);
             break;
     }
 }
开发者ID:bytehead,项目名称:core-bundle,代码行数:63,代码来源:tl_content.php

示例3: run

 /**
  * Generate the module
  *
  * @return string
  */
 public function run()
 {
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_maintenance_mode');
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->headline = $GLOBALS['TL_LANG']['tl_maintenance']['maintenanceMode'];
     $objTemplate->isActive = $this->isActive();
     try {
         $driver = \System::getContainer()->get('lexik_maintenance.driver.factory')->getDriver();
         $isLocked = $driver->isExists();
     } catch (\Exception $e) {
         return '';
     }
     // Toggle the maintenance mode
     if (\Input::post('FORM_SUBMIT') == 'tl_maintenance_mode') {
         if ($isLocked) {
             $driver->unlock();
         } else {
             $driver->lock();
         }
         $this->reload();
     }
     if ($isLocked) {
         $objTemplate->class = 'tl_confirm';
         $objTemplate->explain = $GLOBALS['TL_LANG']['MSC']['maintenanceEnabled'];
         $objTemplate->submit = $GLOBALS['TL_LANG']['tl_maintenance']['maintenanceDisable'];
     } else {
         $objTemplate->class = 'tl_info';
         $objTemplate->explain = $GLOBALS['TL_LANG']['MSC']['maintenanceDisabled'];
         $objTemplate->submit = $GLOBALS['TL_LANG']['tl_maintenance']['maintenanceEnable'];
     }
     return $objTemplate->parse();
 }
开发者ID:contao,项目名称:core-bundle,代码行数:38,代码来源:Maintenance.php

示例4: getExcludedFields

 /**
  * Return all excluded fields as HTML drop down menu
  *
  * @return array
  */
 public function getExcludedFields()
 {
     $processed = array();
     /** @var SplFileInfo[] $files */
     $files = System::getContainer()->get('contao.resource_finder')->findIn('dca')->depth(0)->files()->name('*.php');
     foreach ($files as $file) {
         if (in_array($file->getBasename(), $processed)) {
             continue;
         }
         $processed[] = $file->getBasename();
         $strTable = $file->getBasename('.php');
         System::loadLanguageFile($strTable);
         $this->loadDataContainer($strTable);
     }
     $arrReturn = array();
     // Get all excluded fields
     foreach ($GLOBALS['TL_DCA'] as $k => $v) {
         if (is_array($v['fields'])) {
             foreach ($v['fields'] as $kk => $vv) {
                 if ($vv['exclude'] || $vv['orig_exclude']) {
                     $arrReturn[$k][StringUtil::specialchars($k . '::' . $kk)] = isset($vv['label'][0]) ? $vv['label'][0] . ' <span style="color:#999;padding-left:3px">[' . $kk . ']</span>' : $kk;
                 }
             }
         }
     }
     ksort($arrReturn);
     return $arrReturn;
 }
开发者ID:bytehead,项目名称:core-bundle,代码行数:33,代码来源:tl_user_group.php

示例5: convertTranslationField

 /**
  * @param $table
  * @param $field
  */
 public static function convertTranslationField($table, $field)
 {
     $backup = $field . '_backup';
     $objDatabase = Database::getInstance();
     /* @var $objLanguages Languages */
     $objLanguages = \System::getContainer()->get('craffft.translation_fields.service.languages');
     // Backup the original column and then change the column type
     if (!$objDatabase->fieldExists($backup, $table, true)) {
         $objDatabase->query("ALTER TABLE `{$table}` ADD `{$backup}` text NULL");
         $objDatabase->query("UPDATE `{$table}` SET `{$backup}`=`{$field}`");
         $objDatabase->query("ALTER TABLE `{$table}` CHANGE `{$field}` `{$field}` int(10) unsigned NOT NULL default '0'");
         $objDatabase->query("UPDATE `{$table}` SET `{$field}`='0'");
     }
     $objRow = $objDatabase->query("SELECT id, {$backup} FROM {$table} WHERE {$backup}!=''");
     while ($objRow->next()) {
         if (is_numeric($objRow->{$backup})) {
             $intFid = $objRow->{$backup};
         } else {
             if (strlen($objRow->{$backup}) > 0) {
                 $intFid = TranslationFieldsModel::saveValuesAndReturnFid($objLanguages->getLanguagesWithValue($objRow->{$backup}));
             } else {
                 $intFid = 0;
             }
         }
         $objDatabase->prepare("UPDATE {$table} SET {$field}=? WHERE id=?")->execute($intFid, $objRow->id);
     }
 }
开发者ID:Craffft,项目名称:translation-fields-bundle,代码行数:31,代码来源:Updater.php

示例6: compile

 /**
  * Generate module
  */
 protected function compile()
 {
     $carService = \System::getContainer()->get('xuad_car.service.carservice');
     $carList = $carService->findAll();
     $twigRenderer = \System::getContainer()->get('templating');
     $rendered = $twigRenderer->render('@XuadCar/mod_car_list.twig', ['carList' => $carList]);
     $this->Template->renderedTwig = $rendered;
 }
开发者ID:thunder1902,项目名称:examples,代码行数:11,代码来源:ModuleCarList.php

示例7: updateConfig

 protected function updateConfig($activeRecord)
 {
     Message::addInfo("Updating Config");
     $row = $activeRecord->row();
     $row['skipInternalHook'] = true;
     $url = Controller::generateFrontendUrl($row);
     System::getContainer()->get('phpbb_bridge.connector')->updateConfig(array('contao.forum_pageId' => $activeRecord->id, 'contao.forum_pageUrl' => $url));
 }
开发者ID:BogusCurry,项目名称:contao-phpbb-bridge-bundle,代码行数:8,代码来源:tl_page.php

示例8: checkPermission

 /**
  * Check permissions to edit table tl_faq
  */
 public function checkPermission()
 {
     $bundles = System::getContainer()->getParameter('kernel.bundles');
     // HOOK: comments extension required
     if (!isset($bundles['ContaoCommentsBundle'])) {
         $key = array_search('allowComments', $GLOBALS['TL_DCA']['tl_faq']['list']['sorting']['headerFields']);
         unset($GLOBALS['TL_DCA']['tl_faq']['list']['sorting']['headerFields'][$key]);
     }
 }
开发者ID:contao,项目名称:faq-bundle,代码行数:12,代码来源:tl_faq.php

示例9: increaseLoginCount

 /**
  * Increases the login count.
  */
 public function increaseLoginCount()
 {
     $cache = \System::getContainer()->get('contao.cache');
     if ($cache->contains('login-count')) {
         $count = intval($cache->fetch('login-count')) + 1;
     } else {
         $count = 1;
     }
     $cache->save('login-count', $count);
 }
开发者ID:contao,项目名称:installation-bundle,代码行数:13,代码来源:InstallTool.php

示例10: getActive

 /**
  * Return the active modules as array
  *
  * @return array An array of active modules
  */
 public static function getActive()
 {
     $bundles = array_keys(\System::getContainer()->getParameter('kernel.bundles'));
     foreach (static::$legacy as $bundleName => $module) {
         if (in_array($bundleName, $bundles)) {
             $bundles[] = $module;
         }
     }
     return $bundles;
 }
开发者ID:contao,项目名称:core-bundle,代码行数:15,代码来源:ModuleLoader.php

示例11: getActive

 /**
  * Return the active modules as array
  *
  * @return array An array of active modules
  */
 public static function getActive()
 {
     @trigger_error('Using ModuleLoader::getActive() has been deprecated and will no longer work in Contao 5.0. Use the container parameter "kernel.bundles" instead.', E_USER_DEPRECATED);
     $bundles = array_keys(\System::getContainer()->getParameter('kernel.bundles'));
     foreach (static::$legacy as $bundleName => $module) {
         if (in_array($bundleName, $bundles)) {
             $bundles[] = $module;
         }
     }
     return $bundles;
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:16,代码来源:ModuleLoader.php

示例12: maintenanceCheck

 /**
  * Check for maintenance mode
  *
  * @return string
  */
 public function maintenanceCheck()
 {
     try {
         if (\System::getContainer()->get('lexik_maintenance.driver.factory')->getDriver()->isExists()) {
             return '<p class="tl_error"><a href="contao/main.php?do=maintenance">' . $GLOBALS['TL_LANG']['MSC']['maintenanceEnabled'] . '</a></p>';
         }
     } catch (\Exception $e) {
         // ignore
     }
     return '';
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:16,代码来源:Messages.php

示例13: validator

 /**
  * Trim values
  *
  * @param mixed $varInput
  *
  * @return mixed
  */
 protected function validator($varInput)
 {
     $this->import('BackendUser', 'User');
     $varInput[0] = parent::validator($varInput[0]);
     $varInput[1] = parent::validator($varInput[1]);
     $varInput[2] = preg_replace('/[^a-z0-9_]+/', '', $varInput[2]);
     $imageSizes = \System::getContainer()->get('contao.image.image_sizes');
     $this->arrAvailableOptions = $this->User->isAdmin ? $imageSizes->getAllOptions() : $imageSizes->getOptionsForUser($this->User);
     if (!$this->isValidOption($varInput[2])) {
         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalid'], $varInput[2]));
     }
     return $varInput;
 }
开发者ID:contao,项目名称:core-bundle,代码行数:20,代码来源:ImageSize.php

示例14: generate

 /**
  * @param $strContent
  * @param int $intHeight
  * @return string
  * @throws \Exception
  */
 public static function generate($strContent, $intHeight = 35)
 {
     // Handle height
     if (!is_numeric($intHeight)) {
         $intHeight = 35;
     }
     $strPath = 'barcode/cache';
     $strAbsolutePath = \System::getContainer()->get('kernel')->getRootDir() . '/../web/' . $strPath . '/';
     $objBarcode = new Base1DBarcode();
     $objBarcode->savePath = $strAbsolutePath;
     $strAbsoluteFilePath = $objBarcode->getBarcodePNGPath($strContent, 'C128', 1.5, $intHeight);
     $strFile = substr($strAbsoluteFilePath, strlen($strAbsolutePath));
     return $strPath . '/' . $strFile;
 }
开发者ID:Craffft,项目名称:barqrcodewizard-bundle,代码行数:20,代码来源:Barcode.php

示例15: generate

 /**
  * @param $strContent
  * @param string $strType
  * @param int $intSize
  * @return string
  * @throws \Exception
  */
 public static function generate($strContent, $strType = self::QRCODE_H, $intSize = 3)
 {
     // Handle size
     if (!is_numeric($intSize) || $intSize < 1 || $intSize > 10) {
         $intSize = 3;
     }
     $strPath = 'qrcode/cache';
     $strAbsolutePath = \System::getContainer()->get('kernel')->getRootDir() . '/../web/' . $strPath . '/';
     $objQrcode = new Base2DBarcode();
     $objQrcode->savePath = $strAbsolutePath;
     $strAbsoluteFilePath = $objQrcode->getBarcodePNGPath($strContent, $strType, $intSize, $intSize);
     $strFile = substr($strAbsoluteFilePath, strlen($strAbsolutePath));
     return $strPath . '/' . $strFile;
 }
开发者ID:Craffft,项目名称:barqrcodewizard-bundle,代码行数:21,代码来源:QRcode.php


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