TYPO3 CMS  TYPO3_6-2
EmConfUtility.php
Go to the documentation of this file.
1 <?php
3 
23 
30  public function includeEmConf(array $extension) {
31  $_EXTKEY = $extension['key'];
32  $path = PATH_site . $extension['siteRelPath'] . 'ext_emconf.php';
33  $EM_CONF = NULL;
34  if (file_exists($path)) {
35  include $path;
36  if (is_array($EM_CONF[$_EXTKEY])) {
37  return $EM_CONF[$_EXTKEY];
38  }
39  }
40  return FALSE;
41  }
42 
52  public function constructEmConf(array $extensionData, \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension = NULL) {
53  if (is_object($extension) && empty($extensionData['EM_CONF']['constraints'])) {
54  $extensionData['EM_CONF']['constraints'] = unserialize($extension->getSerializedDependencies());
55  }
56  $emConf = $this->fixEmConf($extensionData['EM_CONF']);
57  $emConf = var_export($emConf, TRUE);
58  $code = '<?php
59 
60 /***************************************************************
61  * Extension Manager/Repository config file for ext "' . $extensionData['extKey'] . '".
62  *
63  * Auto generated ' . date('d-m-Y H:i') . '
64  *
65  * Manual updates:
66  * Only the data in the array - everything else is removed by next
67  * writing. "version" and "dependencies" must not be touched!
68  ***************************************************************/
69 
70 $EM_CONF[$_EXTKEY] = ' . $emConf . ';
71 
72 ';
73  return str_replace(' ', TAB, $code);
74  }
75 
82  public function fixEmConf(array $emConf) {
83  if (
84  !isset($emConf['constraints']) || !isset($emConf['constraints']['depends'])
85  || !isset($emConf['constraints']['conflicts']) || !isset($emConf['constraints']['suggests'])
86  ) {
87  if (!isset($emConf['constraints']) || !isset($emConf['constraints']['depends'])) {
88  $emConf['constraints']['depends'] = $this->stringToDependency($emConf['dependencies']);
89  if (strlen($emConf['PHP_version'])) {
90  $emConf['constraints']['depends']['php'] = $emConf['PHP_version'];
91  }
92  if (strlen($emConf['TYPO3_version'])) {
93  $emConf['constraints']['depends']['typo3'] = $emConf['TYPO3_version'];
94  }
95  }
96  if (!isset($emConf['constraints']) || !isset($emConf['constraints']['conflicts'])) {
97  $emConf['constraints']['conflicts'] = $this->stringToDependency($emConf['conflicts']);
98  }
99  if (!isset($emConf['constraints']) || !isset($emConf['constraints']['suggests'])) {
100  $emConf['constraints']['suggests'] = array();
101  }
102  }
103 
104  // Remove TER v1-style entries
105  unset($emConf['dependencies']);
106  unset($emConf['conflicts']);
107  unset($emConf['suggests']);
108  unset($emConf['private']);
109  unset($emConf['download_password']);
110  unset($emConf['TYPO3_version']);
111  unset($emConf['PHP_version']);
112  unset($emConf['internal']);
113  unset($emConf['module']);
114  unset($emConf['loadOrder']);
115  unset($emConf['lockType']);
116  unset($emConf['shy']);
117  unset($emConf['priority']);
118  unset($emConf['modify_tables']);
119  unset($emConf['CGLcompliance']);
120  unset($emConf['CGLcompliance_note']);
121 
122  return $emConf;
123  }
124 
136  public function stringToDependency($dependency) {
137  $constraint = array();
138  if (is_string($dependency) && strlen($dependency)) {
139  $dependency = explode(',', $dependency);
140  foreach ($dependency as $v) {
141  $constraint[$v] = '';
142  }
143  }
144  return $constraint;
145  }
146 
147 }
$EM_CONF[$_EXTKEY]
Definition: ext_emconf.php:2
constructEmConf(array $extensionData, \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension=NULL)