[TYPO3-mvc] model properties?
Daniel Dimitrov
danielsd_bg at yahoo.fr
Wed Apr 21 10:42:39 CEST 2010
hey Soren,
Hm this means that I have to change the field short_description in the
database too.
Afte few tests:
short_description and shortDescription are not accepted.
only shortdescription is a valid database field that can be automatically
understood from extabase.
Isn't this a little too restrictive?
Cheers,
Daniel
"Søren Malling" <soren.malling at gmail.com> wrote in message
news:mailman.9935.1271760298.610.typo3-project-typo3v4mvc at lists.typo3.org...
> Hi Daniel,
>
> From my experience with using underscore, i found that you have to use
> shortDescription in any case and not short_description.
>
> public function setShortDescription($short_description) {
> $this->short_description = $short_description;
> }
>
> should be
>
> public function setShortDescription($shortDescription) {
> $this->shortDescription = $shortDescription;
> }
>
> I guess it's not needed for the argument, but just to keep code clean :)
>
> The same for you getter methods
>
> Regards,
>
> Søren
>
> On Tue, Apr 20, 2010 at 12:27 PM, Daniel Dimitrov <danielsd_bg at yahoo.fr>
> wrote:
>> 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
>> _______________________________________________
>> TYPO3-project-typo3v4mvc mailing list
>> TYPO3-project-typo3v4mvc at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>>
>
>
>
> --
> Officially Certified TYPO3 Integrator
More information about the TYPO3-project-typo3v4mvc
mailing list