Method that saves the configuration
@param array $data
@param array $extra
@return array
482290
protected static function saveConfigParams(array $data, array $extra)
    {
        Logger::log('Saving required config parameters');
        //En caso de tener parámetros nuevos los guardamos
        if (array_key_exists('label', $extra) && is_array($extra['label'])) {
            foreach ($extra['label'] as $index => $field) {
                if (array_key_exists($index, $extra['value']) && !empty($extra['value'][$index])) {
                    /** @var $data array */
                    $data[$field] = $extra['value'][$index];
                }
            }
        }
        return $data;
    }
1267238
public function export($item, array $extraAttributes = ['group'], bool $useTypeSettings = false): array
    {
        /** @var Field $item*/
        $attributeObj = [];
        $extraAttributes = array_merge($extraAttributes, $this->additionalAttributes(\get_class($item)));
        if (\count($item::supportedTranslationMethods()) > 1) {
            $extraAttributes = array_merge($extraAttributes, ['translationMethod', 'translationKeyFormat']);
        }
        foreach($extraAttributes as $attribute) {
            if ($attribute === 'group') {
                $attributeObj[$attribute] = $item->$attribute->name;
                $attributeObj[$attribute . 'Id'] = $item->$attribute->id;
            } else if ($attribute === 'required') {
                $attributeObj[$attribute] = (bool) $item->$attribute;
            } else {
                $attributeObj[$attribute] = $item->$attribute;
            }
        }
        if ($useTypeSettings) {
            $fieldObj = array_merge($attributeObj, [
                'name' => $item->name,
                'handle' => $item->handle,
                'instructions' => $item->instructions,
                'type' => \get_class($item),
                'typesettings' => $item->getSettings(),
            ]);
        } else {
            $fieldObj = array_merge($attributeObj, [
                'name' => $item->name,
                'handle' => $item->handle,
                'instructions' => $item->instructions,
                'type' => \get_class($item),
            ], $item->getSettings());
        }

        if (isset($fieldObj['translationMethod']) && $fieldObj['translationMethod'] === 'none') {
            unset($fieldObj['translationMethod']);
        }

        if ($item instanceof Matrix) {
            /**
             * @var Matrix $item
             */
            $blockTypesObj = [];
            foreach ($item->getBlockTypes() as $blockType) {
                $blockTypeObj = [
                    'name' => $blockType->name,
                    'handle' => $blockType->handle,
                    'fields' => [],
                ];
                foreach ($blockType->getFields() as $blockField) {
                    $blockTypeObj['fields'][] = $this->export($blockField, [ 'required' ], true);
                }
                $blockTypesObj[] = $blockTypeObj;
            }
            if ($useTypeSettings) {
                $fieldObj['typesettings']['blockTypes'] = $blockTypesObj;
            } else {
                $fieldObj['blockTypes'] = $blockTypesObj;
            }
            unset($fieldObj['contentTable']);
        } else if ($item instanceof Neo) {
            $blockTypesObj = [];
            $blockTypeGroupsObj = [];
            /**
             * @var Neo $item
             */
            foreach ($item->getGroups() as $group) {
                /* @var NeoBlockTypeGroup $blockType */
                $blockTypeGroupsObj[] = [
                    'name' => $group->name,
                    'sortOrder' => (int) $group->sortOrder
                ];
            }
            $fieldObj['groups'] = $blockTypeGroupsObj;
            foreach ($item->getBlockTypes() as $blockType) {
                /* @var NeoBlockType $blockType */
                $blockTypesObj[] = [
                    'name' => $blockType->name,
                    'handle' => $blockType->handle,
                    'sortOrder' => (int) $blockType->sortOrder,
                    'maxBlocks' => (int) $blockType->maxBlocks,
                    'childBlocks' => Json::decodeIfJson((string) $blockType->childBlocks),
                    'maxChildBlocks' => (int) $blockType->maxBlocks,
                    'topLevel' => (bool) $blockType->topLevel,
                    'fieldLayout' => $this->exportFieldLayout($blockType->getFieldLayout()),
                    'requiredFields' => $this->exportRequiredFields($blockType->getFieldLayout()),
                ];
            }
            $fieldObj['blockTypes'] = $blockTypesObj;
        } else if ($item instanceof Date) {
            /**
             * @var Date $item
             */
            if ($useTypeSettings) {
                $fieldObj['typesettings']['dateTime'] = 'show' . (
                    ((bool) $fieldObj['typesettings']['showDate'] === false) ? 'Time' : (
                        ((bool) $fieldObj['typesettings']['showTime'] === false) ? 'Date' : 'Both'
                    )
                );
                unset($fieldObj['typesettings']['showDate'], $fieldObj['typesettings']['showTime']);
            } else {
                $fieldObj['dateTime'] = 'show' . (
                    ((bool) $fieldObj['showDate']) === false ? 'Time' : (
                        ((bool) $fieldObj['showTime']) === false ? 'Date' : 'Both'
                    )
                );
                unset($fieldObj['showDate'], $fieldObj['showTime']);
            }
        } else if ($item instanceof SuperTableField) {
            /**
             * @var SuperTableField $item
             */
            if ($useTypeSettings) {
                $fieldObj['typesettings']['blockTypes'] = [];
                foreach ($item->getBlockTypeFields() as $blockTypeField) {
                    $fieldObj['typesettings']['blockTypes'][] = $this->export($blockTypeField, [ 'required' ], true);
                }
            } else {
                $fieldObj['blockTypes'] = [];
                foreach ($item->getBlockTypeFields() as $blockTypeField) {
                    $fieldObj['blockTypes'][] = $this->export($blockTypeField, [ 'required' ], true);
                }
            }
            unset(
                $fieldObj['contentTable'], // SuperTable will auto-generate this for us.
                $fieldObj['columns'] // Cannot be set during first save, so we wont export this for now.
            );
        }

        $this->unmapSources($fieldObj);

        return $this->stripNulls($fieldObj);
    }
1158879
public function batchInsert($table, array $data, $extra = null)
    {
        $table = $this->getTable($table);
        $field = implode(', ', array_keys($data[0]));
        $placeholders = array();
        $values = array();

        switch ($this->driver) {
            default:
            case 'mysql':
            case 'pgsql':
                foreach ($data as $row) {
                    $placeholders[] = '(' . implode(', ', array_pad(array(), count($row), '?')) . ')';
                    $values = array_merge($values, array_values($row));
                }
                $placeholder = 'VALUES ' . implode(', ', $placeholders);
                break;

            // For SQLite before 3.7.11, http://www.sqlite.org/releaselog/3_7_11.html
            case 'sqlite':
                foreach ($data as $row) {
                    $placeholders[] = 'SELECT ' . implode(', ', array_pad(array(), count($row), '?'));
                    $values = array_merge($values, array_values($row));
                }
                $placeholder = implode(' UNION ', $placeholders);
                break;
        }

        $query = "INSERT INTO $table ($field) $placeholder";
        $extra && $query .= ' ' . $extra;

        return $this->executeUpdate($query, $values);
    }
52914
public function saveColl($data, $extraData = array(), $sort = false)
    {
        if (!is_array($data)) {
            return $this;
        }

        // 1. Uses primary key as data index
        $newData = array();
        foreach ($this->data as $key => $record) {
            unset($this->data[$key]);
            // Ignore default data
            if ($record instanceof $this) {
                $newData[$record[$this->primaryKey]] = $record;
            }
        }
        $this->data = $newData;

        // 2. Removes empty rows from data
        foreach ($data as $index => $row) {
            if (!array_filter($row)) {
                unset($data[$index]);
            }
        }

        // 3. Removes missing rows
        $existIds = array();
        foreach ($data as $row) {
            if (isset($row[$this->primaryKey]) && $row[$this->primaryKey] !== null) {
                $existIds[] = $row[$this->primaryKey];
            }
        }
        /** @var $record Record */
        foreach ($this->data as $key => $record) {
            if (!in_array($record[$this->primaryKey], $existIds)) {
                $record->destroy();
                unset($this->data[$key]);
            }
        }

        // 4. Merges existing rows or create new rows
        foreach ($data as $index => $row) {
            if ($sort) {
                $row[$sort] = $index;
            }
            if (isset($row[$this->primaryKey]) && isset($this->data[$row[$this->primaryKey]])) {
                $this->data[$row[$this->primaryKey]]->fromArray($row);
            } else {
                $this[] = $this->db($this->table)->fromArray($extraData + $row);
            }
        }

        // 5. Save and return
        return $this->save();
    }
821484
public function export($item, array $extraAttributes = []): array
    {
        /** @var AssetTransform $item */
        $attributeObj = [];
        $extraAttributes = array_merge($extraAttributes, $this->additionalAttributes(\get_class($item)));
        foreach($extraAttributes as $attribute) {
            $attributeObj[$attribute] = $item->$attribute;
        }

        $transformObj = array_merge([
            'name' => $item->name,
            'handle' => $item->handle,
            'mode' => $item->mode,
            'position' => $item->position,
            'width' => (int) $item->width,
            'height' => (int) $item->height,
            'quality' => (int) $item->quality,
            'interlace' => $item->interlace,
            'format' => $item->format,
        ], $attributeObj);

        return $this->stripNulls($transformObj);
    }
235797
public function export($item, array $extraAttributes = []): array
    {
        /** @var Section $item */
        $attributeObj = [];
        $extraAttributes = array_merge($extraAttributes, $this->additionalAttributes(\get_class($item)), $this->additionalAttributes($item->type));
        foreach($extraAttributes as $attribute) {
            if ($attribute === 'propagateEntries') {
                $attributeObj[$attribute] = (bool) $item->$attribute;
            } else {
                $attributeObj[$attribute] = $item->$attribute;
            }
        }

        $sectionObj = array_merge([
            'name' => $item->name,
            'handle' => $item->handle,
            'type' => $item->type,
            'enableVersioning' => (bool) $item->enableVersioning,
        ], $attributeObj);

        $siteSettings = $item->getSiteSettings();
        $sectionObj['siteSettings'] = [];
        foreach ($siteSettings as $siteSetting) {
            $hasUrls = (bool) $siteSetting->hasUrls;
            $sectionObj['siteSettings'][] = [
                'siteId' => $siteSetting->getSite()->primary ? null : $siteSetting->getSite()->handle,
                'hasUrls' => $hasUrls,
                'uriFormat' => $hasUrls ? $siteSetting->uriFormat : null,
                'template' => $siteSetting->template,
                'enabledByDefault' => (bool) $siteSetting->enabledByDefault,
            ];
        }
        $entryTypes = $item->getEntryTypes();
        $sectionObj['entryTypes'] = [];
        foreach ($entryTypes as $entryType) {
            $sectionObj['entryTypes'][] = Architect::$processors->entryTypes->export($entryType);
        }

        return $this->stripNulls($sectionObj);
    }
1006587
protected function executeQuery($url, array $data = array(), array $extra_result_data = array())
    {
        $headers = array(
            sprintf('Authorization: Bearer %s', $this->accessToken),
            'Content-Type: application/json',
            'Accept: application/json'
        );

        // Issue the request
        $content = $this->getAdapter()->getContent($url, 'POST', $headers, json_encode($data));

        if (null === $content) {
            return array_merge($this->getDefaults(), $extra_result_data);
        }

        return $this->parseResults($content, $extra_result_data);
    }
862768
public function getDataAttributes($extra = [])
    {
        $output = '';

        foreach (array_merge($this->html_attributes, $extra) as $attribute => $value) {
            if (! is_null($value)) {
                $output .= $attribute.'="'.$value.'"';
            } elseif (! $value && isset($this->args[Cuztom::uglify($attribute)])) {
                $output .= $attribute.'="'.$this->args[Cuztom::uglify($attribute)].'"';
            }
        }

        return apply_filters('cuztom_field_html_attributes', $output, $this, $extra);
    }
849699
public function extra(array $data, $prefix = '')
    {
        $this->initInternals();

        return $this->blueprintSchema->extra($data, $prefix);
    }
585877
public function export($item, array $extraAttributes = [])
    {
        /** @var UserGroup $item */
        $attributeObj = [];
        $extraAttributes = array_merge($extraAttributes, $this->additionalAttributes(\get_class($item)));
        foreach($extraAttributes as $attribute) {
            if ($attribute === 'propagateEntries') {
                $attributeObj[$attribute] = (bool) $item->$attribute;
            } else {
                $attributeObj[$attribute] = $item->$attribute;
            }
        }

        $userObj = array_merge([
            'name' => $item->name,
            'handle' => $item->handle,
            'permissions' => [],
        ], $attributeObj);

        $permissions = Craft::$app->userPermissions->getPermissionsByGroupId($item->id);
        foreach ($permissions as $permission) {
            $userObj['permissions'][] = $permission;
        }

        $this->unmapPermissions($userObj['permissions']);

        return $this->stripNulls($userObj);
    }
90944
public function head($url, array $data = array(), array $extra = array())
    {
        if (!empty($data)) {
            $url = $url . '?' . http_build_query($data);
        }

        $curl = new Curl(array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_NOBODY => true,
            CURLOPT_POSTFIELDS => http_build_query($data)
        ), $extra);

        return $curl->exec();
    }
876049
public function extra(array $extra = [], $override = true)
    {
        TypeChecker::isArray($extra);
        if (! $override) {
            $extra = array_merge($this->getNotificationData('extra', []), $extra);
        }
        $this->setNotificationData('extra', $extra);

        return $this;
    }
924906
protected function saveProductAttributes($data)
    {
        $attributeWithOptions = isset($data['attribute']) ? $data['attribute'] : [];

        if (count($attributeWithOptions) > 0) {
            $selectedAttributes = isset($data['attribute_selected']) ? $data['attribute_selected'] : [];

            $this->attribute()->sync($selectedAttributes);

            $optionsArray = [];

            foreach ($attributeWithOptions as $attributeId => $attributeOptions) {
                $optionsArray[] = array_values($attributeOptions);
            }

            $listOfOptions = $this->combinations($optionsArray);

            foreach ($listOfOptions as $option) {
                $variationProductData = $this->getVariationProductDataGivenOptions($option);
                $variableProduct = self::create($variationProductData);

                if (isset($data['category_id']) && count($data['category_id']) > 0) {
                    $variableProduct->categories()->sync($data['category_id']);
                }

                if (is_array($option)) {
                    foreach ($option as $attributeOptionId) {
                        $attributeOptionModel = AttributeDropdownOption::findorfail($attributeOptionId);
                        ProductAttributeIntegerValue::create([
                            'product_id' => $variableProduct->id,
                            'attribute_id' => $attributeOptionModel->attribute->id,
                            'value' => $attributeOptionModel->id,
                        ]);
                    }
                } else {
                    $attributeOptionModel = AttributeDropdownOption::findorfail($option);
                    ProductAttributeIntegerValue::create([
                        'product_id' => $variableProduct->id,
                        'attribute_id' => $attributeOptionModel->attribute->id,
                        'value' => $attributeOptionModel->id,
                    ]);
                }

                ProductVariation::create(['product_id' => $this->id,
                    'variation_id' => $variableProduct->id
                ]);
            }
        }
    }
604725
public function save($data)
    {
        if (is_array($data)) {
            foreach ($data as $entity) {
                $this
                    ->manager
                    ->persist($entity);
            }
        } else {
            $this
                ->manager
                ->persist($data);
        }

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

        return $data;
    }
1068383
public function save(array &$data, array $options = array())
    {
        $document = new Document($data, $this);
        $save = $document->save($options);
        $data = $document->data;

        return $save;
    }
654373
public function append($elements, $extra = null)
    {
        $elements = (array)$elements;

        foreach ($elements as $column => $element) {
            $column = trim(strtolower($column));

            $this->_conditions[$column] = $element;
        }
    }
961802
protected function _prepareExtraOptions(array &$options, $listExtraOptions = [], $optionPrefix = 'data-') {
		if (empty($options) || empty($listExtraOptions)) {
			return;
		}

		if (!is_array($listExtraOptions)) {
			$listExtraOptions = [$listExtraOptions];
		}
		$extraOptions = array_intersect_key($options, array_flip($listExtraOptions));
		if (empty($extraOptions)) {
			return;
		}

		foreach ($extraOptions as $extraOptionName => $extraOptionValue) {
			if (is_bool($extraOptionValue)) {
				if ($extraOptionValue) {
					$extraOptionValue = 'true';
				} else {
					$extraOptionValue = 'false';
				}
			}
			$options[$optionPrefix . $extraOptionName] = $extraOptionValue;
			unset($options[$extraOptionName]);
		}
	}