Save option

@param OptionInterface $option

@return OptionInterface
961514
public function save(OptionInterface $option)
    {
        $this->em->persist($option);
        $this->em->flush();

        return $option;
    }
533521
public function save(array $options = array())
    {
        $result = false;
        
        if ($this->pricelistId) {
            $result = parent::save($options);
            $order = Order::find($this->id);
            $order->pricelists()->attach($this->pricelistId);
        } else {
            throw new Exception('pricelist_id not set.');
        }
        
        return $result;
    }
377092
public function save($options = [])
    {
        if (!isset($options['except'])) {
            $options['except'] = [];
        }

        $options['except'] = array_merge($options['except'], $this->readOnly);

        if (!$this->exists) {
            return $this->create($options);
        }

        return $this->update($options);
    }
1141914
public function addOption(OptionInterface $option, $name = null)
    {
        $this->options[$name ?: $option->getName()] = $option;
        if ($option instanceof OptionRegistryAwareInterface) {
            $option->setOptionRegistry($this);
        }

        return $this;
    }
829869
public function saveIfExistsOrFail(array $options = []): bool
    {
        if ($this->exists === false) {
            return false;
        }

        return $this->saveOrFail($options);
    }
801253
public function save( array $options = [] )
    {
        $query = $this->newQueryWithoutScopes();

        // If the "saving" event returns false we'll bail out of the save and return
        // false, indicating that the save failed. This provides a chance for any
        // listeners to cancel save operations if validations fail or whatever.
        if ($this->fireModelEvent('saving') === false) {
            return false;
        }

        // If the model already exists in the database we can just update our record
        // that is already in this database using the current IDs in this "where"
        // clause to only update this model. Otherwise, we'll just insert them.
        if ($this->exists) {
            $saved = $this->performUpdate($query, $options);
            self::$lastUpdated = $this;
        }

        // If the model is brand new, we'll insert it into our database and set the
        // ID attribute on the model to the value of the newly inserted row's ID
        // which is typically an auto-increment value managed by the database.
        else {
            $saved = $this->performInsert($query, $options);
            self::$lastCreated = $this;
        }

        if ($saved) {
            $this->finishSave($options);
        }

        return $saved;
    }
466717
public function save(Option $option): bool
    {
        $key = $option->getKey();

        foreach ($this->repositories as $repository) {
            if ($repository->has($key)) {
                return $repository->save($option);
            }
        }

        throw UnknownOptionKey::fromKey($key);
    }
847640
public function save(Option $option): bool
    {
        $key = $option->getKey();

        if (! $this->has($key)) {
            throw UnknownOptionKey::fromKey($key);
        }

        $this->values[$key] = $option->sanitize();

        return $this->persist();
    }
187503
public function save(array $options = [])
    {

        if (is_null($this->getAttributeValue('date')))
            $this->setAttribute('date', carbon()->toDateString());

        $this->setAttribute('month', carbon($this->getAttributeValue('date'))->month);
        $this->setAttribute('year', carbon($this->getAttributeValue('date'))->year);

        return parent::save($options);
    }
1254706
public function getOptionFromDboptions($option, InputInterface $input)
    {
        $dbOptionReturnValue = null;
        if (!empty($input->getOption('dboptions'))) {
            $dbOptions = explode(',', $input->getOption('dboptions'));
            if (is_array($dbOptions)) {
                foreach ($dbOptions as $dbOption) {
                    $dbOptionParts = explode(':', $dbOption);
                    if (!empty($dbOptionParts[1])) {
                        $dbOptionValue = $dbOptionParts[1];
                    }
                    if ($option === $dbOptionParts[0]) {
                        if (!empty($dbOptionValue)) {
                            $dbOptionReturnValue = $dbOptionValue;
                        } else {
                            $dbOptionReturnValue = true;
                        }
                    }
                }
            }
        }
        return $dbOptionReturnValue;
    }
456178
public function saveInto(DataObjectInterface $record)
    {
        $fieldname = $this->name;
        $managedClass = $this->managedClass;

        // Remove all "privileged" permissions if the currently logged-in user is not an admin
        $privilegedPermissions = Permission::config()->privileged_permissions;
        if ((is_array($this->value) || $this->value instanceof Traversable)
            && !Permission::check('ADMIN')
        ) {
            foreach ($this->value as $id => $bool) {
                if (in_array($id, $privilegedPermissions)) {
                    unset($this->value[$id]);
                }
            }
        }

        // remove all permissions and re-add them afterwards
        $permissions = $record->$fieldname();
        foreach ($permissions as $permission) {
            $permission->delete();
        }

        $schema = DataObject::getSchema();
        if ($fieldname && $record && (
            $schema->hasManyComponent(get_class($record), $fieldname)
            || $schema->manyManyComponent(get_class($record), $fieldname)
        )) {
            if (!$record->ID) {
                $record->write(); // We need a record ID to write permissions
            }

            if (is_array($this->value) || $this->value instanceof Traversable) {
                foreach ($this->value as $id => $bool) {
                    if ($bool) {
                        $perm = new $managedClass();
                        $perm->{$this->filterField} = $record->ID;
                        $perm->Code = $id;
                        $perm->write();
                    }
                }
            }
        }
    }
813120
public function save(array $options = array())
  {
      // Do some testing before passing onto parent save method
      //if($this->category === null || $this->category->exists === false)
      //{
          //throw new DomainException('Post must be assigned a Category');
      //}

      if(!$this->exists)
      {
        $this->recordEvents(new PostWasCreatedEvent($this));
      }

      $saved = parent::save($options);

      return $saved;
  }
759325
public function save(ManufacturerInterface $manufacturer): ManufacturerInterface
    {
        $data = $this->serializer()->serialize($manufacturer);

        if ($manufacturer->getId() !== 0) {
            $this->shopware()
                 ->put('/api/manufacturers/'.(string)$manufacturer->getId(), [], $data);
        } else {
            $response = $this->shopware()->post('/api/manufacturers', [], $data);
            $data     = json_decode((string)$response->getBody(), true);
            $manufacturer->setId((int)$data['data']['id']);
        }

        return $manufacturer;
    }
302386
private function SaveOptions(array $options)
    {
        $prev = null;
        foreach ($options as $value=>$text)
        {
            $option = new RadioOption();
            $option->SetRadioField($this->radio);
            $option->SetPrevious($prev);
            $option->SetText($text);
            $option->SetValue($value);
            $option->Save();
            $prev = $option;
        }
    }
991019
public function save(EventInterface $event)
    {
        $uuid = (string) $event->uuid();
        $version = ($this->count($event->uuid())) ?: 0;
        $type = $event->type();
        $payload = $event->payload();
        $body = serialize($event->body());
        $occurredOn = $event->occurredOn()->format('Y-m-d H:i:s.u');

        $sql = 'INSERT INTO `'.PdoDriver::EVENTSTORE_TABLE_NAME.'` (
                    `uuid`,
                    `version`,
                    `payload`,
                    `type`,
                    `body`,
                    `occurred_on`
                  ) VALUES (
                    :uuid,
                    :version, 
                    :payload, 
                    :type,
                    :body, 
                    :occurred_on
            )';

        $stmt = $this->connection->prepare($sql);
        $stmt->bindParam(':uuid', $uuid);
        $stmt->bindParam(':version', $version);
        $stmt->bindParam(':payload', $payload);
        $stmt->bindParam(':type', $type);
        $stmt->bindParam(':body', $body);
        $stmt->bindParam(':occurred_on', $occurredOn);
        $stmt->execute();
    }
285922
public function save($options = array())
    {

        if ($this->isEmbed()) {
            return false;
        }

        $this->processReferencesChanged();
        $this->processEmbedsChanged();

        /* if no changes then do nothing */

        if ($this->_exist && empty($this->dirtyData) && empty($this->unsetData)) return true;

        $this->__preSave();

        if ($this->_exist) {
            $this->__preUpdate();
            $updateQuery = array();

            if (!empty($this->dirtyData)) {
                $updateQuery['$set'] = self::mapFields($this->dirtyData);
            };

            if (!empty($this->unsetData)) {
                $updateQuery['$unset'] = self::mapFields($this->unsetData);
            }

            $success = $this->_connection->update($this->collectionName(), array('_id' => $this->getId()), $updateQuery, $options);
            $this->__postUpdate();

        } else {
            $this->__preInsert();
            $data = self::mapFields($this->cleanData);
            $insert = $this->_connection->insert($this->collectionName(), $data, $options);
            $success = !is_null($this->cleanData['_id'] = $insert['_id']);
            if ($success) {
                $this->_exist = true ;
                $this->__postInsert();
            }

        }

        $this->dirtyData = array();
        $this->unsetData = array();
        $this->__postSave();

        return $success;

    }
725868
protected function save(UserInterface $user)
    {
        try
        {
            $entityManager = $this->getEntityManager();
            $entityManager->persist($user);
            $entityManager->flush();

            return $user;
        }
        catch (\Exception $e)
        {
            return false;
        }
    }