Insert the model states

@param ObjectMixable $mixer
353594
public function onMixin(ObjectMixable $mixer)
    {
        parent::onMixin($mixer);

        if ($mixer instanceof ModelDatabase)
        {
            $table = $mixer->getTable();

            // Set the dynamic states based on the unique table keys
            foreach ($table->getUniqueColumns() as $key => $column) {
                $mixer->getState()->insert($key, $column->filter, null, true, $table->mapColumns($column->related, true));
            }
        }
    }
1169573
protected function insertObjectStateGroupTranslations(Group $objectStateGroup)
    {
        foreach ($objectStateGroup->languageCodes as $languageCode) {
            $languageId = $this->maskGenerator->generateLanguageIndicator(
                $languageCode,
                $languageCode === $objectStateGroup->defaultLanguage
            );

            $query = $this->dbHandler->createInsertQuery();
            $query->insertInto(
                $this->dbHandler->quoteTable('ezcobj_state_group_language')
            )->set(
                $this->dbHandler->quoteColumn('contentobject_state_group_id'),
                $query->bindValue($objectStateGroup->id, null, \PDO::PARAM_INT)
            )->set(
                $this->dbHandler->quoteColumn('description'),
                $query->bindValue($objectStateGroup->description[$languageCode])
            )->set(
                $this->dbHandler->quoteColumn('name'),
                $query->bindValue($objectStateGroup->name[$languageCode])
            )->set(
                $this->dbHandler->quoteColumn('language_id'),
                $query->bindValue($languageId, null, \PDO::PARAM_INT)
            )->set(
                $this->dbHandler->quoteColumn('real_language_id'),
                $query->bindValue($languageId & ~1, null, \PDO::PARAM_INT)
            );

            $query->prepare()->execute();
        }
    }
586389
public function onMixin(KObjectMixable $mixer)
    {
        parent::onMixin($mixer);

        //Create and mixin the permission if it's doesn't exist yet
        if (!$this->_permission instanceof KDispatcherPermissionInterface)
        {
            $permission = $this->_permission;

            if (!$permission || (is_string($permission) && strpos($permission, '.') === false))
            {
                $identifier = $mixer->getIdentifier()->toArray();

                if($identifier['type'] == 'lib') {
                    $identifier['path'] = array('permission');
                } else {
                    $identifier['path'] = array('dispatcher', 'permission');
                }

                if ($permission) {
                    $identifier['name'] = $permission;
                }

                $permission = $this->getIdentifier($identifier);
            }

            if (!$permission instanceof KObjectIdentifierInterface) {
                $permission = $this->getIdentifier($permission);
            }

            $this->_permission = $mixer->mixin($permission);
        }
    }
969018
protected function addDoInsertBodyRaw()
    {
        $this->declareClasses('Propel', 'PDO');
        $table = $this->getTable();
        $peerClassname = $this->getPeerClassname();
        $platform = $this->getPlatform();
        $primaryKeyMethodInfo = '';
        if ($table->getIdMethodParameters()) {
            $params = $table->getIdMethodParameters();
            $imp = $params[0];
            $primaryKeyMethodInfo = $imp->getValue();
        } elseif ($table->getIdMethod() == IDMethod::NATIVE && ($platform->getNativeIdMethod() == PropelPlatformInterface::SEQUENCE || $platform->getNativeIdMethod() == PropelPlatformInterface::SERIAL)) {
            $primaryKeyMethodInfo = $platform->getSequenceName($table);
        }
        $query = 'INSERT INTO ' . $platform->quoteIdentifier($table->getName()) . ' (%s) VALUES (%s)';
        $script = "
        \$modifiedColumns = array();
        \$index = 0;
";

        foreach ($table->getPrimaryKey() as $column) {
            if (!$column->isAutoIncrement()) {
                continue;
            }
            $constantName = $this->getColumnConstant($column);
            if ($platform->supportsInsertNullPk()) {
                $script .= "
        \$this->modifiedColumns[] = $constantName;";
            }
            $columnProperty = strtolower($column->getName());
            if (!$table->isAllowPkInsert()) {
                $script .= "
        if (null !== \$this->{$columnProperty}) {
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . $constantName . ')');
        }";
            } elseif (!$platform->supportsInsertNullPk()) {
                $script .= "
        // add primary key column only if it is not null since this database does not accept that
        if (null !== \$this->{$columnProperty}) {
            \$this->modifiedColumns[] = $constantName;
        }";
            }
        }

        // if non auto-increment but using sequence, get the id first
        if (!$platform->isNativeIdMethodAutoIncrement() && $table->getIdMethod() == "native") {
            $column = $table->getFirstPrimaryKeyColumn();
            $columnProperty = strtolower($column->getName());
            $script .= "
        if (null === \$this->{$columnProperty}) {
            try {";
            $script .= $platform->getIdentifierPhp('$this->' . $columnProperty, '$con', $primaryKeyMethodInfo, '				');
            $script .= "
            } catch (Exception \$e) {
                throw new PropelException('Unable to get sequence id.', \$e);
            }
        }
";
        }

        $script .= "

         // check the columns in natural order for more readable SQL queries";
        foreach ($table->getColumns() as $column) {
            $constantName = $this->getColumnConstant($column);
            $identifier = var_export($platform->quoteIdentifier($column->getName()), true);
            $script .= "
        if (\$this->isColumnModified($constantName)) {
            \$modifiedColumns[':p' . \$index++]  = $identifier;
        }";
        }

        $script .= "

        \$sql = sprintf(
            '$query',
            implode(', ', \$modifiedColumns),
            implode(', ', array_keys(\$modifiedColumns))
        );

        try {
            \$stmt = \$con->prepare(\$sql);
            foreach (\$modifiedColumns as \$identifier => \$columnName) {
                switch (\$columnName) {";
        foreach ($table->getColumns() as $column) {
            $columnNameCase = var_export($platform->quoteIdentifier($column->getName()), true);
            $script .= "
                    case $columnNameCase:";
            $script .= $platform->getColumnBindingPHP($column, "\$identifier", '$this->' . strtolower($column->getName()), '						');
            $script .= "
                        break;";
        }
        $script .= "
                }
            }
            \$stmt->execute();
        } catch (Exception \$e) {
            Propel::log(\$e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', \$sql), \$e);
        }
";

        // if auto-increment, get the id after
        if ($platform->isNativeIdMethodAutoIncrement() && $table->getIdMethod() == "native") {
            $column = $table->getFirstPrimaryKeyColumn();
            $columnProperty = strtolower($column->getName());
            $script .= "
        try {";
            $script .= $platform->getIdentifierPhp('$pk', '$con', $primaryKeyMethodInfo);
            $script .= "
        } catch (Exception \$e) {
            throw new PropelException('Unable to get autoincrement id.', \$e);
        }";
            if ($table->isAllowPkInsert()) {
                $script .= "
        if (\$pk !== null) {
            \$this->set" . $column->getPhpName() . "(\$pk);
        }";
            } else {
                $script .= "
        \$this->set" . $column->getPhpName() . "(\$pk);";
            }
            $script .= "
";
        }

        return $script;
    }
51432
public function save($record, $objectType, $matchField = null)
    {
        if ($matchField) {
            $this->addBulkUpsertRecord($record, $objectType, $matchField);
        } elseif (isset($record->Id) && null !== $record->Id) {
            $this->addBulkUpdateRecord($record, $objectType);
        } else {
            $this->addBulkCreateRecord($record, $objectType);
        }

        return $this;
    }
99694
public function updateObjectState(ObjectState $objectState)
    {
        try {
            return $this->innerGateway->updateObjectState($objectState);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
856854
public function afterInsert($model, $id)
    {
        if ($this->weak) {
            return;
        }

        $this->save_buffer[$this->foreign_field] =
            isset($this->join) ? $this->join->id : $id;

        $persistence = $this->persistence ?:
            $this->owner->persistence;

        $this->id = $persistence->insert(
            $model,
            $this->save_buffer,
            $this->foreign_table
        );
    }
376960
public function afterInsert($model, $id)
    {
        if ($this->weak) {
            return;
        }

        $insert = $this->dsql();
        $insert->set($model->persistence->typecastSaveRow($model, $this->save_buffer));
        $this->save_buffer = [];
        $insert
            ->set(
                $this->foreign_field,
                isset($this->join) ? $this->join->id : $id
            );
        $insert->insert();
        $this->id = $this->owner->lastInsertID();
    }
136644
public function setVersionMixin(AbstractMappingEvent $event)
    {
        if (!$this->support($event->getDocument())) {
            return;
        }

        $event->getNode()->addMixin('mix:versionable');
    }
728151
private function array_insert(mixed $object, string $key, int $position) : void
    {
        if (0 == count($this->members)) {
            // The array is empty so just add the item
            $this->members[$key] = $object;
        } elseif ($position == count($this->members)) {
            // The item goes at the end of the array
            $this->members[$key] = $object;
        } else {
            $this->members = array_slice($this->members, 0, $position,
                    true) + array($key => $object) + array_slice($this->members, $position, null, true);
        }
    }
589409
public function addMiddleware($middleware, bool $prepend = false)
    {
        if (!is_array($middleware)) {
            $middleware = [$middleware];
        }

        if ($prepend) {
            $this->middleware = array_merge($middleware, $this->middleware);
        } else {
            $this->middleware = array_merge($this->middleware, $middleware);
        }

        $this->middleware = array_unique($this->middleware, SORT_REGULAR);
    }
1017364
def create_mixin(self):
        

        _builder = self

        class CustomModelMixin(object):
            @cached_property
            def _content_type(self):
                return ContentType.objects.get_for_model(self)

            @classmethod
            def get_model_custom_fields(cls):
                """ Return a list of custom fields for this model, callable at model level """
                return _builder.fields_model_class.objects.filter(content_type=ContentType.objects.get_for_model(cls))

            def get_custom_fields(self):
                """ Return a list of custom fields for this model """
                return _builder.fields_model_class.objects.filter(content_type=self._content_type)

            def get_custom_value(self, field):
                """ Get a value for a specified custom field """
                return _builder.values_model_class.objects.get(custom_field=field,
                                                               content_type=self._content_type,
                                                               object_id=self.pk)

            def set_custom_value(self, field, value):
                """ Set a value for a specified custom field """
                custom_value, created = \
                    _builder.values_model_class.objects.get_or_create(custom_field=field,
                                                                      content_type=self._content_type,
                                                                      object_id=self.pk)
                custom_value.value = value
                custom_value.full_clean()
                custom_value.save()
                return custom_value

            #def __getattr__(self, name):
            #    """ Get a value for a specified custom field """
            #    try:
            #        obj = _builder.values_model_class.objects.get(custom_field__name=name,
            #                                                      content_type=self._content_type,
            #                                                      object_id=self.pk)
            #        return obj.value
            #    except ObjectDoesNotExist:
            #        pass
            #    return super(CustomModelMixin, self).__getattr__(name)

        return CustomModelMixin
33926
protected function initialize($mixed) {
								
		if(is_a($mixed, 'Guzzle\Http\Message\Response')) {			
			$this->href = strval($mixed->getHeader('Location'));
			
			$json_obj = json_decode($mixed->getBody(true));
			if($json_obj) {
				$this->_castInputParametersWithClosure($json_obj);
			}
		}
		
		if(is_a($mixed, 'SimpleXMLElement')) {			
			$this->_castInputParametersWithClosure(get_object_vars($mixed));
		}
		
		if(is_a($mixed, 'stdClass')) {
			$this->_castInputParametersWithClosure(get_object_vars($mixed));
		}
		
		if(is_a($mixed, 'RGeyer\Guzzle\Rs\Model\ModelBase')) {
			$this->_params = array_merge($this->_params, $mixed->_params);
		}
		
		if(isset($this->_params['links'])) {
			foreach($this->links as $link) {
				if($link->rel == 'self') {
					$this->href = $link->href;
				}
			}
		}
		
		if($this->href) {
			$this->id = $this->_castIdWithClosure($this->getIdFromHref($this->href));
		}
	}
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);
        }
    }
929055
protected function setMixins(Metadata\Interfaces\MixinInterface $metadata, array $mixins)
    {
        foreach ($mixins as $mixinName) {
            $mixinMeta = $this->loadMetadataForMixin($mixinName);
            if (null === $mixinMeta) {
                continue;
            }
            $metadata->addMixin($mixinMeta);
        }
        return $metadata;
    }
352907
public function insert($substring, $idx, $encoding = null)
    {
        return $this->addModifier('insert', array($substring, $idx, $encoding));
    }
1008715
public function insertAllData($model)
    {
        try {
            $this->validate(['model' => $model]);
            $query = null;

            $allData = $this->con->getAllData($model, $query);
            $params = null;
            foreach ($allData as $key => $data) {
                $params['body'][] = array(
                    'index' => array(
                        '_index' => $this->client->getIndex(),
                        '_type'  => $model->tableName(),
                        '_id'    => $data[$this->idColumn],
                    ),
                );
                $params['body'][] = $data;
            }
            $responses = $this->client->getClient()->bulk($params);
            return $responses;
        } catch (\Elasticsearch\Common\Exceptions\NoNodesAvailableException $ex) {
            throw new SyncMySqlExceptions("Check your elasticsearch connetion");
        }
    }