Edit a hook

@link https://developer.github.com/v3/repos/hooks/#edit-a-hook

@param int    $id
@param string $config
@param array  $events
@param array  $addEvents
@param array  $removeEvents
@param bool   $active

@return array
16742
public function editHook(int $id, string $config, array $events = ['push'], array $addEvents = [],
                             array $removeEvents = [], bool $active = true): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/hooks/:id',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $id), Request::METHOD_PATCH, [
                'config'        => $config,
                'events'        => $events,
                'add_events'    => $addEvents,
                'remove_events' => $removeEvents,
                'active'        => $active
            ]);
    }
799713
static function removeEvents( $events = false, $id = false, $version = false )
    {
        if ( is_array( $events ) )
        {
            $db = eZDB::instance();
            $db->begin();
            foreach( $events as $event )
            {
                $event->remove();
            }
            $db->commit();
        }
        else
        {
            $condArray = array();
            if ( $version !== false )
            {
                $condArray['version'] = $version;
            }
            if ( $id !== false )
            {
                $condArray['workflow_id'] = $id;
            }
            eZPersistentObject::removeObject( eZWorkflowEvent::definition(),
                                              $condArray );
        }
    }
119248
public function edit($listener, $id)
    {
        $eloquent = $this->model->findOrFail($id);
        $form = $this->presenter->form($eloquent);

        $this->fireEvent('form', [$eloquent, $form]);

        return $listener->editSucceed(compact('eloquent', 'form'));
    }
77903
public function editAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();
        $site = $em->getRepository(Site::class)->find($id);

        $originalDomains = new ArrayCollection();
        foreach ($site->getDomains() as $domain) {
            $originalDomains->add($domain);
        }

        $form = $this->createForm(SiteType::class, $site);
        $form->handleRequest($request);


        if ($form->isSubmitted() && $form->isValid()) {

            // Remove deleted domains
            foreach ($originalDomains as $domain) {
                if (false === $site->getDomains()->contains($domain)) {
                    $em->remove($domain);
                }
            }

            // Add new domain
            foreach ($form->getData()->getDomains() as $domain) {
                $domain->setSite($site);
            }
            $em->persist($domain);

            $em->flush();

            return $this->redirectToRoute('opifer_cms_site_edit', ['id' => $site->getId()]);
        }

        return $this->render('OpiferCmsBundle:Backend/Site:edit.html.twig', [
            'form' => $form->createView(),
            'site' => $site,
        ]);
    }
1154069
public function configureEventManager(SharedEventManagerInterface $eventManager, $id, $eventName)
    {
        $quotedId = $this->xpathQuote($id);
        $quotedEvent = $this->xpathQuote($eventName);
        $objectManager = $this->getObjectManager();

        $this->addListenersFromArray($eventManager, $id, $eventName);

        $xpath = "./listener[@scope = $quotedId and @event = $quotedEvent and @class != '']";
        foreach ($this->getXml()->xpath($xpath) as $node) {
            $class = (string)$node['class'];
            $priority = (string)$node['priority'];

            if (!$objectManager->has($class)) {
                continue;
            }

            $params = array();
            if (isset($node->options)) {
                $params = $node->options->toPhpValue('array', $objectManager);
            }

            $listener = $objectManager->newInstance($class, $params);
            $eventManager->attach($id, $eventName, $listener, (int)$priority);
        }

        return $this;
    }
209835
public function editAction(Request $request, $id)
    {
        /** @var Config $data */
        $data = $this->manager->find($id);

        if (!$data) {
            throw $this->createNotFoundException();
        }

        try {
            $adapter = $this->registry->getAdapter($data->getAdapter());
        } catch (Exception $e) {
            throw $this->createNotFoundException('Not Found', $e);
        }

        $event = new GetResponseConfigEvent($data, $request);

        if ($this->dispatcher->dispatch(IntegratedChannelEvents::CONFIG_EDIT_REQUEST, $event)->getResponse()) {
            return $event->getResponse();
        }

        $form = $this->createEditForm($data, $adapter);
        $form->handleRequest($request);

        if ($form->get('actions')->getData() == 'cancel') {
            return $this->redirect($this->generateUrl('integrated_channel_config_index'));
        }

        if ($form->isSubmitted() && $form->isValid()) {
            $event = $this->dispatcher->dispatch(
                IntegratedChannelEvents::CONFIG_EDIT_SUBMITTED,
                new FormConfigEvent($data, $request, $form)
            );

            $this->manager->persist($data);

            if (!$response = $event->getResponse()) {
                if ($message = $this->getFlashMessage()) {
                    $message->success(sprintf('The changes to the config %s are saved', $data->getName()));
                }

                $response = $this->redirect($this->generateUrl('integrated_channel_config_index'));
            }

            $this->dispatcher->dispatch(
                IntegratedChannelEvents::CONFIG_EDIT_RESPONSE,
                new FilterResponseConfigEvent($data, $request, $response)
            );

            return $response;
        }

        return $this->render('IntegratedChannelBundle:Config:edit.html.twig', [
            'adapter' => $adapter,
            'data'    => $data,
            'form'    => $form->createView()
        ]);
    }
678623
public function editContactEvent($contactId, $eventId, array $parameters)
    {
        return $this->makeRequest($this->endpoint.'/'.$eventId.'/contact/'.$contactId.'/edit', $parameters, 'PUT');
    }
594850
function(items, enabled)
	{
		var method = enabled === false ? 'removeEventListener' : 'addEventListener';
		
		items = (conbo.isArray(items) ? items : [items]).slice();
		
		while (items.length)
		{
			var item = items.pop();
			
			if (item instanceof conbo.EventDispatcher)
			{
				item[method](conbo.ConboEvent.CHANGE, this.dispatchEvent, this);
			}
		}
	}
783509
public function handleEdit($id, $key)
	{
		$column = $this->getColumn($key);
		$value = $this->getPresenter()->getRequest()->getPost('value');

		/**
		 * @var mixed Could be NULL of course
		 */
		$new_value = call_user_func_array($column->getEditableCallback(), [$id, $value]);

		$this->getPresenter()->payload->_datagrid_editable_new_value = $new_value;
	}
423356
protected void modified(String id, Map<String, Object> properties) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(this, tc, "modified " + id, properties);
        }

        config = properties;
        myProps = null;
    }
348873
public function actionAdd($id, $parent_id, $add = 1)
    {
        $parent = $this->findParentModel($parent_id);
        $model = $this->findParentModel();
        $model->type = Item::TYPE_PERMISSION;
        $model->name = $id;
        if ((!$child = $model::findOne($id)) && $add) {
            $child = $model;
        }
        if ($add) {
            $parent->addChild($child);
        } else if ($child){
            $parent->removeChild($child);
        }
    }
1333779
public function getEditForm($id=null, $fields=null) {
        if(!$id) {
            $id=$this->currentPageID();
        }
        
        
        $record=$this->getRecord($id);
        if($record && !$record->canView()) {
            return Security::permissionFailure($this);
        }
        
        
        
        if($record) {
            $fields=$record->getCMSFields();
            $actions=new FieldList(
                                    FormAction::create('doSave', _t('CodeBank.SAVE', '_Save'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'),
                                    FormAction::create('doCancel', _t('CodeBank.CANCEL', '_Cancel'))
                                );
            
            
            if($record->canDelete()) {
                $actions->push(FormAction::create('doDelete', _t('CodeBank.DELETE', '_Delete'))->addExtraClass('ss-ui-action-destructive'));
            }
            
            
            // Use <button> to allow full jQuery UI styling
            $actionsFlattened=$actions->dataFields();
            if($actionsFlattened) {
                foreach($actionsFlattened as $action) {
                    if($action instanceof FormAction) {
                        $action->setUseButtonTag(true);
                    }
                }
            }
            
            
            if($record->hasMethod('getCMSValidator')) {
                $validator=$record->getCMSValidator();
            }else {
                $validator=new RequiredFields();
            }
            
            
            $fields->push(new HiddenField('ID', 'ID'));
            
            $form=CMSForm::create($this, 'EditForm', $fields, $actions, $validator)->setHTMLID('Form_EditForm');
            $form->loadDataFrom($record);
            $form->disableDefaultAction();
            $form->addExtraClass('cms-edit-form');
            $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
            $form->addExtraClass('center '.$this->BaseCSSClasses());
            $form->setResponseNegotiator($this->getResponseNegotiator());
            $form->setAttribute('data-pjax-fragment', 'CurrentForm');
            
            
            $this->extend('updateEditForm', $form);
            
            
            //Display message telling user to run dev/build because the version numbers are out of sync
            if(CB_VERSION!='@@VERSION@@' && CodeBankConfig::CurrentConfig()->Version!=CB_VERSION.' '.CB_BUILD_DATE) {
                $form->insertBefore(new LiteralField('<p class="message error">'._t('CodeBank.UPDATE_NEEDED', '_A database upgrade is required please run {startlink}dev/build{endlink}.', array('startlink'=>'<a href="dev/build?flush=all">', 'endlink'=>'</a>')).'</p>'), 'LanguageID');
            }else if($this->hasOldTables()) {
                $form->insertBefore(new LiteralField('<p class="message warning">'._t('CodeBank.MIGRATION_AVAILABLE', '_It appears you are upgrading from Code Bank 2.2.x, your old data can be migrated {startlink}click here to begin{endlink}, though it is recommended you backup your database first.', array('startlink'=>'<a href="dev/tasks/CodeBankLegacyMigrate">', 'endlink'=>'</a>')).'</p>'), 'LanguageID');
            }
            
            $form->Actions()->push(new LiteralField('CodeBankVersion', '<p class="codeBankVersion">Code Bank: '.$this->getVersion().'</p>'));
            
            
            Requirements::javascript(CB_DIR.'/javascript/CodeBank.EditForm.js');
            
            return $form;
        }
        
        $form=$this->EmptyForm();
        if(Session::get('CodeBank.deletedSnippetID')) {
            $form->Fields()->push(new HiddenField('ID', 'ID', Session::get('CodeBank.deletedSnippetID')));
        }
        
        
        //Display message telling user to run dev/build because the version numbers are out of sync
        if(CB_VERSION!='@@VERSION@@' && CodeBankConfig::CurrentConfig()->Version!=CB_VERSION.' '.CB_BUILD_DATE) {
            $form->push(new LiteralField('<p class="message error">'._t('CodeBank.UPDATE_NEEDED', '_A database upgrade is required please run {startlink}dev/build{endlink}.', array('startlink'=>'<a href="dev/build?flush=all">', 'endlink'=>'</a>')).'</p>'));
        }else if($this->hasOldTables()) {
            $form->push(new LiteralField('<p class="message warning">'._t('CodeBank.MIGRATION_AVAILABLE', '_It appears you are upgrading from Code Bank 2.2.x, your old data can be migrated {startlink}click here to begin{endlink}, though it is recommended you backup your database first.', array('startlink'=>'<a href="dev/tasks/CodeBankLegacyMigrate">', 'endlink'=>'</a>')).'</p>'));
        }
        
        $this->redirect('admin/codeBank/');
        return $form;
    }
821559
protected function _addModuleEvents($aModuleEvents, $sModuleId)
    {
        $aEvents = (array) \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('aModuleEvents');
        if (is_array($aEvents)) {
            $aEvents[$sModuleId] = $aModuleEvents;
        }

        $this->_saveToConfig('aModuleEvents', $aEvents);
    }
390911
function(events) {
	return {
		remove: function() { // Remove multiple events.
			for (var key in events) {
				events[key].remove();
			}
		},
		add: function() { // Add multiple events.
			for (var key in events) {
				events[key].add();
			}
		}
	};
}
217917
public function editAction(Request $request, $id)
    {
        /** @var ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_UPDATE);

        $model = $this->findOr404Error($id);
        $form = $crudConfigurator->getForm($model);

        return $this->createOrUpdate($request, $model, $form, Constants::ACTION_UPDATE, $crudConfigurator->getTemplate()->getEdit());
    }
1155461
public function getRenderedEditor($id, array $options = array())
    {
        $config = clone $this->options;
        $config->setFromArray($options);
        
        $basePath = $this->getView()->basePath($config->getBasePath());
        $editor = new \CKEditor($basePath);
        
        return $editor->replace($id, $this->optionsToCKEditorConfig($config));
    }
631266
public function edit($id)
    {
        $this->request->allowMethod(['get', 'put']);

        /** @var Page $page */
        $page = $this->Pages->get($id, ['contain' => ['Current', 'Attributes', 'Collections']]);

        ThemeManager::theme(Wasabi::setting('Cms.Theme.id'));

        if ($this->request->is('put')) {
            $page = $this->Pages->patchEntity($page, $this->request->data);
            if ($this->Pages->save($page)) {
                $this->Flash->success(__d('wasabi_cms', 'The page <strong>{0}</strong> has been saved.', $page->name));
                $this->redirect(['action' => 'index']);
                return;
            } else {
                $this->Flash->error($this->formErrorMessage);
            }
        } else {
            /** @var Content $current */
            $current = $page->current;
            if (!is_array($current) &&
                get_class($current) === 'Wasabi\Cms\Model\Entity\Content' &&
                $current->isNew()
            ) {
                $defaultLayout = ThemeManager::theme()->getLayout('Default');
                $page->current = [
                    (new Content())->set('content', json_encode($defaultLayout->content()))
                ];
            }
        }

        if ($page->meta_robots_index === null) {
            $page->meta_robots_index = (bool)Configure::read('Settings.Cms.SEO.meta-robots-index');
        }

        if ($page->meta_robots_follow === null) {
            $page->meta_robots_follow = (bool)Configure::read('Settings.Cms.SEO.meta-robots-follow');
        }

        $routes = $this->Routes
            ->findAllFor('Wasabi/Cms.Pages', $id, Wasabi::contentLanguage()->id)
            ->order([$this->Routes->aliasField('url') => 'asc']);

        $this->set([
            'page' => $page,
            'layouts' => ThemeManager::theme()->getLayoutsForSelect(),
            'availableModules' => ModuleManager::getAvailableModules(),
            'changeAttributesUrl' => Router::url([
                'plugin' => 'Wasabi/Cms',
                'controller' => 'Pages',
                'action' => 'attributes'
            ]),
            'attributes' => $page->getLayout()->attributes(),
            'routes' => $routes,
            'routeTypes' => RouteTypes::getForSelect(),
            'formRoute' => $this->Routes->newEntity([
                'type' => ($routes->count() >= 1) ? RouteTypes::TYPE_REDIRECT_ROUTE : RouteTypes::TYPE_DEFAULT_ROUTE
            ])
        ]);

        $this->render('add');
    }