set() public static méthode

Set an environment variable
public static set ( string $strKey, mixed $varValue )
$strKey string The variable name
$varValue mixed The variable value
 /**
  * {@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';
 }
 /**
  *
  * @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;
 }
Exemple #3
0
 /**
  * @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);
                         }
                     }
                 }
             }
             $objFeed->addItem($objItem);
         }
     }
     File::putContent('share/' . $strFile . '.xml', $this->replaceInsertTags($objFeed->{$strType}(), false));
 }