[TYPO3-english] Flexform Select itemsProcFunc with Extbase incl. ConfigurationManager
David Gurk
dgurk at medienwerft.de
Fri Oct 12 12:48:53 CEST 2012
Hi,
the basis for this question is an Extbase Extension to create teasers. At the pages is it possible to select from the available teaser with the plugin, which teaser should be displayed on the page. This is realized with a multiselect in Flexforms (itemsProcFunc).
### Flexform ###
<code>
<settings.teaser>
<TCEforms>
<label>Teaser</label>
<config>
<type>select</type>
<itemsProcFunc>Tx_Example_Controller_AddItemsToFlexform->mainAction</itemsProcFunc>
<size>20</size>
<maxitems>15</maxitems>
</config>
</TCEforms>
</settings.teaser>
</code>
### Class ###
This class in itemsProcFunc is an Extbase class. The following code works fine but is really simple:
<code>
class Tx_Example_Controller_AddItemsToFlexform extends Tx_Extbase_MVC_Controller_ActionController {
function mainAction($params, $conf) {
$sql = "SELECT uid, name FROM tx_example_domain_model_teaser WHERE sys_language_uid='0' AND deleted='0'";
$result = mysql_query($sql) OR die(mysql_error());
if (mysql_num_rows($result)) {
while ($row = mysql_fetch_assoc($result)) {
$params['items'][] = array($row['name'], $row['uid']);
}
}
asort($params['items']);
return $params;
}
}
</code>
But my challenge is a bit difficult. On the website exists two areas, each with an own storage folder in the website tree. I defined for each area the constant for the storagePid (plugin.tx_example.persistence.storagePid). I wish, that only the teasers for each area are displayed in the Flexform multiselect.
But their I have a problem to inject the ConfigurationManager to get the storagePid:
<code>
class Tx_Example_Controller_AddItemsToFlexform extends Tx_Extbase_MVC_Controller_ActionController {
/**
* @var Tx_Extbase_Configuration_ConfigurationManagerInterface
*/
protected $configurationManager;
/**
* @param Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager
* @return void
*/
public function injectConfigurationManager(Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager) {
$this->configurationManager = $configurationManager;
}
function mainAction($params, $conf) {
$frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$storagePid = $frameworkConfiguration['persistence']['storagePid'];
t3lib_div::debug($storagePid);
}
}
</code>
All I get is an error:
"Fatal error: Call to a member function getConfiguration() on a non-object..."
Is there anyone who knows if this what I expect can work?
Regards
David
More information about the TYPO3-english
mailing list