我们正在尝试对某种语言进行验证,但我们正在尝试的是在xtext中编写语言和验证的skeltons(根本不使用xtend) 是否可以单独使用xtext语言验证,即不使用xtend。 提前致谢
答案 0 :(得分:0)
你的Xtext语法应该是递归的,类似的东西:
<?php
namespace app\models;
use Yii;
use app\models\CDbExpression;
/**
* This is the model class for table "reservations".
*
* @property integer $reservation_id
* @property integer $schedule_id
* @property integer $customer_id
* @property integer $officer_id
* @property integer $seat_number
* @property string $amount_paid
* @property string $datetime
*
* @property Customers $customer
* @property User $officer
* @property VehicleSchedules $schedule
*/
class Reservations extends \yii\db\ActiveRecord
{
public $mobile_number;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'reservations';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['schedule_id', 'customer_id', 'officer_id', 'seat_number'], 'required'],
[['schedule_id', 'customer_id', 'officer_id', 'seat_number'], 'integer'],
[['amount_paid'], 'number'],
[['datetime', 'mobile_number'], 'safe'],
[['customer_id'], 'exist', 'skipOnError' => true, 'targetClass' => Customers::className(), 'targetAttribute' => ['customer_id' => 'customer_id']],
[['officer_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['officer_id' => 'id']],
[['schedule_id'], 'exist', 'skipOnError' => true, 'targetClass' => VehicleSchedules::className(), 'targetAttribute' => ['schedule_id' => 'schedule_id']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'reservation_id' => 'Ticket Number',
'schedule_id' => 'Schedule ID',
'customer_id' => 'Customer Name',
'officer_id' => 'Officer',
'seat_number' => 'Seat Number',
'amount_paid' => 'Amount Paid',
'datetime' => 'Date & Time',
'mobile_number' => 'Mobile Number',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCustomer()
{
return $this->hasOne(Customers::className(), ['customer_id' => 'customer_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getOfficer()
{
return $this->hasOne(Staff::className(), ['id' => 'officer_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getSchedule()
{
return $this->hasOne(VehicleSchedules::className(), ['schedule_id' => 'schedule_id']);
}