本文整理汇总了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';
}
}
示例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;
}
}
示例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();
}
示例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;
}
示例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);
}
}
示例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;
}
示例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));
}
示例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]);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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 '';
}
示例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;
}
示例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;
}
示例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;
}