Commit b85074a2 by Klimov Paul

Sphinx Gii generator created

parent 2b8cd18a
<?php
/**
* This is the template for generating the model class of a specified Sphinx index.
*
* @var yii\web\View $this
* @var yii\sphinx\gii\model\Generator $generator
* @var string $indexName full table name
* @var string $className class name
* @var yii\sphinx\IndexSchema $indexSchema
* @var string[] $labels list of attribute labels (name => label)
* @var string[] $rules list of validation rules
*/
echo "<?php\n";
?>
namespace <?= $generator->ns ?>;
use Yii;
/**
* This is the model class for index "<?= $indexName ?>".
*
<?php foreach ($indexSchema->columns as $column): ?>
* @property <?= $column->isMva ? 'array' : $column->phpType ?> <?= "\${$column->name}\n" ?>
<?php endforeach; ?>
*/
class <?= $className ?> extends <?= '\\' . ltrim($generator->baseClass, '\\') . "\n" ?>
{
/**
* @inheritdoc
*/
public static function indexName()
{
return '<?= $generator->generateIndexName($indexName) ?>';
}
<?php if ($generator->db !== 'sphinx'): ?>
/**
* @return \yii\sphinx\Connection the database connection used by this AR class.
*/
public static function getDb()
{
return Yii::$app->get('<?= $generator->db ?>');
}
<?php endif; ?>
/**
* @inheritdoc
*/
public function rules()
{
return [<?= "\n " . implode(",\n ", $rules) . "\n " ?>];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
<?php foreach ($labels as $name => $label): ?>
<?= "'$name' => " . $generator->generateString($label) . ",\n" ?>
<?php endforeach; ?>
];
}
}
<?php
/**
* @var yii\web\View $this
* @var yii\widgets\ActiveForm $form
* @var yii\sphinx\gii\model\Generator $generator
*/
echo $form->field($generator, 'indexName');
echo $form->field($generator, 'modelClass');
echo $form->field($generator, 'ns');
echo $form->field($generator, 'baseClass');
echo $form->field($generator, 'db');
echo $form->field($generator, 'useIndexPrefix')->checkbox();
echo $form->field($generator, 'enableI18N')->checkbox();
echo $form->field($generator, 'messageCategory');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment