/*
@param string $id id
@param string $attributes attributes
@param string $offset offset
778806
private function processBeginCache($id,$attributes,$offset)
	{
		$attrs=$this->processAttributes($attributes);
		if(empty($attrs))
			return $this->generatePhpCode("if(\$this->beginCache('$id')):",$offset);
		else
			return $this->generatePhpCode("if(\$this->beginCache('$id', array($attrs))):",$offset);
	}
837376
public function attach($id, array $attributes = [])
    {
        $query = $this->newPivotStatement();

        $query->insert($this->createAttachRecords((array) $id, $attributes));
    }
1316620
public function offsetGet($offset)
    {
        return isset($this->attributes[$offset])
            ? $this->attributes[$offset]
            : null;
    }
634194
public function update($id, array $attributes)
    {
        $user = $this->findById($id);

        $user->first_name = $attributes['first_name'];
        $user->last_name = $attributes['last_name'];
        $user->email = $attributes['email'];
        $user->permissions = $attributes['permissions'];

        if( array_key_exists('password', $attributes) )
        {
            $user->password = $attributes['password'];
        }

        $user->save();

        if ( array_key_exists('groups',$attributes) )
        {
            $this->syncGroups($attributes['groups'], $user);
        }

        $this->event->fire('users.update',array($user));

        return $user;
    }
481601
function removeAttribute($id, $disposition = self::ATTR_ALL)
    {
        $attributes = &$this->_subArray($this->currentCert, 'certificationRequestInfo/attributes');

        if (!is_array($attributes)) {
            return false;
        }

        $result = false;
        foreach ($attributes as $key => $attribute) {
            if ($attribute['type'] == $id) {
                $n = count($attribute['value']);
                switch (true) {
                    case $disposition == self::ATTR_APPEND:
                    case $disposition == self::ATTR_REPLACE:
                        return false;
                    case $disposition >= $n:
                        $disposition -= $n;
                        break;
                    case $disposition == self::ATTR_ALL:
                    case $n == 1:
                        unset($attributes[$key]);
                        $result = true;
                        break;
                    default:
                        unset($attributes[$key]['value'][$disposition]);
                        $attributes[$key]['value'] = array_values($attributes[$key]['value']);
                        $result = true;
                        break;
                }
                if ($result && $disposition != self::ATTR_ALL) {
                    break;
                }
            }
        }

        $attributes = array_values($attributes);
        return $result;
    }
275809
public function offsetSet($offset, $value)
    {
        /**
         * @var UniqueIdentity $value
         */
        $this->elements->offsetSet($value->uId()->id(), $value);
    }
692134
public function update($id, array $attributes = [])
    {
        // Find the given instance
        $updated  = false;
        $instance = $id instanceof Model ? $id : $this->find($id);

        if ($instance) {
            // Fill instance with data
            $instance->fill($attributes);

            // Save the instance
            $updated = $instance->save();

            // Fire the updated event
            $this->getContainer('events')->fire($this->getRepositoryId().'.entity.updated', [$this, $instance]);
        }

        return [
            $updated,
            $instance,
        ];
    }
494809
public function offsetUnset($id)
    {
        // Unset the alias, service or factory
        if (isset($this->aliases[$id])) {
            // Call set alias so that it is internally resolved
            $this->setAlias($id, null);
        }
        if (isset($this->services[$id])) {
            unset($this->services[$id]);
        }
        if (isset($this->factories[$id])) {
            unset($this->factories[$id]);
        }
    }
895300
private function processWidget($type,$attributes,$offset)
	{
		$attrs=$this->processAttributes($attributes);
		if(empty($attrs))
			return $this->generatePhpCode("\$this->widget('$type');",$offset);
		else
			return $this->generatePhpCode("\$this->widget('$type', array($attrs));",$offset);
	}
971645
public function detach($id, $relation, $attributes)
    {
        return $this->find($id)->{$relation}()->detach($attributes);
    }
1023654
public function update($id, $attributes)
    {
        $attributes = $this->castRequest($attributes);
        $updated    = false;
        $instance   = $id instanceof Model ? $id : $this->find($id);

        if ($instance) {
            event(implode('-', $this->tag).'.entity.updating', [$this, $instance, $attributes]);

            $updated = $instance->update($attributes);

            event(implode('-', $this->tag).'.entity.updated', [$this, $instance, $attributes]);
        }

        return [
            $updated,
            $instance,
        ];
    }
679655
public function offsetSet($offset, $value)
    {
        if ( ! $this->magicAssignment) {
            throw new UnassignableAttributeException("Not allowed to assign value by magic with array access");
        }

        $this->checkAttributeAssignable($offset);

        $this->attributes[ $offset ] = $value;
    }
1235532
public function restore( $id, $attributes = array(), $search = false )
    {
        $ttl = (int)eZINI::instance( 'rest.ini' )->variable( 'CacheSettings', 'RouteApcCacheTTL' );
        $currentTime = time();
        $expiryTime = $this->getExpiryTime( $id );

        // Check if cache is marked as expired in expiry.php
        // Mandatory in clustered environment for cache control
        $isCacheInternallyExpired = false;
        if( $expiryTime < ( $currentTime - $ttl ) )
        {
            $isCacheInternallyExpired = true;
        }

        if( !$isCacheInternallyExpired ) // Cache not marked as expired in expiry.php, defer cache retore to parent class
        {
            return parent::restore( $id, $attributes, $search );
        }
        else // Cache is expired in expiry.php, return false as we must regenerate it
        {
            parent::delete( $id, $attributes, $search ); // Directly go to the parent not to force registry store, to avoid potential cache slam
            return false;
        }
    }
160577
public function offsetUnset($id)
    {
        unset($this->values[$id]);
        unset($this->definitions[$id]);
        unset($this->aliases[$id]);
    }
389344
protected function attachUsingCustomClass($id, array $attributes)
    {
        $records = $this->formatAttachRecords(
            $this->parseIds($id), $attributes
        );

        foreach ($records as $record) {
            $this->newPivot($record, false)->save();
        }
    }
936223
protected function addLabelAttributes(array $attributes, $id)
    {
        $attributes = $this->addAttribute($attributes, 'for', $id);
        if (empty($id)) {
            $attributes = $this->addAttribute($attributes, 'class', $this->multiLabelClass);
        }
        return $attributes;
    }
1253569
public function attach($id, array $attributes = array(), $touch = true)
    {
        $models = $id;

        if ($id instanceof Model)
        {
            $models = [$id];
        } elseif ($id instanceof Collection)
        {
            $models = $id->all();
        } elseif ( ! $this->isArrayOfModels($id))
        {
            $models = $this->modelsFromIds($id);
            // In case someone is messing with us and passed a bunch of ids (or single id)
            // that do not exist we slap them in the face with a ModelNotFoundException.
            // There must be at least a record found as for the records that do not match
            // they will be ignored and forever forgotten, poor thing.
            if (count($models) < 1) throw new ModelNotFoundException;

            $models = $models->all();
        }

        $saved = $this->saveMany($models, $attributes);

        if ($touch) $this->touchIfTouching();

        return ( ! is_array($id)) ? $saved->first() : $saved;
    }