本文整理汇总了PHP中Item::getClassId方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::getClassId方法的具体用法?PHP Item::getClassId怎么用?PHP Item::getClassId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::getClassId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveRelatedItemIdsByModelAndUser
protected static function resolveRelatedItemIdsByModelAndUser(Item $model, &$relatedItemIds, User $user)
{
assert('is_array($relatedItemIds)');
if (RightsUtil::canUserAccessModule($model::getModuleClassName(), $user)) {
$itemId = $model->getClassId('Item');
if (!in_array($itemId, $relatedItemIds)) {
$relatedItemIds[] = $itemId;
}
}
}
示例2: getAllByPersonIndexedByType
/**
* Given a Item (Either User or Person), Try to find an existing models and index the returning array by
* badge type.
* @param Item $person
*/
public static function getAllByPersonIndexedByType(Item $person)
{
assert('$person->id > 0');
assert('$person instanceof Contact || $person instanceof User');
$searchAttributeData = array();
$searchAttributeData['clauses'] = array(1 => array('attributeName' => 'person', 'relatedAttributeName' => 'id', 'operatorType' => 'equals', 'value' => $person->getClassId('Item')));
$searchAttributeData['structure'] = '1';
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('GameBadge');
$where = RedBeanModelDataProvider::makeWhere('GameBadge', $searchAttributeData, $joinTablesAdapter);
$models = self::getSubset($joinTablesAdapter, null, null, $where, null);
$indexedModels = array();
foreach ($models as $gameBadge) {
$indexedModels[$gameBadge->type] = $gameBadge;
}
return $indexedModels;
}
示例3: resolveByPerson
/**
* Given an Item (Either User or Person), try to find an existing model. If the model does
* not exist, create it and populate the Item.
* @param Item $person
* @return The found or created model.
* @throws NotSupportedException
*/
public static function resolveByPerson(Item $person)
{
assert('$person->id > 0');
assert('$person instanceof Contact || $person instanceof User');
$searchAttributeData = array();
$searchAttributeData['clauses'] = array(1 => array('attributeName' => 'person', 'relatedAttributeName' => 'id', 'operatorType' => 'equals', 'value' => $person->getClassId('Item')));
$searchAttributeData['structure'] = '1';
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('GameCoin');
$where = RedBeanModelDataProvider::makeWhere('GameCoin', $searchAttributeData, $joinTablesAdapter);
$models = self::getSubset($joinTablesAdapter, null, 2, $where, null);
if (count($models) > 1) {
$logContent = 'Duplicate Game Coin for Person: ' . $person->id;
GamificationUtil::logAndNotifyOnDuplicateGameModel($logContent);
return $models[0];
}
if (count($models) == 0) {
$gameCoin = new GameCoin();
$gameCoin->person = $person;
$gameCoin->value = 0;
return $gameCoin;
}
return $models[0];
}
示例4: doNotificationSubscribersContainPerson
public function doNotificationSubscribersContainPerson(Item $item)
{
foreach ($this->notificationSubscribers as $notificationSubscriber) {
if ($notificationSubscriber->person->getClassId('Item') == $item->getClassId('Item')) {
return true;
}
}
return false;
}
示例5: resolvePersonAndAvailableTypes
/**
* Given an Item (Either User or Person), try to find an existing model for each type. If the model does
* not exist, create it and populate the Item and type. @return models found or created indexed by type.
* @param Item $person
* @param array $levelTypes - Level types
*/
public static function resolvePersonAndAvailableTypes(Item $person, $levelTypes)
{
assert('$person->id > 0');
assert('$person instanceof Contact || $person instanceof User');
assert('is_array($levelTypes)');
$searchAttributeData = array();
$searchAttributeData['clauses'] = array(1 => array('attributeName' => 'person', 'relatedAttributeName' => 'id', 'operatorType' => 'equals', 'value' => $person->getClassId('Item')));
$searchAttributeData['structure'] = '1';
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('GameLevel');
$where = RedBeanModelDataProvider::makeWhere('GameLevel', $searchAttributeData, $joinTablesAdapter);
$models = self::getSubset($joinTablesAdapter, null, null, $where, null);
$modelsByType = array();
foreach ($levelTypes as $type) {
$modelFound = false;
foreach ($models as $model) {
if ($model->type == $type) {
$modelsByType[$type] = $model;
$modelFound = true;
break;
}
}
if (!$modelFound) {
$gameLevel = new GameLevel();
$gameLevel->type = $type;
$gameLevel->person = $person;
$gameLevel->value = 1;
$modelsByType[$type] = $gameLevel;
}
}
return $modelsByType;
}
示例6: getAllTasksByType
/**
* Get all tasks by kanban type
* @param int $taskType
* @param Item $childObjectOfItem
* @return array of objects
*/
public static function getAllTasksByType($taskType, Item $childObjectOfItem)
{
assert('is_int($taskType)');
$searchAttributeData = array();
$searchAttributeData['clauses'] = array(1 => array('attributeName' => 'type', 'operatorType' => 'equals', 'value' => intval($taskType)), 2 => array('attributeName' => 'kanbanRelatedItem', 'operatorType' => 'equals', 'value' => $childObjectOfItem->getClassId('Item')));
$searchAttributeData['structure'] = '(1 and 2)';
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter(get_called_class());
$where = RedBeanModelDataProvider::makeWhere(get_called_class(), $searchAttributeData, $joinTablesAdapter);
$models = self::getSubset($joinTablesAdapter, null, null, $where, 'sortOrder ASC');
return $models;
}
示例7: resolvePersonAndAvailableTypes
/**
* Given an Item (Either User or Person), try to find an existing model for each type. If the model does
* not exist, create it and populate the Item and type. @return models found or created indexed by type.
* @param Item $person
* @param $collectionTypes
* @return array
* @throws FailedToSaveModelException
*/
public static function resolvePersonAndAvailableTypes(Item $person, $collectionTypes)
{
assert('$person->id > 0');
assert('$person instanceof Contact || $person instanceof User');
assert('is_array($collectionTypes)');
$searchAttributeData = array();
$searchAttributeData['clauses'] = array(1 => array('attributeName' => 'person', 'relatedAttributeName' => 'id', 'operatorType' => 'equals', 'value' => $person->getClassId('Item')));
$searchAttributeData['structure'] = '1';
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('GameCollection');
$where = RedBeanModelDataProvider::makeWhere('GameCollection', $searchAttributeData, $joinTablesAdapter);
$models = self::getSubset($joinTablesAdapter, null, null, $where, null);
$modelsByType = array();
foreach ($collectionTypes as $type) {
$modelFound = false;
foreach ($models as $model) {
if ($model->type == $type) {
$modelsByType[$type] = $model;
$modelFound = true;
break;
}
}
if (!$modelFound) {
$gameCollectionRules = GameCollectionRulesFactory::createByType($type);
$gameCollection = new GameCollection();
$gameCollection->type = $type;
$gameCollection->person = $person;
$gameCollection->serializedData = serialize($gameCollectionRules::makeDefaultData());
$saved = $gameCollection->save();
if (!$saved) {
throw new FailedToSaveModelException();
}
$modelsByType[$type] = $gameCollection;
}
}
return $modelsByType;
}