Set a ContentType record's individual value.

@param string $key
@param mixed  $value
327965
public function setValue($key, $value)
    {
        // Don't set templateFields if not a real contenttype
        if (($key === 'templatefields') && (!$this->isRootType)) {
            return;
        }

        // Check if the value need to be unserialized.
        if (is_string($value) && substr($value, 0, 2) === 'a:') {
            try {
                $unserdata = Lib::smartUnserialize($value);
            } catch (\Exception $e) {
                $unserdata = false;
            }

            if ($unserdata !== false) {
                $value = $unserdata;
            }
        }

        if ($key === 'id') {
            $this->id = $value;
        }

        // Set the user in the object.
        if ($key === 'ownerid' && !empty($value)) {
            $this->user = $this->app['users']->getUser($value);
        }

        // Only set values if they have are actually a field.
        $allowedcolumns = self::getBaseColumns();
        $allowedcolumns[] = 'taxonomy';
        if (!isset($this->contenttype['fields'][$key]) && !in_array($key, $allowedcolumns)) {
            return;
        }

        /*
         * This Block starts introducing new-style hydration into the legacy content object.
         * To do this we fetch the new field from the manager and hydrate a temporary entity.
         *
         * We don't return at this point so continue to let other transforms happen below so the
         * old behaviour will still happen where adjusted.
         */
        if (isset($this->contenttype['fields'][$key]['type']) && $this->app['storage.field_manager']->hasCustomHandler($this->contenttype['fields'][$key]['type'])) {
            $newFieldType = $this->app['storage.field_manager']->getFieldFor($this->contenttype['fields'][$key]['type']);
            $newFieldType->mapping['fieldname'] = $key;
            $entity = new Content();
            // Note: Extensions _should_ implement \Bolt\Storage\Field\Type\FieldTypeInterface,
            // but if they don't, 'hydrate' doesn't exist.
            if (method_exists($newFieldType, 'hydrate')) {
                $newFieldType->hydrate([$key => $value], $entity);
            }
            $value = $entity->$key;
        }

        if (in_array($key, ['datecreated', 'datechanged', 'datepublish', 'datedepublish'])) {
            if (!preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $value)) {
                // @todo Try better date-parsing, instead of just setting it to
                // 'now' (or 'the past' for datedepublish)
                if ($key === 'datedepublish') {
                    $value = null;
                } else {
                    $value = date('Y-m-d H:i:s');
                }
            }
        }

        if ($key === 'templatefields') {
            if ((is_string($value)) || (is_array($value))) {
                if (is_string($value)) {
                    try {
                        $unserdata = Lib::smartUnserialize($value);
                    } catch (\Exception $e) {
                        $unserdata = false;
                    }
                } else {
                    $unserdata = $value;
                }

                if (is_array($unserdata)) {
                    if (is_a($this, Legacy\Content::class)) {
                        $value = new static($this->app, $this->getTemplateFieldsContentType(), [], false);
                    } else {
                        $value = new Legacy\Content($this->app, $this->getTemplateFieldsContentType(), [], false);
                    }
                    $value->setValues($unserdata);
                } else {
                    $value = null;
                }
            }
        }

        if (!isset($this->values['datechanged']) ||
            !preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $this->values['datechanged'])) {
            $this->values['datechanged'] = date('Y-m-d H:i:s');
        }

        $this->values[$key] = $value;
    }
227022
public function set($key, $value)
    {
        $this->checkForNonEmptyKey($key);

        $this->getBackEndUser()->uc[self::PHPUNIT_SETTINGS_KEY][$key] = $value;
        $this->getBackEndUser()->writeUC();
    }
1081692
public function set($key, $value)
    {
        $method = 'setter' . ucfirst($key);
        if (method_exists($this, $method)) {
            $value = $this->$method($value);
        }
        $this->setRaw($key, $value);
    }
1237936
public function setPost($key, $value)
    {
        $this->_POST = Hash::insert($this->_POST, $key, $value);
    }
364836
public function setAttribute($key, $value)
    {
        if (isset($this->repositories[$key])) {
            if (! ($value instanceof $this->repositories[$key])) {
                return;
            }

            $className = str_replace('\\', '', $this->repositories[$key]);

            $this->cache->set(
                "repositories.{$className}.{$this->id}.{$key}",
                $value
            );

            return;
        }

        if ($str = $this->checkForMutator($key, 'set')) {
            $this->{$str}($value);

            return;
        }

        if (array_search($key, $this->fillable) !== false) {
            $this->attributes[$key] = $value;
        }
    }
920481
public function setContenttype($contenttype)
    {
        if (is_string($contenttype)) {
            $contenttype = $this->app['storage']->getContenttype($contenttype);
        }

        $this->contenttype = $contenttype;
    }
1304362
public function setString($key, $value)
    {
        if (!$this->isDisabled()) {
            $path = $this->resolvePath($key, true);
            file_put_contents($path, $value);
        }
    }
851871
public function offsetSet($key, $value)
    {
        $key = strtr(strtolower($key), '_', '-');

        $this->_data[$key] = $value;
    }
88877
public function set(string $key, $value)
    {
        if (!is_array($value)) {
            $value = [$value];
        }
        $this->data[$key] = $value;
    }
546073
public function offsetSet($key, $value)
    {
        if ($key === 'query' && isset($value)) {
            $value = $this->_queryToArray($value);
        }
        $this->data[$key] = $value;
    }
1113064
static function set( $key, $value ) {
        $me = self::getInstance();
        $me->parameters[$key] = $value;
    }
961049
public function set($key, $value)
    {
        array_set($this->settings,$key,$value);
        $this->save($this->path, $this->filename);
        $this->load($this->path, $this->filename);
    }
1023566
public function set($key, $value = null)
    {
        try {
            $this->table()->insert(compact('key', 'value'));
        } catch (Exception $e) {
            $this->table()->where('key', '=', $key)->update(compact('value'));
        }
    }
905007
private function setValue($key, $value)
    {
        $this->$key = $value;

        if ($key == 'expires_in') $this->setExpiration($value);
    }
808088
public function setHypermedia(string $key, $value): self
    {
        $this->Hypermedia[$key] = $value;
        return $this;
    }
952106
public function setVariable($key, $value) {
        $this->_content = str_replace('#' . $key . '#', (string)$value, $this->_content);
        return $this;
    }
1346198
public function setAttribute($key, $value)
    {
        if ($key == 'type') {
            switch ($value) {
            case 'image': self::$rules['value'] = 'image';
            break;
            case 'file': self::$rules['value'] = 'file';
            break;
            case 'video-encoder': self::$rules['value'] = 'video';
            break;
        }
        }

        // Continue
        return parent::setAttribute($key, $value);
    }