本文整理匯總了PHP中Contao\Environment::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP Environment::set方法的具體用法?PHP Environment::set怎麽用?PHP Environment::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Contao\Environment
的用法示例。
在下文中一共展示了Environment::set方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setupBeforeClass
/**
* {@inheritdoc}
*/
public static function setupBeforeClass()
{
Environment::reset();
Environment::set('path', '/core');
require __DIR__ . '/../../src/Resources/contao/config/default.php';
require __DIR__ . '/../../src/Resources/contao/config/agents.php';
}
示例2: layoutAction
/**
*
* @Route("/layout")
*/
public function layoutAction()
{
$this->validateRequest();
$objPage = PageModel::findOneByType('phpbb_forum');
// Set the correct current page for navigation
Environment::set('relativeRequest', $this->container->get('phpbb_bridge.connector')->getBridgeConfig('forum_pageId') . $GLOBALS['TL_CONFIG']['urlSuffix']);
$response = $this->frontendIndex->run();
if ($objPage instanceof PageModel) {
$page = new Forum();
Input::setGet('format', 'json');
$response = $page->getResponse($objPage);
}
return $response;
}
示例3: generateFiles
/**
* @param $arrFeed
* @return null
*/
protected function generateFiles($arrFeed)
{
$arrArchives = deserialize($arrFeed['wrappers']);
if (!is_array($arrArchives) || empty($arrArchives)) {
return null;
}
$strType = $arrFeed['format'] == 'atom' ? 'generateAtom' : 'generateRss';
$strLink = $arrFeed['feedBase'] ?: Environment::get('base');
$strFile = $arrFeed['feedName'];
$objFeed = new \Feed($strFile);
$objFeed->link = $strLink;
$objFeed->title = $arrFeed['title'];
$objFeed->description = $arrFeed['description'];
$objFeed->language = $arrFeed['language'];
$objFeed->published = $arrFeed['tstamp'];
if ($arrFeed['maxItems'] > 0) {
$objArticle = $this->findPublishedByPids($arrArchives, $arrFeed['maxItems'], $arrFeed['fmodule'] . '_data');
} else {
$objArticle = $this->findPublishedByPids($arrArchives, 0, $arrFeed['fmodule'] . '_data');
}
if ($objArticle !== null) {
$arrUrls = array();
$strUrl = '';
while ($objArticle->next()) {
$pid = $objArticle->pid;
$wrapperDB = $this->Database->prepare('SELECT * FROM ' . $arrFeed['fmodule'] . ' WHERE id = ?')->execute($pid)->row();
if ($wrapperDB['addDetailPage'] == '1') {
$rootPage = $wrapperDB['rootPage'];
if (!isset($arrUrls[$rootPage])) {
$objParent = PageModel::findWithDetails($rootPage);
if ($objParent === null) {
$arrUrls[$rootPage] = false;
} else {
$arrUrls[$rootPage] = $this->generateFrontendUrl($objParent->row(), Config::get('useAutoItem') && !Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language);
}
}
$strUrl = $arrUrls[$rootPage];
}
$authorName = '';
if ($objArticle->author) {
$authorDB = $this->Database->prepare('SELECT * FROM tl_user WHERE id = ?')->execute($objArticle->author)->row();
$authorName = $authorDB['name'];
}
$objItem = new \FeedItem();
$objItem->title = $objArticle->title;
$objItem->link = HelperModel::getLink($objArticle, $strUrl, $strLink);
$objItem->published = $objArticle->date ? $objArticle->date : $arrFeed['tstamp'];
$objItem->author = $authorName;
// Prepare the description
if ($arrFeed['source'] == 'source_text') {
$strDescription = '';
$objElement = ContentModelExtend::findPublishedByPidAndTable($objArticle->id, $arrFeed['fmodule'] . '_data', array('fview' => 'detail'));
if ($objElement !== null) {
// Overwrite the request (see #7756)
$strRequest = Environment::get('request');
Environment::set('request', $objItem->link);
while ($objElement->next()) {
$strDescription .= $this->getContentElement($objElement->current());
}
Environment::set('request', $strRequest);
}
} else {
$strDescription = '';
$objElement = ContentModelExtend::findPublishedByPidAndTable($objArticle->id, $arrFeed['fmodule'] . '_data', array('fview' => 'list'));
if ($objElement !== null) {
// Overwrite the request (see #7756)
$strRequest = Environment::get('request');
Environment::set('request', $objItem->link);
while ($objElement->next()) {
$strDescription .= $this->getContentElement($objElement->current());
}
Environment::set('request', $strRequest);
}
if (!$strDescription) {
$strDescription = $objArticle->description;
}
}
$strDescription = $this->replaceInsertTags($strDescription, false);
$objItem->description = $this->convertRelativeUrls($strDescription, $strLink);
// Add the article image as enclosure
if ($objArticle->addImage) {
$objFile = \FilesModel::findByUuid($objArticle->singleSRC);
if ($objFile !== null) {
$objItem->addEnclosure($objFile->path);
}
}
// Enclosures
if ($objArticle->addEnclosure) {
$arrEnclosure = deserialize($objArticle->enclosure, true);
if (is_array($arrEnclosure)) {
$objFile = \FilesModel::findMultipleByUuids($arrEnclosure);
if ($objFile !== null) {
while ($objFile->next()) {
$objItem->addEnclosure($objFile->path);
}
}
//.........這裏部分代碼省略.........