[TYPO3-mvc] model properties?
Daniel Dimitrov
danielsd_bg at yahoo.fr
Tue Apr 20 12:27:29 CEST 2010
Hey guys,
I'm trying to figure something out, but so far I'm unsuccessful :(
I have a simple Model class:
/**
* A product
*
* @version $id:$
* @scope prototype
* @entity
*/
class Tx_Bwshop_Domain_Model_Products extends
Tx_Extbase_DomainObject_AbstractEntity {
/**
* the product's title
* @var string
*/
protected $title;
/**
* the product's author_name
* @var string
*/
protected $author_name;
/**
* the product's description
* @var string
*/
protected $description;
/**
* the product's short description
* @var string
*/
protected $short_description;
/**
* the product's volume
* @var string
*/
protected $volume;
/**
* get the product's title
* @return string
*/
public function getTitle() {
// var_dump($this);
return $this->title;
}
/**
* get the product's short_description
* @return string
*/
public function getShortDescription() {
return $this->short_description;
}
/**
* get the product's author_name
* @return string
*/
public function getAuthorName() {
return $this->author_name;
}
/**
* get the product's title
* @return string
*/
public function getDescription() {
return $this->description;
}
/**
* Sets the title of the product
*
* @param string $title of the product
* @return void;
*/
public function setTitle($title) {
$this->title = $title;
}
/**
* Sets the author_name of the product
*
* @param string $author_name of the product
* @return void;
*/
public function setAuthorName($author_name) {
$this->author_name = $author_name;
}
/**
* Sets the short_description of the product
*
* @param string $title of the product
* @return void;
*/
public function setShortDescription($short_description) {
$this->short_description = $short_description;
}
}
when I use findAll to get all data from the database a single object from
the result looks like this:
object(Tx_Bwshop_Domain_Model_Products)#107 (8) {
["title:protected"]=>
string(17) "ABCP"
["author_name:protected"]=>
NULL
["description:protected"]=>
string(11) "description"
["short_description:protected"]=>
NULL
["volume:protected"]=>
string(3) "100"
["_cleanProperties:private"]=>
array(4) {
["title"]=>
string(17) "ABCProblemAnalyse"
["description"]=>
string(11) "description"
["volume"]=>
string(3) "100"
["uid"]=>
int(1056)
}
["uid:protected"]=>
int(1056)
["isClone:private"]=>
bool(false)
}
as you see the object has proteted properties such as short_description and
author_name that are not added to the _cleanProperties.
Actually, why is the value set to NULL? Author_name and short_description
are fields in the database and they are defined in my tca.php file like
this:
'author_name' => array (
'exclude' => 0,
'label' =>
'LLL:EXT:bw_shop/Resources/Private/Language/locallang_db.xml:tx_bwshop_domain_model_products.author_name',
'config' => array (
'type' => 'input',
'size' => '30',
)
),
'short_description' => array(
'exclude' => 1,
'label' =>
'LLL:EXT:bw_shop/Resources/Private/Language/locallang_db.xml:tx_bwshop_domain_model_products.short_description',
'config' => array(
'type' => 'text',
'rows' => 5,
'cols' => 30,
)
),
Any ideas what I do wrong?
Thanks,
Daniel
More information about the TYPO3-project-typo3v4mvc
mailing list