Creates a new object state.

@param $objectStateGroupId

@throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException

@return \eZ\Publish\Core\REST\Server\Values\CreatedObjectState
332334
public function createObjectState($objectStateGroupId, Request $request)
    {
        $objectStateGroup = $this->objectStateService->loadObjectStateGroup($objectStateGroupId);

        try {
            $createdObjectState = $this->objectStateService->createObjectState(
                $objectStateGroup,
                $this->inputDispatcher->parse(
                    new Message(
                        array('Content-Type' => $request->headers->get('Content-Type')),
                        $request->getContent()
                    )
                )
            );
        } catch (InvalidArgumentException $e) {
            throw new ForbiddenException($e->getMessage());
        }

        return new Values\CreatedObjectState(
            array(
                'objectState' => new RestObjectState(
                    $createdObjectState,
                    $objectStateGroup->id
                ),
            )
        );
    }
586178
public function insertObjectState(ObjectState $objectState, $groupId)
    {
        try {
            return $this->innerGateway->insertObjectState($objectState, $groupId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1067107
static public function create($groupId, $userId, $role)
    {
        $instance = new self();

        $instance->group_id = (int)$groupId;
        $instance->user_id = (int)$userId;
        $instance->role = (int)$role;

        return $instance;
    }
223101
public function updateAction(Request $request, ObjectStateGroup $group): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('state', 'administrate'));
        $form = $this->formFactory->updateObjectStateGroup(
            new ObjectStateGroupUpdateData($group)
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (ObjectStateGroupUpdateData $data) {
                $group = $data->getObjectStateGroup();
                $updateStruct = $this->objectStateService->newObjectStateGroupUpdateStruct();
                $updateStruct->identifier = $data->getIdentifier();
                $updateStruct->names[$group->mainLanguageCode] = $data->getName();

                $updatedGroup = $this->objectStateService->updateObjectStateGroup($group, $updateStruct);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Object state group '%name%' updated.") */
                        'object_state_group.update.success',
                        ['%name%' => $updatedGroup->getName()],
                        'object_state'
                    )
                );

                return $this->redirectToRoute('ezplatform.object_state.group.view', [
                    'objectStateGroupId' => $group->id,
                ]);
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->render('@ezdesign/admin/object_state_group/edit.html.twig', [
            'object_state_group' => $group,
            'form' => $form->createView(),
        ]);
    }
160323
public static function updateObjectState( $objectID, $objectStateList )
    {
        $searchEngine = eZSearch::getEngine();

        if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'updateObjectState' ) )
        {
            return $searchEngine->updateObjectState( $objectID, $objectStateList );
        }

        return false;
    }
1251269
public function updateObjectState($objectStateGroupId, $objectStateId, Request $request)
    {
        $updateStruct = $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type')),
                $request->getContent()
            )
        );

        $objectState = $this->objectStateService->loadObjectState($objectStateId);

        try {
            $updatedObjectState = $this->objectStateService->updateObjectState($objectState, $updateStruct);

            return new RestObjectState($updatedObjectState, $objectStateGroupId);
        } catch (InvalidArgumentException $e) {
            throw new ForbiddenException($e->getMessage());
        }
    }
1059635
public function createGroupAsync(CreateGroupRequest $request, AsyncCallback $callback = null)
    {
        $response = new CreateGroupResponse();
        return $this->client->sendRequestAsync($request, $response, $callback);
    }
1243075
public function deleteObjectState($objectStateId)
    {
        $this->objectStateService->deleteObjectState(
            $this->objectStateService->loadObjectState($objectStateId)
        );

        return new Values\NoContent();
    }
219573
public function insertGroupAssignment($typeId, $status, $groupId)
    {
        try {
            return $this->innerGateway->insertGroupAssignment($typeId, $status, $groupId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
1100682
public function createGroup(CreateGroupRequest $request)
    {
        $response = new CreateGroupResponse();
        return $this->client->sendRequest($request, $response);
    }
1244445
public function loadTypesDataForGroup($groupId, $status)
    {
        try {
            return $this->innerGateway->loadTypesDataForGroup($groupId, $status);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
489
public function createDraftFromCurrentVersion($contentId)
    {
        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
        $contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
        $versionInfo = $this->repository->getContentService()->loadVersionInfo(
            $contentInfo
        );

        if ($versionInfo->isDraft()) {
            throw new ForbiddenException('Current version is already in status DRAFT');
        }

        $contentDraft = $this->repository->getContentService()->createContentDraft($contentInfo);

        return new Values\CreatedVersion(
            array(
                'version' => new Values\Version(
                    $contentDraft,
                    $contentType,
                    $this->repository->getContentService()->loadRelations($contentDraft->getVersionInfo())
                ),
            )
        );
    }
1324153
public function setContentState($contentId, $groupId, $stateId)
    {
        // First find out if $contentId is related to existing states in $groupId
        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $this->dbHandler->aliasedColumn($query, 'id', 'ezcobj_state')
        )->from(
            $this->dbHandler->quoteTable('ezcobj_state')
        )->innerJoin(
            $this->dbHandler->quoteTable('ezcobj_state_link'),
            $query->expr->eq(
                $this->dbHandler->quoteColumn('id', 'ezcobj_state'),
                $this->dbHandler->quoteColumn('contentobject_state_id', 'ezcobj_state_link')
            )
        )->where(
            $query->expr->lAnd(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('group_id', 'ezcobj_state'),
                    $query->bindValue($groupId, null, \PDO::PARAM_INT)
                ),
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('contentobject_id', 'ezcobj_state_link'),
                    $query->bindValue($contentId, null, \PDO::PARAM_INT)
                )
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        $rows = $statement->fetchAll(\PDO::FETCH_ASSOC);

        if (!empty($rows)) {
            // We already have a state assigned to $contentId, update to new one
            $query = $this->dbHandler->createUpdateQuery();
            $query->update(
                $this->dbHandler->quoteTable('ezcobj_state_link')
            )->set(
                $this->dbHandler->quoteColumn('contentobject_state_id'),
                $query->bindValue($stateId, null, \PDO::PARAM_INT)
            )->where(
                $query->expr->lAnd(
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('contentobject_id'),
                        $query->bindValue($contentId, null, \PDO::PARAM_INT)
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('contentobject_state_id'),
                        $query->bindValue($rows[0]['ezcobj_state_id'], null, \PDO::PARAM_INT)
                    )
                )
            );

            $query->prepare()->execute();
        } else {
            // No state assigned to $contentId from specified group, create assignment
            $query = $this->dbHandler->createInsertQuery();
            $query->insertInto(
                $this->dbHandler->quoteTable('ezcobj_state_link')
            )->set(
                $this->dbHandler->quoteColumn('contentobject_id'),
                $query->bindValue($contentId, null, \PDO::PARAM_INT)
            )->set(
                $this->dbHandler->quoteColumn('contentobject_state_id'),
                $query->bindValue($stateId, null, \PDO::PARAM_INT)
            );

            $query->prepare()->execute();
        }
    }
1050153
public function create($objectId)
    {
        //对象配置信息
        $objInfo=$this->getObjInfo($objectId);
        if($objInfo==null){
            throw new \Exception("Call to undefined object '".$objectId."'");
        }

        //如果单例模式且对象已经存在,直接返回
        if($objInfo->singleton && array_key_exists($objectId, $this->m_singletonObjMap)){
            return $this->m_singletonObjMap[$objectId];
        }

        //创建对象
        if(!class_exists($objInfo->class)){
            throw new \Exception("Class '".$objInfo->class."' not found");
        }
        $obj=$this->newInstance($objInfo->class,$objInfo->constructorArgs);

        //注入全局属性(全局属性只有值类型)
        foreach ($this->m_config->getConfigValues(BuiltInConst::GLOBAL_CONFIG_SESSION) as $name=>$value){
            $this->setProperty($obj, $name, $value);
        }

        //注入属性
        foreach ($objInfo->propertyInfos as $name=>$value){
            $this->setProperty($obj, $name, $value);
        }

        //如果为单态模式,则保存到缓存
        if($objInfo->singleton){
            $this->m_singletonObjMap[$objectId]=$obj;
        }

        //通过配置接口注入配置实例
        if($obj instanceof IConfigurable){
            $obj->setConfiguration($this->m_config);
        }

        //返回对象
        return $obj;
    }
295876
public function create($objectID, $categoryConst, array $attributes) {
        $params = [
            'objID' => $objectID,
            'data' => $attributes,
            'category' => $categoryConst
        ];

        $result = $this->api->request(
            'cmdb.category.create',
            $params
        );

        if (!array_key_exists('id', $result) ||
            !is_numeric($result['id']) ||
            !array_key_exists('success', $result) ||
            $result['success'] !== true) {
            if (array_key_exists('message', $result)) {
                throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
            } else {
                throw new RuntimeException('Bad result');
            }
        }

        return (int) $result['id'];
    }
389589
public function getGroupMember($groupId, $memberId)
	{
		return $this->sendRequest(
			$this->createRequest('GET', sprintf('groups/%d/members/%d', $groupId, $memberId))
		);
	}
1142453
public function createObjectStateGroup(Request $request)
    {
        try {
            $createdStateGroup = $this->objectStateService->createObjectStateGroup(
                $this->inputDispatcher->parse(
                    new Message(
                        array('Content-Type' => $request->headers->get('Content-Type')),
                        $request->getContent()
                    )
                )
            );
        } catch (InvalidArgumentException $e) {
            throw new ForbiddenException($e->getMessage());
        }

        return new Values\CreatedObjectStateGroup(
            array(
                'objectStateGroup' => $createdStateGroup,
            )
        );
    }