Edit your organization membership

@link https://developer.github.com/v3/orgs/members/#edit-your-organization-membership

@param string $org
@param string $state

@return array
@throws \Exception
489632
public function editYourOrganizationMembership(string $org, string $state = AbstractApi::STATE_ACTIVE): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/user/memberships/orgs/:org', $org),
            Request::METHOD_PATCH, [
                'state' => $state
            ]);
    }
599912
public function getTokenForCode($code, $state)
    {
        if ($state != $_SESSION['oauth2_lockme_state']) {
            unset($_SESSION['oauth2_lockme_state']);
            throw new \Exception("Wrong state");
        }
        unset($_SESSION['oauth2_lockme_state']);

        $this->accessToken = $this->provider->getAccessToken('authorization_code', [
        'code' => $code
    ]);
        return $this->accessToken;
    }
402364
function setState($state) {
		if($state == (self::ALARM_ACTUATOR_STATE_ON or self::ALARM_ACTUATOR_STATE_OFF))
			$this->state = $state;
		else
			throw new \Exception('Invalid AlarmActuator state "'.$state.'"');
	}
1348203
public function listYourOrganizationMembership(string $state = null): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/user/memberships/orgs?:args',
            http_build_query(['state' => $state])));
    }
230639
public function setPublicationState($publicationState)
    {
        if (array_key_exists($publicationState, self::PUBLICATION_STATES)) {
            $this->publicationState = self::PUBLICATION_STATES[$publicationState];
        } else {
            throw new \Exception('publication state is unknown');
        }
    }
41962
public function mergeInto(RootPackageInterface $root, PluginState $state)
    {
        $this->prependRepositories($root);

        $this->mergeRequires('require', $root, $state);

        $this->mergePackageLinks('conflict', $root);
        $this->mergePackageLinks('replace', $root);
        $this->mergePackageLinks('provide', $root);

        $this->mergeSuggests($root);

        $this->mergeAutoload('autoload', $root);

        $this->mergeExtra($root, $state);

        $this->mergeScripts($root, $state);

        if ($state->isDevMode()) {
            $this->mergeDevInto($root, $state);
        } else {
            $this->mergeReferences($root);
        }
    }
314152
public function createUserAndMembership($roles = [Membership::ROLE_READ], $organization = '')
    {
        if (\is_string($roles)) {
            $roles = [$roles];
        }
        $roles = array_map(function ($role) {
            return strtolower($role);
        }, $roles);
        $contents = $this
            ->call('POST',
                implode('/', [self::ORGANIZATION_RESOURCE, $this->getOrganizationName($organization), 'memberships']),
                ['json' => [
                    'roles' => $roles,
            ]])
            ->getBody()
            ->getContents();

        return $this->getSingleMemberShipFromJsonResponse($contents);
    }
366905
public function exchangeArray(array $state) {
		if ($this instanceof IValueObject && $this->isExchanged())
			throw new Exception("Cannot change ValueObjects. Create new object instead");
		if ($this instanceof IValidatorAware && !is_null($this->getValidator()) &&
			!$this->getValidator()->isValid($state)) {
			$stateRep = array();
			foreach ($state as $key => $val)
				$stateRep[] = $key.' => '.
					(is_object($val)?'[Object]':(is_resource($val)?'[Resource]':var_export($val,true)));
			throw new InvalidStateException("ExchangeArray called with an invalid state: ".
				             var_export($this->getValidator()->getMessages(),true)."\n\n(".implode(',',$stateRep).')');
		}
		$toSet = $this->getStateVarsWithAll();
		foreach ($this->getStateVO() as $voIndex)
			if (isset($state[$voIndex])) {
				$vo = $state[$voIndex];
				if ($vo instanceof IExchangeState)
					$state = array_merge($state,$vo->getArrayCopy());
			}

		foreach ($toSet as $var) {
			if (isset($state[$var])) {
				$value = $state[$var];
				if ($this instanceof IValueObject && $value instanceof IFreezable) $value->freeze();
				// @TODO Add fields of ValueObjects to motherObject
				$this->{self::_privatizeField($var)} = $value;
			}
			else
				$this->{self::_privatizeField($var)} = null;
		}
		if ($this instanceof IValueObject)
			$this->markExchanged();
	}
1052512
public function addMemberByInvitation(OrganizationInterface $organization, User $user, Invitation $invitation)
    {
        $this->addMember($organization, $user, $invitation->getRoles());

        $invitation->setStatus('accepted');
        $invitation->setTo($user);
        $this->dm->persist($invitation);
        $this->dm->flush();
    }
1146706
public function getStateCandidates(int $state): array
    {
        $candidates = [];

        foreach ($this->candidates as $candidateId => $candidate) {
            if ($candidate->getState() == $state) {
                $candidates[$candidateId] = $candidate;
            }
        }

        return $candidates;
    }
435690
public function editAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id);

        if (!$permissionsGroup) {
            throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
        }

        $editForm = $this->createEditForm($permissionsGroup);
        
        $deleteRoleScopesForm = array();
        foreach ($permissionsGroup->getRoleScopes() as $roleScope) {
            $deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm(
                    $permissionsGroup, $roleScope);
        }
        
        $addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);

        return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array(
            'entity'      => $permissionsGroup,
            'edit_form'   => $editForm->createView(),
            'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
            'delete_role_scopes_form' => array_map( function($form) { 
                
                return $form->createView(); 
            }, $deleteRoleScopesForm),
            'add_role_scopes_form' => $addRoleScopesForm->createView()
        ));
    }
1269902
public function tokenize($state)
    {
        $rules = $this->ruler->getRules('');
        $len = count($rules);
        $end = $state->posMax;
        $maxNesting = $state->md->options->maxNesting;
        $ok = false;

        $i = 0;
        while ($state->pos < $end) {
            // Try all possible rules.
            // On success, rule should:
            //
            // - update `state.pos`
            // - update `state.tokens`
            // - return true
            if($state->pos == 3){
                $test = 0;
            }else if($state->pos == 17){
                $test = 0;
            }

            if ($state->level < $maxNesting) {
                $i = 0;
                foreach ($rules as &$rule) {
                    $i++;
                    if( is_array($rule) )
                        $ok = $rule[0]->{$rule[1]}($state, false);
                    else
                        $ok = $rule($state, false);
                    if ($ok) { break; }
                }
            }

            if ($ok) {
                if ($state->pos >= $end) { break; }
                continue;
            }

            $state->pending .= $state->src[$state->pos++];
        }

        if ($state->pending) {
            $state->pushPending();
        }
    }
1160268
public function switchTo($state)
    {
        $states = [
            0,
            1,
            false,
            true,
            'on',
            'off',
            'yes',
            'no'
        ];

        if (!in_array($state, $states)) {
            Throw new ControlException('Wrong state for on/off switch.');
        }

        switch ($state) {
            case 0:
            case false:
            case 'off':
            case 'no':
                $this->switchOff();
                break;
            case 1:
            case true:
            case 'on':
            case 'yes':
                $this->switchOn();
                break;
        }
    }
1338612
public function add_new_organization(cc_i_organization &$org) {
        $norg    = $this->activemanifest->create_organization_node($org, $this->doc);
        $orgnode = $this->node("//imscc:manifest[@identifier='".
            $this->activemanifest->manifestID().
            "']/imscc:organizations");
        $orgnode->appendChild($norg);
    }
1284609
public function pushState($state)
		{
		$r = array_push($this->states, $state);
		$this->state = $this->states[count($this->states) - 1];
		return $r;
		}
1275306
public function setState($state) {
        $statusProp = $this->getProperty(OntologyDeliveryExecution::PROPERTY_STATUS);
        $state = $this->getResource($state);
        $currentStatus = $this->getState();
        if ($currentStatus->getUri() == $state->getUri()) {
            common_Logger::w('Delivery execution '.$this->getIdentifier().' already in state '.$state->getUri());
            return false;
        }
        $this->editPropertyValues($statusProp, $state);
        if ($state->getUri() == DeliveryExecutionInterface::STATE_FINISHED) {
            $this->setPropertyValue($this->getProperty(OntologyDeliveryExecution::PROPERTY_TIME_END), microtime());
        }
        $this->state = $state;
        return true;
    }
208322
public function submitForm(array &$form, FormStateInterface $form_state) {
    $operations = [
      [
        [
          '\Drupal\openy_campaign\Controller\MembersController',
          'deleteAllMembersProcessBatch',
        ],
        [],
      ],
    ];
    $batch = [
      'title' => t('Deleting members'),
      'operations' => $operations,
      'finished' => [
        '\Drupal\openy_campaign\Controller\MembersController',
        'deleteAllMembersFinishBatch',
      ],
    ];
    batch_set($batch);
  }