Commit 1d5eaf03 authored by speedprogs_de's avatar speedprogs_de

added several methods to object builder

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@51610 735d13b6-9817-0410-8766-e36946ffe9aa
parent bad4016a
......@@ -78,39 +78,63 @@
if (empty($className) || empty($identifier) || empty($attributes)) {
throw new Exception('No valid params given to create an object');
}
if (!empty($this->objects[$className][$identifier])) {
if (!empty($this->objects[$identifier])) {
return;
}
$object = reset($this->dataMapper->map($className, array($attributes)));
$this->objects[$className][$identifier] = $object;
$this->objects[$identifier] = clone($object);
$this->persistenceSession->unregisterReconstitutedObject($object);
unset($object);
}
/**
* Check if an object exists in storage
*
* @param string $identifier String to uniquely identify an object
* @return boolean TRUE if exists
*/
public function has($identifier) {
if (empty($identifier)) {
throw new Exception('No valid identifier given to check for an object');
}
return (!empty($this->objects[$identifier]));
}
/**
* Return a stored object
*
* @param string $className Name of the class
* @param string $identifier String to uniquely identify an object
* @return Tx_Extbase_DomainObject_DomainObjectInterface Stored object
*/
public function get($className, $identifier) {
if (empty($className) || empty($identifier)) {
throw new Exception('No valid params given to return an object');
public function get($identifier) {
if (empty($identifier)) {
throw new Exception('No valid identifier given to return an object');
}
if (!empty($this->objects[$className][$identifier])) {
return $this->objects[$className][$identifier];
if (!empty($this->objects[$identifier])) {
return $this->objects[$identifier];
}
return NULL;
}
/**
* Returns all objects
* Remove a stored object
*
* @param string $identifier String to uniquely identify an object
* @return void
*/
public function remove($identifier) {
if (empty($identifier)) {
throw new Exception('No valid identifier given to remove an object');
}
unset($this->objects[$identifier]);
}
/**
* Returns all stored objects
*
* @return array All objects
*/
......@@ -118,5 +142,15 @@
return $this->objects;
}
/**
* Remove all stored objects
*
* @return void
*/
public function removeAll() {
unset($this->objects);
}
}
?>
\ No newline at end of file
......@@ -130,17 +130,17 @@
* 3. Version Tx_TerFe2_Domain_Model_Version
* 4. Extension Tx_TerFe2_Domain_Model_Extension
*/
t3lib_div::writeFile(PATH_site . 'debug.txt', print_r($structure, TRUE));
/*
$structure = array(
'ext_key' => 'test'
);
$this->objectBuilder->create('Tx_TerFe2_Domain_Model_Extension', $structure['ext_key'], $structure);
$this->objectBuilder->get('Tx_TerFe2_Domain_Model_Extension', $structure['ext_key'])->setExtKey('blub');
//$this->objectBuilder->get('Tx_TerFe2_Domain_Model_Extension', $structure['ext_key'])->setExtKey('blub');
$objects = $this->objectBuilder->getAll();
t3lib_div::writeFile(PATH_site . 'debug.txt', print_r($objects, TRUE));
t3lib_div::writeFile(PATH_site . 'debug.txt', print_r($objects, TRUE));*/
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment