0 votes

I have multiple Timestampable definitions for one Entity but different fields.
The generated PHP only contains one (seems to be the last definition):

enter image description here

Would have expected:

/**
 * @ORM\Column(type="datetime", nullable=false)
 * @Gedmo\Timestampable(on="create")
 * @Gedmo\Timestampable(on="change", field="status")
 *
 */
private $statusTime;

But this is actually generated:

/**
 * @ORM\Column(type="datetime", nullable=false)
 * @Gedmo\Timestampable(on="change", field="status")
 *
 */
private $statusTime;
asked by (120 points)

Thanks for info. We will check it and let you know.

I checked your screenshot but there is missing "Field" property for the first timestamp.

Are you sure you have correctly filled these values?

Can you please send me your Skipper file so I can check it directly on your file?

([email protected])

As I understand (and seems to be logical) Field property is not needed in case of On=create.

From documentation:

Field only valid if on=change is specified, tracks property or a list of properties for changes.

Relevant XML:

<?xml version="1.0"?>
<skipper-clipboard>
  <entity name="SomeBundle\Entity\Issue" local-name="Issue" namespace="SomeBundle\Entity" size-x="0" size-y="0" size-x2="125" size-y2="255" position-x="143" position-y="19" hdr-color="#D2D2D2" bg-color="#FFFFFF">
    <field name="id" type="integer" required="true" unique="true" primary="true" auto-increment="true">
      <orm-attributes>
        <attribute name="generator">
          <attribute name="strategy">IDENTITY</attribute>
        </attribute>
      </orm-attributes>
    </field>
    <field name="createdTime" type="datetime" required="true"/>
    <field name="statusTime" type="datetime" required="true"/>
    <field name="status" type="text" required="true"/>
    <orm-attributes>
      <attribute name="table">rma_cases</attribute>
      <attribute name="Gedmo">
        <attribute name="Timestampable">
          <attribute name="Fields">
            <attribute name="Field">
              <attribute name="On">create</attribute>
              <attribute name="Name">createdTime</attribute>
            </attribute>
            <attribute name="Field">
              <attribute name="Name">statusTime</attribute>
              <attribute name="Field">status</attribute>
              <attribute name="On">change</attribute>
            </attribute>
          </attribute>
        </attribute>
      </attribute>
      <attribute name="change-tracking-policy">DEFERRED_EXPLICIT</attribute>
    </orm-attributes>
  </entity>
</skipper-clipboard>

You're probably right, sorry for confusion.

Thanks for example, we will check it.

Thanks, but based on your example, the result is valid. You have first field used as "CreatedTime" and second is "StatusTime"

So, the annotation is exported to two different fiels:

/**
 * @ORM\Column(type="datetime", nullable=false)
 * @Gedmo\Timestampable(on="create")
 */
private $createdTime;

/**
 * @ORM\Column(type="datetime", nullable=false)
 * @Gedmo\Timestampable(on="change", field="status")
 */
private $statusTime; 

Ok, sorry, I've created a little bit of confusion now myself, it seems I removed the third defintion
during the time I tried to find workaround.

I now added it back, and ... it doesn't generate the line for it.

But for some reason I now tried to test what happens if remove @Gedmo annotations alltogether from PHP. And unbelievable ... it generated both definitions.

So, when the existing PHP looks like this:

/**
 * @ORM\Column(type="datetime", nullable=false)
 * @Gedmo\Timestampable(on="change", field="status")
 *
 *
 */
private $statusTime;

... Skipper does not generate the on="create" annotation (and says that file was not changed).

But when the PHP code looks like this before generation:

/**
 * @ORM\Column(type="datetime", nullable=false)
 */
private $statusTime;

It exports it as it should:

/**
 * @ORM\Column(type="datetime", nullable=false)
 * @Gedmo\Timestampable(on="change", field="status")
 * @Gedmo\Timestampable(on="create")
 */
private $statusTime;

BUT on the next generation (initiated immediately after previous one) it removes the on="create" annotation, giving me this:

    /**
 * @ORM\Column(type="datetime", nullable=false)
 * @Gedmo\Timestampable(on="change", field="status")
 *
 */
private $statusTime;

And it stays like this on subsequent generations.

So, my initial report was for actual problem, but I messed up with pic/xml. Sorry about that.

These last tests done with:
enter image description here

And:

    <?xml version="1.0"?>
<skipper-clipboard>
  <entity name="SomeBundle\Entity\Issue" local-name="Issue" namespace="SomeBundle\Entity" size-x="0" size-y="0" size-x2="125" size-y2="255" position-x="143" position-y="19" hdr-color="#D2D2D2" bg-color="#FFFFFF">
    <field name="id" type="integer" required="true" unique="true" primary="true" auto-increment="true">
      <orm-attributes>
        <attribute name="generator">
          <attribute name="strategy">IDENTITY</attribute>
        </attribute>
      </orm-attributes>
    </field>
    <field name="createdTime" type="datetime" required="true"/>
    <field name="statusTime" type="datetime" required="true"/>
    <field name="status" type="text" required="true"/>
    <orm-attributes>
      <attribute name="table">issues</attribute>
      <attribute name="Gedmo">
        <attribute name="Timestampable">
          <attribute name="Fields">
            <attribute name="Field">
              <attribute name="On">create</attribute>
              <attribute name="Name">createdTime</attribute>
            </attribute>
            <attribute name="Field">
              <attribute name="Name">statusTime</attribute>
              <attribute name="Field">status</attribute>
              <attribute name="On">change</attribute>
            </attribute>
            <attribute name="Field">
              <attribute name="Name">statusTime</attribute>
              <attribute name="On">create</attribute>
            </attribute>
          </attribute>
        </attribute>
      </attribute>
      <attribute name="change-tracking-policy">DEFERRED_EXPLICIT</attribute>
    </orm-attributes>
  </entity>
</skipper-clipboard>

Perfect, I see the same behavior here. thanks

Hi, we identified the problem but this will require more work to do.

We're already reworking AST manipulation (import/export) so we also update it together with this issue.

Unfortunately, currently I can't promise any exact term. It's a large change which allows us to support more framework in the future (starting with Laravel) so it will take some time.

Please log in or register to answer this question.