本文整理汇总了PHP中X2Model::getModelTypesWhichSupportRelationships方法的典型用法代码示例。如果您正苦于以下问题:PHP X2Model::getModelTypesWhichSupportRelationships方法的具体用法?PHP X2Model::getModelTypesWhichSupportRelationships怎么用?PHP X2Model::getModelTypesWhichSupportRelationships使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X2Model
的用法示例。
在下文中一共展示了X2Model::getModelTypesWhichSupportRelationships方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(&$params)
{
// make sure this is a valid model type
if (!is_subclass_of($this->config['modelClass'], 'X2Model')) {
return array(false, "");
}
if (!isset($this->config['attributes']) || empty($this->config['attributes'])) {
return array(false, "");
}
// verify that if create relationship option was set, that a relationship can be made
if ($this->parseOption('createRelationship', $params)) {
$acceptedModelTypes = X2Model::getModelTypesWhichSupportRelationships();
if (!in_array($this->config['modelClass'], $acceptedModelTypes)) {
return array(false, Yii::t('x2flow', 'Relationships cannot be made with records ' . 'of type {type}.', array('{type}' => $this->config['modelClass'])));
}
if (!isset($params['model'])) {
// no model passed to trigger
return array(false, '');
}
if (!in_array(get_class($params['model']), $acceptedModelTypes)) {
return array(false, Yii::t('x2flow', 'Relationships cannot be made with records ' . 'of type {type}.', array('{type}' => get_class($params['model']))));
}
}
$model = new $this->config['modelClass']();
$model->setScenario('X2FlowCreateAction');
if ($this->setModelAttributes($model, $this->config['attributes'], $params) && $model->save()) {
if ($this->parseOption('createRelationship', $params)) {
Relationships::create(get_class($params['model']), $params['model']->id, get_class($model), $model->id);
}
return array(true, Yii::t('studio', 'View created record: ') . $model->getLink());
} else {
$errors = $model->getErrors();
return array(false, array_shift($errors));
}
}
示例2: array
?>
</span>
</div>
<div class="tableWrapper">
<table>
<tbody>
<tr class="formSectionRow">
<td style="">
<div class="formItem leftLabel">
<label><?php
echo Yii::t('media', 'Association Type');
?>
</label>
<div class="formInputBox" style="height: auto;">
<?php
$linkableModels = X2Model::getModelTypesWhichSupportRelationships(true);
$this->widget('MultiTypeAutocomplete', array('selectName' => 'Media[associationType]', 'hiddenInputName' => 'Media[associationId]', 'selectValue' => '', 'options' => array_merge(array('' => Yii::t('app', 'None')), array_diff_key($linkableModels, array_flip(array('Media', 'Groups', 'X2List', 'Actions', 'Reports'))), array('bg' => Yii::t('app', 'Background'))), 'staticOptions' => array('', 'bg'), 'htmlOptions' => array('class' => 'media-association-type')));
// echo $form->dropDownList($model,'associationType',
// array(
// 'none'=>Yii::t('actions','None'),
// 'contacts'=>Yii::t('actions','Contact'),
// 'opportunities'=>Yii::t('actions','Opportunity'),
// 'accounts'=>Yii::t('actions','Account'),
// 'bg'=>Yii::t('media', 'Background'),
// ), array('onChange'=>'showAssociationAutoComplete(this)'));
?>
</div>
</div>
</td>
</tr>
示例3: validateType
/**
* Ensure that type corresponds to child of X2Model which supports relationships
*/
public function validateType($attr)
{
$value = $this->{$attr};
$validTypes = X2Model::getModelTypesWhichSupportRelationships(true);
if (!class_exists($value) || !isset($validTypes[$value])) {
$this->addError($attr, Yii::t('app', 'Invalid record type'));
}
}
示例4: getViewFileParams
public function getViewFileParams()
{
if (!isset($this->_viewFileParams)) {
$linkableModels = X2Model::getModelTypesWhichSupportRelationships(true);
asort($linkableModels);
// used to instantiate html dropdown
$linkableModelsOptions = $linkableModels;
$hasUpdatePermissions = $this->checkModuleUpdatePermissions();
$this->_viewFileParams = array_merge(parent::getViewFileParams(), array('model' => $this->model, 'modelName' => get_class($this->model), 'linkableModelsOptions' => $linkableModelsOptions, 'hasUpdatePermissions' => $hasUpdatePermissions, 'height' => $this->getWidgetProperty('height')));
}
return $this->_viewFileParams;
}