Allows site hooks to merge data into the site payload

 Returns the patched site payload
501619
def site_payload
      @cached_payload = begin
        payload = old_site_payload

        site_hooks.each do |hook|
          p = hook.merge_payload(payload, self)
          next unless p && p.is_a?(Hash)
          payload = Jekyll::Utils.deep_merge_hashes(payload, p)
        end
        payload
      end
    end
800889
def web_hook_receiver(sender, **kwargs):
    """"""

    deployment = Deployment.objects.get(pk=kwargs.get('deployment_id'))

    hooks = deployment.web_hooks

    if not hooks:
        return

    for hook in hooks:

        data = payload_generator(deployment)

        deliver_hook(deployment, hook.url, data)
429222
function injectHook(options, name, hook) {
  const existing = options[name]
  options[name] = existing
    ? Array.isArray(existing) ? existing.concat(hook) : [existing, hook]
    : [hook]
}
66516
@RequirePOST
    public HttpResponse doInvalidateData() {
        for (UpdateSite site : sites) {
            site.doInvalidateData();
        }

        return HttpResponses.ok();
    }
1099902
function getSiteFromPrefix(prefix) {
  var split = prefix.split('/'), // Split the url/uri by `/`
    host = split.shift(),        // The first value should be the host ('http://' is not included)
    optPath = split.shift(),  // The next value is the first part of the site's path OR the whole part
    path = optPath ? `/${optPath}` : '',
    length = split.length + 1,   // We always need at least one pass through the for loop
    site;                        // Initialize the return value to `undefined`

  for (let i = 0; i < length; i++) {
    site = getSite(host, path); // Try to get the site based on the host and path

    if (site) { // If a site was found, break out of the loop
      break;
    } else {
      path += `/${split.shift()}`; // Grab the next value and append it to the `path` value
    }
  }

  return site; // Return the site
}
1116403
def combined_ast
      payload = patterns.map { |p| AST::Node[:group].new(p.to_ast.payload) }
      AST::Node[:root].new(payload)
    end
794135
function (context, payload) {
        var state = context.state;
        var entity = state.$name;
        return context.dispatch(state.$connection + "/insertOrUpdate", __assign({ entity: entity }, payload), { root: true });
    }
1196810
def update_payload(self, fields=None):
        """"""
        payload = super(ConfigTemplate, self).update_payload(fields)
        if 'template_combinations' in payload:
            payload['template_combinations_attributes'] = payload.pop(
                'template_combinations')
        return {u'config_template': payload}
893437
def _merge_update_item(self, model_item, data):
        
        data_item = self.edit_model_schema.dump(model_item, many=False).data
        for _col in self.edit_columns:
            if _col not in data.keys():
                data[_col] = data_item[_col]
        return data
631004
function load(data, site) {
  let promiseComponentsOps, promisePagesOps, promiseUrisOps, promiseListsOps, promiseUsersOps,
    prefix = site.prefix,
    compData = applyPrefix(data, site);

  promiseListsOps = saveObjects(`${prefix}/_lists/`, compData._lists, getPutOperation);
  promiseUrisOps = saveBase64Strings(`${prefix}/_uris/`, compData._uris, getPutOperation);
  _.each(compData._uris, function (page, uri) {
    log('info', `bootstrapped: ${uri} => ${page}`);
  });
  promiseComponentsOps = saveWithInstances(`${prefix}/_components/`, compData._components, function (name, item) {
    return bluebird.join(
      dbOps.getPutOperations(components.cmptPut, name, _.cloneDeep(item), locals.getDefaultLocals(site))
    ).then(_.flatten);
  });
  promisePagesOps = saveObjects(`${prefix}/_pages/`, compData._pages, (name, item) => [getPutOperation(name, item)]);
  promiseUsersOps = saveObjects('', compData._users, (name, item) => [getPutOperation(`/_users/${encode(`${item.username}@${item.provider}`)}`, item)]);

  /* eslint max-params: ["error", 5] */
  return bluebird.join(promiseComponentsOps, promisePagesOps, promiseUrisOps, promiseListsOps, promiseUsersOps, function (componentsOps, pagesOps, urisOps, listsOps, userOps) {
    const flatComponentsOps = _.flatten(componentsOps),
      ops = flatComponentsOps.concat(_.flattenDeep(pagesOps.concat(urisOps, listsOps, userOps)));

    return db.batch(ops, { fillCache: false, sync: false });
  });
}
734444
public function saveSiteAction()
    {
        $request = $this->getRequest();
        $siteId = $request->getPost('site_id', null);
        $status  = 0;
        $errors  = array();
        $textMessage = '';
        $textTitle = '';
        
        $this->getEventManager()->trigger('meliscms_site_save_start', $this, array());
        
        $translator = $this->getServiceLocator()->get('translator');
        $melisTool = $this->getServiceLocator()->get('MelisCoreTool');
        $melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY);
       
        // Getting the Creation/Edition Site Form
        if (is_null($siteId))
        {
            $siteFormType = 'meliscms_site_tool_creation_form';
            $logTypeCode = 'CMS_SITE_ADD';
        }
        else
        {
            $siteFormType = 'meliscms_site_tool_edition_form';
            $logTypeCode = 'CMS_SITE_UPDATE';
        }
        
        $siteForm = $melisTool->getForm($siteFormType);
        
        if($request->isPost()) 
        {
            $siteTable = $this->getServiceLocator()->get('MelisEngineTableSite');
            $domainTable = $this->getServiceLocator()->get('MelisEngineTableSiteDomain');
            $site404Table = $this->getServiceLocator()->get('MelisEngineTableSite404');
            
            $postValues = get_object_vars($request->getPost());
            $postValues = $melisTool->sanitizePost($postValues);
            $siteForm->setData($postValues);
            
            
            
            if($siteForm->isValid()) 
            {
                $data = $siteForm->getData();
                
                $dataSite = array();
                $dataDomain = array();
                $dataSite404 = array();
                $dataSiteLang= null;
                
                if (!empty($data['plang_lang_id'])){
                    $dataSiteLang = $data['plang_lang_id'];
                }
                
                foreach($data as $dataKey => $dataValue) 
                {
                    if(strpos($dataKey, self::SITE_TABLE_PREFIX) !== false) {
                        $dataSite[$dataKey] = $data[$dataKey];
                    }
                    
                    if(strpos($dataKey, self::SITE404_TABLE_PREFIX) !== false) {
                        $dataSite404[$dataKey] = $data[$dataKey];
                    }
                    
                    if(strpos($dataKey, self::DOMAIN_TABLE_PREFIX) !== false) {
                        $dataDomain[$dataKey] = $data[$dataKey];
                    }
                }
                
                $isValidName = false;
                // Checking if the Site name is existing on the site lists
                $siteName = $this->getRequest()->getPost('site_name');
                $siteData = $siteTable->getEntryByField('site_name', $siteName)->current();
                
                if (is_null($siteId))
                {
                    if (empty($siteData))
                    {
                        $isValidName = true;
                    }
                }
                else 
                {
                    if (!empty($siteData))
                    {
                        
                        if ($siteData->site_id == $siteId)
                        {
                            $isValidName = true;
                        }
                    }
                    else 
                    {
                        $isValidName = true;
                    }
                }
                
                if($isValidName) 
                {
                    $genSiteModule = !empty($request->getPost('gen_site_mod')) ? true : false;
                    
                    $cmsSiteSrv = $this->getServiceLocator()->get('MelisCmsSiteService');
                    $saveSiteResult = $cmsSiteSrv->saveSite($dataSite, $dataDomain, $dataSite404, $dataSiteLang, $siteId, $genSiteModule, $dataSite['site_name']);
                    
                    if ($saveSiteResult['success'])
                    {
                        if (is_null($siteId))
                        {
                            $textMessage = 'tr_meliscms_tool_site_add_success';
                        }
                        else 
                        {
                            $textMessage = 'tr_meliscms_tool_site_edit_success';
                        }
                        
                        $siteId = $saveSiteResult['site_id'];
                        // to solve the error on loading css and js
                        // regenerate the melis.modules.path cause the newly created path is not
                        // included in the file
                        $this->regenerateModulesPath();
                        $status = 1;
                    }
                    else 
                    {
                        if ($saveSiteResult['message'] == 'tr_meliscms_tool_site_no_platform_ids')
                        {
                            $textMessage = 'tr_meliscms_tool_site_error_prompt_add';
                            $errors['platformId'] = array(
                                'label' => $translator->translate('tr_meliscms_tool_platform_ids'),
                                'noPlatformIds' => $translator->translate('tr_meliscms_tool_site_no_platform_ids')
                            );
                        }
                        else 
                        {
                            $textMessage = $saveSiteResult['message'];
                        }
                    }
                    
                    unset($data);
                    unset($dataSite);
                    unset($dataSite404);
                    unset($dataDomain);
                }
                else 
                {
                    // if data already exists then add manually the foreign site id key
                    $textMessage = 'tr_meliscms_tool_site_error_prompt_add';
                    $errors = array(
                        'site_name' => array(
                            'siteAlreadyExists' => $translator->translate('tr_meliscms_tool_site_name_exists')
                        ),
                    );
                }
            }
            else 
            {
                if (is_null($siteId))
                {
                    $textMessage = 'tr_meliscms_tool_site_error_prompt_add';
                }
                else
                {
                    $textMessage = 'tr_meliscms_tool_site_edit_failed';
                }
                
                $errors = $siteForm->getMessages();
                $status = 0;
            }
            
            // insert labels and error messages in error array
            $melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
            $appConfigForm = $melisMelisCoreConfig->getItem('meliscms/tools/meliscms_tool_site/forms/'.$siteFormType);
            $appConfigForm = $appConfigForm['elements'];
            
            foreach ($errors as $keyError => $valueError)
            {
                foreach ($appConfigForm as $keyForm => $valueForm)
                {
                    if ($valueForm['spec']['name'] == $keyError && !empty($valueForm['spec']['options']['label']))
                    {
                        $errors[$keyError]['label'] = $valueForm['spec']['options']['label'];
                    }
                }
            }
        }
        
        $response = array(
            'success' => $status,
            'textTitle' => 'tr_meliscms_tool_site',
            'textMessage' => $textMessage,
            'errors' => $errors,
            'test' => $errors,
        );

        $this->getEventManager()->trigger('meliscms_site_save_end', $this, array_merge($response, array('typeCode' => $logTypeCode, 'itemId' => $siteId)));
        
        if ($siteId)
        {
            $response['siteId'] = $siteId;
        }
        
        return new JsonModel($response);
    }
1191964
def MergeData(self, merge_data, raw_data=None):
    """"""
    self.FlushCache()
    if raw_data is None:
      raw_data = self.raw_data

    for k, v in iteritems(merge_data):
      # A context clause.
      if isinstance(v, dict) and k not in self.type_infos:
        if k not in self.valid_contexts:
          raise InvalidContextError("Invalid context specified: %s" % k)
        context_data = raw_data.setdefault(k, collections.OrderedDict())
        self.MergeData(v, context_data)

      else:
        # Find the descriptor for this field.
        descriptor = self.type_infos.get(k)
        if descriptor is None:
          msg = ("Missing config definition for %s. This option is likely "
                 "deprecated or renamed. Check the release notes." % k)
          if flags.FLAGS.disallow_missing_config_definitions:
            raise MissingConfigDefinitionError(msg)

        if isinstance(v, string_types):
          v = v.strip()

        # If we are already initialized and someone tries to modify a constant
        # value (e.g. via Set()), break loudly.
        if self.initialized and k in self.constants:
          raise ConstModificationError(
              "Attempting to modify constant value %s" % k)

        raw_data[k] = v
14809
function (context, payload) {
        var state = context.state;
        var entity = state.$name;
        // If the payload is an array, then the payload should be an array of
        // data so let's pass the whole payload as data.
        if (Array.isArray(payload)) {
            return context.dispatch(state.$connection + "/update", { entity: entity, data: payload }, { root: true });
        }
        // If the payload doesn't have `data` property, we'll assume that
        // the user has passed the object as the payload so let's define
        // the whole payload as a data.
        if (payload.data === undefined) {
            return context.dispatch(state.$connection + "/update", { entity: entity, data: payload }, { root: true });
        }
        // Else destructure the payload and let root action handle it.
        return context.dispatch(state.$connection + "/update", __assign({ entity: entity }, payload), { root: true });
    }
370745
function mergeMeta(ctx, newMeta) {
	if (newMeta)
		_.assign(ctx.meta, newMeta);
	return ctx.meta;
}
411172
def generate_payload(self, config, context):
        
        request = current_request()

        payload = {
            'url': request.build_absolute_uri(),
            'component': request.resolver_match.app_name,
            'action': request.resolver_match.func.__name__,
            'params': {},
            'session': {},
            'cgi_data': dict(request.META),
            'context': context
        }

        if hasattr(request, 'session'):
            payload['session'] = filter_dict(dict(request.session), config.params_filters)

        payload['params'] = filter_dict(dict(getattr(request, request.method)), config.params_filters)

        return payload
788039
function mergeHook (
  parentVal: ?Array<Function>,
  childVal: ?Function | ?Array<Function>
): ?Array<Function> {
  return childVal
    ? parentVal
      ? parentVal.concat(childVal)
      : Array.isArray(childVal)
        ? childVal
        : [childVal]
    : parentVal
}
1217431
def update_payload(self, fields=None):
        """"""
        data = super(SyncPlan, self).update_payload(fields)
        if isinstance(data.get('sync_date'), datetime):
            data['sync_date'] = data['sync_date'].strftime('%Y-%m-%d %H:%M:%S')
        return data