__clone example


  public function setStorageRequired($required) {
    $this->definition['storage_required'] = $required;
    return $this;
  }

  /** * Magic method: Implements a deep clone. */
  public function __clone() {
    parent::__clone();

    // The itemDefinition (\Drupal\Core\Field\TypedData\FieldItemDataDefinition)     // has a property fieldDefinition, which is a recursive reference to the     // parent BaseFieldDefinition, therefore the reference to the old object has     // to be overwritten with a reference to the cloned one.     $this->itemDefinition->setFieldDefinition($this);
    // Reset the static cache of the field property definitions in order to     // ensure that the clone will reference different field property definitions     // objects.     $this->propertyDefinitions = NULL;
  }

  
if ($this->forUpdate) {
      $query .= ' FOR UPDATE';
    }

    return $query;
  }

  /** * {@inheritdoc} */
  public function __clone() {
    parent::__clone();

    // On cloning, also clone the dependent objects. However, we do not     // want to clone the database connection object as that would duplicate the     // connection itself.
    $this->condition = clone($this->condition);
    $this->having = clone($this->having);
    foreach ($this->union as $key => $aggregate) {
      $this->union[$key]['query'] = clone($aggregate['query']);
    }
    foreach ($this->tables as $alias => $table) {
      
unset($instance->$name);
        } else {
            $accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope);
            $accessor['unset']($instance$name);
        }
    }

    public function __clone(): void
    {
        if (!isset($this->lazyObjectState)) {
            if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['clone']) {
                parent::__clone();
            }

            return;
        }

        $this->lazyObjectState = clone $this->lazyObjectState;

        if (isset($this->lazyObjectState->realInstance)) {
            $this->lazyObjectState->realInstance = clone $this->lazyObjectState->realInstance;
        }
    }

    
$accessor['unset']($this$name);
        }
    }

    public function __clone(): void
    {
        if ($state = $this->lazyObjectState ?? null) {
            $this->lazyObjectState = clone $state;
        }

        if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['clone']) {
            parent::__clone();
        }
    }

    public function __serialize(): array
    {
        $class = self::class;

        if ((Registry::$parentMethods[$class] ??= Registry::getParentMethods($class))['serialize']) {
            $properties = parent::__serialize();
        } else {
            $this->initializeLazyObject();
            

    public function __clone()
    {
        parent::__clone();

        if ($this->security_policy !== null) {
            $this->security_policy = clone $this->security_policy;
            $this->security_policy->smarty = $this;
        }
    }

    /** * @param string $charset * * @return Enlight_Template_Manager */
unset($instance->$name);
        } else {
            $accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope);
            $accessor['unset']($instance$name);
        }
    }

    public function __clone(): void
    {
        if (!isset($this->lazyObjectState)) {
            if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['clone']) {
                parent::__clone();
            }

            return;
        }

        $this->lazyObjectState = clone $this->lazyObjectState;

        if (isset($this->lazyObjectState->realInstance)) {
            $this->lazyObjectState->realInstance = clone $this->lazyObjectState->realInstance;
        }
    }

    

  protected function isSimpleQuery() {
    return (!$this->pager && !$this->range && !$this->count) || $this->sqlQuery->getMetaData('simple_query');
  }

  /** * Implements the magic __clone method. * * Reset fields and GROUP BY when cloning. */
  public function __clone() {
    parent::__clone();
    $this->sqlFields = [];
    $this->sqlGroupBy = [];
  }

  /** * Gets the Tables object for this query. * * @param \Drupal\Core\Database\Query\SelectInterface $sql_query * The SQL query object being built. * * @return \Drupal\Core\Entity\Query\Sql\TablesInterface * The object that adds tables and fields to the SQL query object. */
$accessor['unset']($this$name);
        }
    }

    public function __clone(): void
    {
        if ($state = $this->lazyObjectState ?? null) {
            $this->lazyObjectState = clone $state;
        }

        if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['clone']) {
            parent::__clone();
        }
    }

    public function __serialize(): array
    {
        $class = self::class;

        if ((Registry::$parentMethods[$class] ??= Registry::getParentMethods($class))['serialize']) {
            $properties = parent::__serialize();
        } else {
            $this->initializeLazyObject();
            
Home | Imprint | This part of the site doesn't use cookies.