本文整理匯總了PHP中Backend\Core\Engine\Model::updateExtra方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::updateExtra方法的具體用法?PHP Model::updateExtra怎麽用?PHP Model::updateExtra使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Backend\Core\Engine\Model
的用法示例。
在下文中一共展示了Model::updateExtra方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: insert
/**
* Insert an item in the database
*
* @param array $item
* @return int
*/
public static function insert(array $item)
{
$item['created_on'] = BackendModel::getUTCDate();
$item['edited_on'] = BackendModel::getUTCDate();
$db = BackendModel::get('database');
// insert extra
$item['extra_id'] = BackendModel::insertExtra('widget', 'Instagram', 'InstagramFeed');
$item['id'] = (int) $db->insert('instagram_users', $item);
// update extra (item id is now known)
BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => \SpoonFilter::ucfirst(Language::lbl('Instagram', 'InstagramFeed')) . ': ' . $item['username'], 'edit_url' => BackendModel::createURLForAction('Edit', 'Instagram', null) . '&id=' . $item['id']));
return $item['id'];
}
示例2: update
/**
* Update an existing item.
*
* @param array $item The new data.
* @return int
*/
public static function update(array $item)
{
$db = BackendModel::getContainer()->get('database');
// update extra
BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('Edit') . '&id=' . $item['id']));
// archive all older content_block versions
$db->update('content_blocks', array('status' => 'archived'), 'id = ? AND language = ?', array($item['id'], BL::getWorkingLanguage()));
// insert new version
$item['revision_id'] = $db->insert('content_blocks', $item);
// how many revisions should we keep
$rowsToKeep = (int) BackendModel::get('fork.settings')->get('ContentBlocks', 'max_num_revisions', 20);
// get revision-ids for items to keep
$revisionIdsToKeep = (array) $db->getColumn('SELECT i.revision_id
FROM content_blocks AS i
WHERE i.id = ? AND i.language = ? AND i.status = ?
ORDER BY i.edited_on DESC
LIMIT ?', array($item['id'], BL::getWorkingLanguage(), 'archived', $rowsToKeep));
// delete other revisions
if (!empty($revisionIdsToKeep)) {
$db->delete('content_blocks', 'id = ? AND language = ? AND status = ? AND revision_id NOT IN (' . implode(', ', $revisionIdsToKeep) . ')', array($item['id'], BL::getWorkingLanguage(), 'archived'));
}
// return the new revision_id
return $item['revision_id'];
}
示例3: updateCategory
/**
* Update a certain category
*
* @param array $item
*/
public static function updateCategory(array $item)
{
$item['edited_on'] = BackendModel::getUTCDate();
BackendModel::getContainer()->get('database')->update('catalog_categories', $item, 'id = ?', array($item['id']));
// update extra
BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => BL::getLabel('Category') . ' ' . $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('EditCategory') . '&id=' . $item['id']));
}
示例4: updateWidget
/**
* Update the widget so it shows the correct title and has the correct template
*/
private function updateWidget()
{
$editUrl = Model::createURLForAction('Edit', 'ContentBlocks', (string) $this->locale) . '&id=' . $this->id;
// update data for the extra
// @TODO replace this with an implementation with doctrine
$extras = Model::getExtras([$this->extraId]);
$extra = reset($extras);
$data = ['id' => $this->id, 'language' => (string) $this->locale, 'edit_url' => $editUrl];
if (isset($extra['data'])) {
$data = $data + (array) $extra['data'];
}
$data['custom_template'] = $this->template;
$data['extra_label'] = $this->title;
Model::updateExtra($this->extraId, 'data', $data);
}
示例5: update
/**
* Update an item
*
* @param array $item The data of the record to update.
*
* @return int
*/
public static function update($item)
{
// redefine edited on date
$item['edited_on'] = BackendModel::getUTCDate();
// we have an extra_id
if (isset($item['extra_id'])) {
// update extra
BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => \SpoonFilter::ucfirst(BL::lbl('Location', 'core')) . ': ' . $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('Edit') . '&id=' . $item['id']));
}
// update item
return BackendModel::get('database')->update('location', $item, 'id = ? AND language = ?', array($item['id'], $item['language']));
}
示例6: updateCategory
/**
* Update a certain category
*
* @param array $item
*/
public static function updateCategory(array $item)
{
// update faq category
BackendModel::getContainer()->get('database')->update('faq_categories', $item, 'id = ?', array($item['id']));
// update extra
BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => 'Category: ' . $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('EditCategory') . '&id=' . $item['id']));
// invalidate faq
BackendModel::invalidateFrontendCache('Faq', BL::getWorkingLanguage());
}