Path

ez projects / birthday / forum / general / removed ezdomdocument depen...

Attention please: Due to restructuring legacy services, the eZ Projects service is going to be discontinued. All the current repositories will be migrated to a new platform. More details will be announced soon.

Removed ezDomDocument dependency

You need to be logged in to post messages in the forums. New users may register here.

Matteo Mosangini

Member since:
12 July 2009

Posts: 11

Friday 27 November 2009 9:33:25 am

I removed ezDomDocument dependency in order to be able to export a class containing an ezbirthday datatype.
I had to modify serializeContentClassAttribute and unserializeContentClassAttribute:




function serializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )


   {


       $defaultValue = $classAttribute->attribute( self::BIRTHDAY_DEFAULT );


 

       $dom = $attributeParametersNode->ownerDocument;


       switch ( $defaultValue )


       {


           case self::BIRTHDAY_DEFAULT_EMTPY:


           {


               $attributeParametersNode->appendChild( $dom->createElement( 'default-value',


                                                                                        array( 'type' => 'empty' ) ) );


           } break;


           case self::BIRTHDAY_DEFAULT_CURRENT_DATE:


           {


                 $attributeParametersNode->appendChild( $dom->createElement( 'default-value',


                                                                                        array( 'type' => 'current-date' ) ) );


 

           } break;


       }


       unset($dom);


 

   }


 

   /*!


    \reimp


   */


   function unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )


   {


     

       $defaultValue = $attributeParametersNode->getElementByTagName( 'default-value' )->getAttribute('type');


 

       switch ( $defaultValue )


       {


           case 'empty':


           {


               $classAttribute->setAttribute( self::BIRTHDAY_DEFAULT, self::BIRTHDAY_DEFAULT_EMTPY );


           } break;


           case 'current-date':


           {


               $classAttribute->setAttribute( self::BIRTHDAY_DEFAULT, self::BIRTHDAY_DEFAULT_CURRENT_DATE );


           } break;


       }


   }


Up

Matteo Mosangini

Member since:
12 July 2009

Posts: 11

Thursday 10 December 2009 10:48:06 am

There was an error in Unserialize...

this is the correct version:




function unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )


   {


     

      foreach($attributeParametersNode->getElementsByTagName( 'default-value' ) as $attribute){


           $defaultValue = $attribute->getAttribute('type');


       }


 

       switch ( $defaultValue )


       {


           case 'empty':


           {


               $classAttribute->setAttribute( self::BIRTHDAY_DEFAULT, self::BIRTHDAY_DEFAULT_EMTPY );


           } break;


           case 'current-date':


           {


               $classAttribute->setAttribute( self::BIRTHDAY_DEFAULT, self::BIRTHDAY_DEFAULT_CURRENT_DATE );


           } break;


       }


   }


Up

You need to be logged in to post messages in the forums. New users may register here.