setType() public method

Changes the type of the field
public setType ( $p_type )
コード例 #1
0
ファイル: do_retype.php プロジェクト: sourcefabric/newscoop
$articleTypeName = Input::Get('f_article_type');
$fieldName = trim(Input::Get('f_field_name'));
$fieldType = trim(Input::Get('f_article_field_type'));
$field = new ArticleTypeField($articleTypeName, $fieldName);
$correct = true;
$errorMsgs = array();
if (!$field->exists()) {
    $errorMsgs[] = $translator->trans('The field $1 does not exist.', array('$1' => '<B>' . urlencode($fieldName) . '</B>'), 'article_type_fields');
    $correct = false;
}
if (array_search($fieldType, $field->getConvertibleToTypes()) === false) {
    $errorMsgs[] = $translator->trans('Can not convert the field $1 from $2 to type $3.', array('$1' => $fieldName, '$2' => $field->getType(), '$3' => $fieldType), 'article_type_fields');
    $correct = false;
}
if ($correct) {
    $field->setType($fieldType);
    $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
    $cacheService->clearNamespace('article_type');
    camp_html_goto_page("/{$ADMIN}/article_types/fields/?f_article_type=" . urlencode($articleTypeName));
}
$crumbs = array();
$crumbs[] = array($translator->trans('Configure'), "");
$crumbs[] = array($translator->trans('Article Types'), "/{$ADMIN}/article_types/");
$crumbs[] = array($articleTypeName, '');
$crumbs[] = array($translator->trans("Article type fields", array(), 'article_type_fields'), "/{$ADMIN}/article_types/fields/?f_article_type=" . urlencode($articleTypeName));
$crumbs[] = array($translator->trans("Adding new field", array(), 'article_type_fields'), "");
echo camp_html_breadcrumbs($crumbs);
?>

<P>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="8" class="message_box">