<?xml version="1.0"?>

<!--

 This file is part of the Sylius package.

 (c) Paweł Jędrzejewski

 For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.

-->

<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
                                        http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

    <class name="Sylius\Component\Order\Model\Order">
        <property name="items">
            <constraint name="Valid" />
        </property>
    </class>

    <class name="Sylius\Component\Order\Model\OrderItem">
        <property name="quantity">
            <constraint name="NotBlank">
                <option name="message">sylius.order_item.quantity.not_blank</option>
                <option name="groups">sylius</option>
            </constraint>
            <constraint name="Type">
                <option name="type">integer</option>
                <option name="message">sylius.order_item.quantity.integer</option>
                <option name="groups">sylius</option>
            </constraint>
            <constraint name="Range">
                <option name="min">1</option>
                <option name="minMessage">sylius.order_item.quantity.min</option>
                <option name="groups">sylius</option>
            </constraint>
        </property>
    </class>

    <class name="Sylius\Component\Order\Model\Adjustment">
        <property name="label">
            <constraint name="NotBlank">
                <option name="message">sylius.adjustment.label.not_blank</option>
                <option name="groups">sylius</option>
            </constraint>
        </property>
        <property name="amount">
            <constraint name="NotBlank">
                <option name="message">sylius.adjustment.amount.not_blank</option>
                <option name="groups">sylius</option>
            </constraint>
            <constraint name="Type">
                <option name="type">integer</option>
                <option name="message">sylius.adjustment.amount.integer</option>
                <option name="groups">sylius</option>
            </constraint>
        </property>
    </class>

</constraint-mapping>
                                                                                                                           <?xml version="1.0" encoding="UTF-8" ?>

<!--

 This file is part of the Sylius package.

 (c) Paweł Jędrzejewski

 For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.

-->

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"                  
                  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                                      http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
>

    <mapped-superclass name="Sylius\Component\Order\Model\Comment" table="sylius_order_comment">
        <id name="id" column="id" type="integer">
            <generator strategy="AUTO" />
        </id>

        <field name="state" column="state" type="string" />
        <field name="comment" column="comment" type="text" nullable="true" />
        <field name="notifyCustomer" column="notify_customer" type="boolean" />
        <field name="author" column="author" type="string" />

        <field name="createdAt" column="created_at" type="datetime">
            <gedmo:timestampable on="create"/>
        </field>
        <field name="updatedAt" column="updated_at" type="datetime" nullable="true">
            <gedmo:timestampable on="update"/>
        </field>

        <many-to-one field="order" target-entity="Sylius\Component\Order\Model\OrderInterface" inversed-by="comments">
            <join-column name="order_id" referenced-column-name="id" nullable="false" />
        </many-to-one>
    </mapped-superclass>

</doctrine-mapping>
