@param $item
@param bool $update

@return bool|object

@throws \Throwable
@throws \craft\errors\EntryTypeNotFoundException
762069
public function save($item, bool $update = false)
    {
        return Craft::$app->sections->saveEntryType($item);
    }
8571
public function updateItem(Item $item): void
    {
        $query = $this->connection->createQueryBuilder();

        $query
            ->update('ngbm_collection_item')
            ->set('collection_id', ':collection_id')
            ->set('position', ':position')
            ->set('value', ':value')
            ->set('value_type', ':value_type')
            ->set('config', ':config')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $item->id, Type::INTEGER)
            ->setParameter('collection_id', $item->collectionId, Type::INTEGER)
            ->setParameter('position', $item->position, Type::INTEGER)
            ->setParameter('value', $item->value, Type::STRING)
            ->setParameter('value_type', $item->valueType, Type::STRING)
            ->setParameter('config', $item->config, Type::JSON_ARRAY);

        $this->applyStatusCondition($query, $item->status);

        $query->execute();
    }
453915
public function augmentNewSiteTreeItem(&$item)
    {
        if (isset($_POST['PageTypeFake'])) {
            $item->PageTypeFake = $_POST['PageTypeFake'];
        }
        if (isset($_POST['PageTypeID'])) {
            $item->PageTypeID = $_POST['PageTypeID'];
        }
    }
713854
function (item) {
    var i = this.indexOf(item);
    if (!~i) return false;
    this.source.splice(i, 1);
    this._updateInfo();

    this.emit("remove", item, i);
    this.emit("update", { remove: [item] });
    return item;
  }
290061
public function addItem($item){
		$itemO=$this->getItemToAdd($item);
		$this->addContent($itemO);
		return $itemO;
	}
224547
public function update($itemData, $createIfAbsent = false)
    {
        $newData = $this->preUpdate($itemData, $createIfAbsent);
        $result = $this->dataStore->update($newData, $createIfAbsent);

        return $this->postUpdate($result, $newData, $createIfAbsent);
    }
997129
public function save($item, $autoUpdate = true)
    {
        $result = null;
        $this->allowSave = true;
        if (isset($this->events[ self::EVENT_ON_BEFORE_SAVE ])) {
            $this->secureEval($this->events[ self::EVENT_ON_BEFORE_SAVE ], array(
                'item' => &$item
            ));
        }
        if ($this->allowSave) {
            $result = $this->getDriver()->save($item, $autoUpdate);
        }

        if (isset($this->events[ self::EVENT_ON_AFTER_SAVE ])) {
            $this->secureEval($this->events[ self::EVENT_ON_AFTER_SAVE ], array(
                'item' => &$item
            ));
        }
        return $result;
    }
563081
public function setType(Item $item, $body)
    {
        $rename = [
            'Movie' => 'Feature',
            'Music' => 'Music video',
            'Special' => 'TV-special',
        ];
        $type = ucfirst($body['kind']);
        $type = isset($rename[$type]) ? $rename[$type] : $type;

        return $item->setType(
            $this
                ->doctrine
                ->getRepository('AnimeDbCatalogBundle:Type')
                ->findOneBy(['name' => $type])
        );
    }
781718
public function save($item, bool $update = false)
    {
        return Craft::$app->categories->saveGroup($item);
    }
924319
public function isCanRefill(Item $item, $field)
    {
        return in_array($field, $this->supported_fields) && $this->getSourceForFill($item);
    }
1157973
public function UpdateItem()
    {
        $pathExpr = $this->SingleValuedPathExpression();

        $this->match(Lexer::T_EQUALS);

        $updateItem = new AST\UpdateItem($pathExpr, $this->NewValue());

        return $updateItem;
    }
192781
protected function checkScope($update = true)
    {
        $request = request();

        if ($update && $request->exists('scope')) {

            $this->activeScope = $request->get('scope');

            $this->markResetActivePage();
            $this->storeActiveScopeInSession();
        } else {
            $this->retrieveActiveScopeFromSession();
        }

        // Check if active is valid, reset it othwerwise
        if ($this->activeScope && ! $this->isValidScopeKey($this->activeScope)) {
            $this->activeScope = null;
            $this->storeActiveScopeInSession();
        }

        return $this;
    }
818838
public function convertBooleans($item)
    {
        if (is_array($item)) {
            foreach ($item as $key => $value) {
                if (is_bool($value)) {
                    $item[$key] = ($value) ? 'true' : 'false';
                } elseif (is_numeric($value)) {
                    $item[$key] = ($value > 0) ? 'true' : 'false';
                }
            }
        } else {
            if (is_bool($item)) {
                $item = ($item) ? 'true' : 'false';
            } elseif (is_numeric($item)) {
                $item = ($item > 0) ? 'true' : 'false';
            }
        }

        return $item;
    }
1038486
public function updateItem($itemHash, $key, $value)
    {
        if (empty($item = $this->getItem($itemHash)) === false) {
            if ($key == 'qty' && $value == 0) {
                return $this->removeItem($itemHash);
            }

            $item->$key = $value;
        }

        $this->update();

        return $item;
    }
210300
protected function update($step)
    {
        $contentTypeCollection = $this->matchContentTypes('update', $step);

        if (count($contentTypeCollection) > 1 && array_key_exists('references', $step->dsl)) {
            throw new \Exception("Can not execute Content Type update because multiple types match, and a references section is specified in the dsl. References can be set when only 1 type matches");
        }

        if (count($contentTypeCollection) > 1 && array_key_exists('new_identifier', $step->dsl)) {
            throw new \Exception("Can not execute Content Type update because multiple roles match, and a new_identifier is specified in the dsl.");
        }

        $contentTypeService = $this->repository->getContentTypeService();
        $lang = $this->getLanguageCode($step);
        foreach ($contentTypeCollection as $key => $contentType) {

            if (isset($step->dsl['remove_drafts']) && $step->dsl['remove_drafts']) {
                try {
                    $draft = $contentTypeService->loadContentTypeDraft($contentType->id);
                    $contentTypeService->deleteContentType($draft);
                } catch (NotFoundException $e) {
                }
            }

            $contentTypeDraft = $contentTypeService->createContentTypeDraft($contentType);

            $contentTypeUpdateStruct = $contentTypeService->newContentTypeUpdateStruct();
            $contentTypeUpdateStruct->mainLanguageCode = $lang;

            $newIdentifier = null;
            if (isset($step->dsl['new_identifier'])) {
                $newIdentifier = $this->referenceResolver->resolveReference($step->dsl['new_identifier']);
                $contentTypeUpdateStruct->identifier = $newIdentifier;
            }

            if (isset($step->dsl['name'])) {
                $contentTypeUpdateStruct->names = $this->getMultilingualValue($step->dsl['name'], $lang, $contentTypeDraft->getNames());
            }

            if (isset($step->dsl['description'])) {
                $contentTypeUpdateStruct->descriptions = $this->getMultilingualValue($step->dsl['description'], $lang, $contentTypeDraft->getDescriptions());
            }

            if (isset($step->dsl['name_pattern'])) {
                $contentTypeUpdateStruct->nameSchema = $step->dsl['name_pattern'];
            }

            if (isset($step->dsl['url_name_pattern'])) {
                $contentTypeUpdateStruct->urlAliasSchema = $step->dsl['url_name_pattern'];
            }

            if (isset($step->dsl['is_container'])) {
                $contentTypeUpdateStruct->isContainer = $step->dsl['is_container'];
            }

            if (isset($step->dsl['default_always_available'])) {
                $contentTypeUpdateStruct->defaultAlwaysAvailable = $step->dsl['default_always_available'];
            }

            if (isset($step->dsl['default_sort_field'])) {
                $contentTypeUpdateStruct->defaultSortField = $this->sortConverter->hash2SortField($step->dsl['default_sort_field']);
            }

            if (isset($step->dsl['default_sort_order'])) {
                $contentTypeUpdateStruct->defaultSortOrder = $this->sortConverter->hash2SortOrder($step->dsl['default_sort_order']);
            }

            // Add/edit attributes
            if (isset($step->dsl['attributes'])) {
                // NB: seems like eZ gets mixed up if we pass some attributes with a position and some without...
                // We go out of our way to avoid collisions and preserve order
                $maxFieldDefinitionPos = count($contentType->fieldDefinitions);
                $newFieldDefinitions = array();
                foreach ($step->dsl['attributes'] as $attribute) {

                    // allow easy reuse of attribute defs by storing them in references
                    if (is_string($attribute)) {
                        $attribute = $this->referenceResolver->resolveReference($attribute);
                    }

                    $existingFieldDefinition = $this->contentTypeHasFieldDefinition($contentType, $attribute['identifier']);

                    if ($existingFieldDefinition) {
                        // Edit existing attribute
                        $fieldDefinitionUpdateStruct = $this->updateFieldDefinition(
                            $contentTypeService, $attribute, $attribute['identifier'], $contentType->identifier, $lang, $existingFieldDefinition
                        );
                        $contentTypeService->updateFieldDefinition(
                            $contentTypeDraft,
                            $existingFieldDefinition,
                            $fieldDefinitionUpdateStruct
                        );
                        if ($fieldDefinitionUpdateStruct->position > 0) {
                            $maxFieldDefinitionPos = $fieldDefinitionUpdateStruct->position > $maxFieldDefinitionPos ? $fieldDefinitionUpdateStruct->position : $maxFieldDefinitionPos;
                        } else {
                            $maxFieldDefinitionPos = $existingFieldDefinition->position > $maxFieldDefinitionPos ? $existingFieldDefinition->position : $maxFieldDefinitionPos;
                        }

                    } else {
                        // Create new attributes, keep them in temp array
                        $newFieldDefinition = $this->createFieldDefinition($contentTypeService, $attribute, $contentType->identifier, $lang);
                        $maxFieldDefinitionPos = $newFieldDefinition->position > $maxFieldDefinitionPos ? $newFieldDefinition->position : $maxFieldDefinitionPos;
                        $newFieldDefinitions[] = $newFieldDefinition;
                    }
                }

                // Add new attributes
                foreach($newFieldDefinitions as $newFieldDefinition) {
                    if ($newFieldDefinition->position == 0) {
                        $newFieldDefinition->position = ++$maxFieldDefinitionPos;
                    }
                    $contentTypeService->addFieldDefinition($contentTypeDraft, $newFieldDefinition);
                }
            }

            // Remove attributes
            if (isset($step->dsl['remove_attributes'])) {

                // allow the '*' string to mean 'all attributes excepts the ones specified in this step'
                if ($step->dsl['remove_attributes'] === '*') {
                    $modifiedAttributeIdentifiers = array();
                    foreach ($step->dsl['attributes'] as $attribute) {
                        $modifiedAttributeIdentifiers[] = $attribute['identifier'];
                    }

                    foreach ($contentType->getFieldDefinitions() as $existingFieldDefinition) {
                        if (!in_array($existingFieldDefinition->identifier, $modifiedAttributeIdentifiers)) {
                            $contentTypeService->removeFieldDefinition($contentTypeDraft, $existingFieldDefinition);
                        }
                    }
                } else {
                    // we assume that $step->dsl['remove_attributes'] is an array of field identifiers
                    foreach ($step->dsl['remove_attributes'] as $attribute) {
                        $existingFieldDefinition = $this->contentTypeHasFieldDefinition($contentType, $attribute);
                        if ($existingFieldDefinition) {
                            $contentTypeService->removeFieldDefinition($contentTypeDraft, $existingFieldDefinition);
                        }
                        /// @todo log a warning if the specified field is not present
                    }
                }
            }

            $contentTypeService->updateContentTypeDraft($contentTypeDraft, $contentTypeUpdateStruct);
            $contentTypeService->publishContentTypeDraft($contentTypeDraft);

            if (isset($step->dsl['content_type_group'])) {
                $this->setContentTypeGroup($contentType, $step->dsl['content_type_group']);
            }

            if (isset($step->dsl['remove_content_type_group'])) {
                $this->unsetContentTypeGroup($contentType, $step->dsl['remove_content_type_group']);
            }

            // Set references
            if ($newIdentifier !== null) {
                $contentType = $contentTypeService->loadContentTypeByIdentifier($newIdentifier);
            } else {
                $contentType = $contentTypeService->loadContentTypeByIdentifier($contentTypeDraft->identifier);
            }

            $contentTypeCollection[$key] = $contentType;
        }

        $this->setReferences($contentTypeCollection, $step);

        return $contentTypeCollection;
    }
702537
public static function create($result, $table, $update=false)
	{
		$model = null;
		$class = \Model::getClassFromTable($table);
		$id    = is_object($result) ? $result->id : $result;
		$cto32 = version_compare(VERSION, '3.2', '>=');

		// Check the registry in Contao 3.2
		if($cto32) {
			$model = \Model\Registry::getInstance()->fetch($table, $id);

			// model is already in the registry, shall we update the model to the current record?
			// This will affect every reference which uses the model
			// You really have to know what u need - both is dangerous
			if($model && $update) {
				$model->setRow($result->row());
			}
		}

		// Model is not in the registry
		if(!$model) {
			if(is_object($result)) {
				$model = new $class($result);
			}
			else {
				// we have to get the result from the db
				$result = \Database::getInstance()
					->prepare("SELECT * FROM $table WHERE id=?")
					->execute($id);

				if($result->numRows) {
					$model = new $class($result);
				}
				else {
					$model = new $class();

					// do not set id if Contao 3.2 is used because a new record is created, so that id is ignored
					if(!$cto32) {
						$model->id = $id;
					}
				}
			}
		}

		return $model;
	}
1264634
public function setItem(Item $item)
    {
        if ($this->item !== $item) {
            $this->item = $item->setType($this);
        }

        return $this;
    }