Copy an entry `object` of `class`.

@param object $object  - the entity to copy
@param array  $options - additional copy options
198578
public function copy($object, array $options = [])
    {
        $this->checkPermission('COPY', $object, [], true);
        $class = get_class($object);
        $new = new $class();

        $this->serializer->deserialize(
          $this->serializer->serialize($object),
          $new
        );

        $this->om->persist($new);

        //first event is the pre one
        if ($this->dispatch('copy', 'pre', [$object, $options, $new])) {
            //second event is the post one
            //we could use only one event afaik
            $this->dispatch('copy', 'post', [$object, $options, $new]);
        }

        $this->om->flush();

        return $new;
    }
1021341
public static function fromObject($object)
    {
        if (\is_object($object)) {
            $object = (array)$object;
        }
        if (\is_array($object)) {
            $array = [];
            foreach ($object as $key => $value) {
                $array[$key] = self::fromObject($value);
            }
        } else {
            $array = $object;
        }
        return $array;
    }
626091
public function mergeProperties($object)
    {
        $defaultValues = get_class_vars(get_class($this));
        $currentValues = get_object_vars($this);
        foreach ($object as $property => $value) {
            if ($property === '_context') {
                continue;
            }
            if ($currentValues[$property] === $defaultValues[$property]) { // Overwrite default values
                $this->$property = $value;
                continue;
            }
            if ($property === '_unmerged') {
                $this->_unmerged = array_merge($this->_unmerged, $value);
                continue;
            }
            if ($currentValues[$property] !== $value) { // New value is not the same?
                if ($defaultValues[$property] === $value) { // but is the same as the default?
                    continue; // Keep current, no notice
                }
                $identity = method_exists($object, 'identity') ? $object->identity() : get_class($object);
                $context1 = $this->_context;
                $context2 = property_exists($object, '_context') ? $object->_context : 'unknown';
                if (is_object($this->$property) && $this->$property instanceof AbstractAnnotation) {
                    $context1 = $this->$property->_context;
                }
                Logger::warning('Multiple definitions for ' . $identity . '->' . $property . "\n     Using: " . $context1 . "\n  Skipping: " . $context2);
            }
        }
    }
1209704
protected function _copyVariables($object)
    {
        // Store for _updateVariable
        $this->_copyDestinations[] = $object;

        // Extra object
        $object->escort = $this;

        foreach ($this->getContainer() as $key => $value) {
            // Prevent self referencing
            if ($value !== $object) {
                // \MUtil_Echo::r(get_class($value), $key);
                // echo get_class($value) . ' => ' . $key . '<br/>';
                $object->$key = $value;
            }
        }

        // viewRenderer is not in the container so has to be copied separately
        foreach (get_object_vars($this) as $name => $value) {
            if ('_' != $name[0]) {
                // \MUtil_Echo::r(get_class($value), $key);
                $object->$name = $value;
            }
        }
    }
273782
public function remove($object)
    {
        $this->hasUnpersistedChanges = true;
        if ($this->addedObjects->contains($object)) {
            $this->addedObjects->detach($object);
        } else {
            $this->removedObjects->attach($object);
        }
    }
920112
public function serialize($object, $options = [])
    {
        if (!$object) {
            return $object;
        }

        $data = $this->get($object)->serialize($object, $options);

        //if a serializer wants to return a stdClass, we want an array
        if (is_object($data)) {
            $data = json_decode(json_encode($data), true);
        }

        return $data;
    }
1050165
public static function setValuesToObject($object, $values = null) {
		if (! isset ( $values ))
			$values = $_POST;
		foreach ( $values as $key => $value ) {
			$accessor = "set" . ucfirst ( $key );
			if (method_exists ( $object, $accessor )) {
				$object->$accessor ( $value );
				$object->_rest [$key] = $value;
			}
		}
	}
436887
public function objectToString($object, array $options=[])
  {
    $vars = '';
    foreach(get_object_vars($object) as $k => $v){
      if ( is_scalar($v) ){
        $vars .= "\tpublic $" . $k . " = '" . addcslashes($v, '\\\'') . "';\n";
      }
      elseif ( is_array($v) || is_object($v) ){
        $vars .= "\tpublic $" . $k . " = " . $this->getArrayString((array) $v) . ";\n";
      }
    }
    
    $str = "<?php\nclass " . $options['class'] . " {\n";
    $str .= $vars;
    $str .= "}";

    if ( !isset($options['closingtag']) || $options['closingtag'] !== false ){
      $str .= "\n?>";
    }

    return $str;
  }
368378
public static function ban($object, $options = [])
	{
		$foreground = static::i('ban')->addCssClass('text-danger');
		return static::is($foreground, $object, $options);
	}
1249865
function addObject( $id, $options = 'add' )
    {
        // add the specified object to the page
        if ( isset( $this->looseObjects[$id] ) && $this->currentContents != $id )
        {
            // then it is a valid object, and it is not being added to itself
            switch ( $options )
            {
            case 'all':
                // then this object is to be added to this page (done in the next block) and
                // all future new pages.
                $this->addLooseObjects[$id] = 'all';
            case 'add':
                if ( isset( $this->objects[$this->currentContents]['onPage'] ) )
                {
                    // then the destination contents is the primary for the page
                    // (though this object is actually added to that page)
                    $this->o_page( $this->objects[$this->currentContents]['onPage'], 'content', $id );
                }
                break;
            case 'even':
                $this->addLooseObjects[$id] = 'even';
                $pageObjectId = $this->objects[$this->currentContents]['onPage'];
                if ( $this->objects[$pageObjectId]['info']['pageNum'] % 2 == 0 )
                {
                    $this->addObject( $id ); // hacky huh :)
                }
                break;
            case 'odd':
                $this->addLooseObjects[$id] = 'odd';
                $pageObjectId = $this->objects[$this->currentContents]['onPage'];
                if ( $this->objects[$pageObjectId]['info']['pageNum'] % 2 == 1 )
                {
                    $this->addObject( $id ); // hacky huh :)
                }
                break;
            case 'next':
                $this->addLooseObjects[$id] = 'all';
                break;
            case 'nexteven':
                $this->addLooseObjects[$id] = 'even';
                break;
            case 'nextodd':
                $this->addLooseObjects[$id] = 'odd';
                break;
            }
        }
    }
345852
public function remove($object)
    {
        $this
            ->objectManager
            ->remove($object);

        $this
            ->objectManager
            ->flush($object);
    }
751320
protected function prepare($object)
    {
        $this->metadata = $this->objectManager->getClassMetadata(get_class($object));
        $this->prepareStrategies();
    }
111122
private static function doDump(&$data, $object)
    {
        if (is_object($object) && static::$objectStorage->contains($object)) {
            $data = null;

            return;
        }

        if (is_object($object)) {
            static::$objectStorage->attach($object);
        }

        if (is_array($object) || $object instanceof \Traversable) {
            foreach ($object as $key => $value) {
                static::doDump($data[$key], $value);
            }
        } elseif (is_object($object)) {
            $ref = new \ReflectionObject($object);

            $properties = $ref->getProperties();

            foreach ($properties as $property) {
                $property->setAccessible(true);

                $value = $property->getValue($object);

                static::doDump($data[$property->getName()], $value);
            }
        } else {
            $data = $object;
        }
    }
780810
static function addInstance($object){
		$name = str_replace(DS,'.',get_class($object));
		self::$instance[$name] = $object;
	}
1047680
public function toObject(array $data, $object)
    {
        $className = $this->getFullClassName($object);
        $metadata = $this->metadataFactory->getMetadataForClass($className);
        $unserializedProperties = 0;
        foreach ($metadata->getProperties() as $property) {
            if (!$property->isExpose() || $this->propertySkipper->shouldSkip($property)) {
                if ($this->isMediumStrictUnserializeMode() && array_key_exists($property->getSerializedName(), $data)) {
                    throw new InvalidArgumentException(sprintf('%s extra field', $property->getSerializedName()));
                }
                continue;
            }

            if (!array_key_exists($property->getSerializedName(), $data)) {
                if ($this->isStrictUnserializeMode()) {
                    throw new InvalidArgumentException(sprintf('%s field is lost', $property->getSerializedName()));
                }
                continue;
            }
            $value = $this->handleValue($data[$property->getSerializedName()], $property, self::DIRECTION_UNSERIALIZE, $object);

            if ($value === $object) {
                throw new RecursionException(sprintf('Invalid self reference detected. %s::%s', $className, $property->getName()));
            }

            $this->involveValue($object, $property, $value);
            $unserializedProperties ++;
        }

        if ($this->isMediumStrictUnserializeMode() && $unserializedProperties !== count($data)) {
            throw new InvalidArgumentException('Wrong number of fields in the deserialized data');
        }

        return $object;
    }
85047
public static function init($object, array $options)
    {
        foreach ($options as $property => $value) {
            if (is_numeric($property)) {
                continue;
            }

            $setter = 'set' . ucfirst($property);

            // has setter
            if (method_exists($object, $setter)) {
                $object->$setter($value);
            } else {
                $object->$property = $value;
            }
        }

        return $object;
    }
1181256
private function _setFields($object, $fields)
    {
        $fields = is_array($fields) ? $fields : [];
        foreach ($fields as $sKey => $sValue) {
            $object->$sKey = oxNew('oxField', $sValue);
        }

        return $object;
    }