Transforms ExtJS values to be suitable for storing them

@param \stdClass $entry Entry object from ExtJS
@return \stdClass Modified object
517075
protected function transformValues( \stdClass $entry )
	{
		if( isset( $entry->{'coupon.code.datestart'} ) ) {
			$entry->{'coupon.code.datestart'} = str_replace( 'T', ' ', $entry->{'coupon.code.datestart'} );
		}

		if( isset( $entry->{'coupon.code.dateend'} ) ) {
			$entry->{'coupon.code.dateend'} = str_replace( 'T', ' ', $entry->{'coupon.code.dateend'} );
		}

		return $entry;
	}
749609
protected function _createItem( array $entry )
	{
		$item = $this->_manager->createItem();

		foreach( $entry as $name => $value )
		{
			switch( $name )
			{
				case 'job.id': $item->setId( $value ); break;
				case 'job.label': $item->setLabel( $value ); break;
				case 'job.method': $item->setMethod( $value ); break;
				case 'job.status': $item->setStatus( $value ); break;
				case 'job.parameter':
					if( is_string( $value ) ) {
						$item->setParameter( json_decode( $value, true ) );
					} else {
						$item->setParameter( (array) $value );
					}
					break;
				case 'job.result':
					if( is_string( $value ) ) {
						$item->setResult( json_decode( $value, true ) );
					} else {
						$item->setResult( (array) $value );
					}
					break;
			}
		}

		return $item;
	}
342897
public function transform($value)
    {
        $transitions = array();

        foreach ($value as $transition) {
            $transitions[] = $this->generateTransitionName($transition->getStatusFrom(), $transition->getStatusTo());
        }

        return $transitions;
    }
582504
public function parse(&$entry)
    {
        foreach ($this->types as $type => $attr) {
            // initialize map type to entry
            $type_var          = '_' . $attr;
            $this->{$type_var} = array();

            // get values for this type
            if ($entry->exists($attr)) {
                $values = $entry->getValue($attr);
                if (is_array($values)) {
                    foreach ($values as $value) {

                        unset($schema_entry); // this was a real mess without it

                        // get the schema entry
                        $schema_entry = $this->_parse_entry($value);

                        // set the type
                        $schema_entry['type'] = $type;

                        // save a ref in $_oids
                        $this->_oids[$schema_entry['oid']] = &$schema_entry;

                        // save refs for all names in type map
                        $names = $schema_entry['aliases'];
                        array_push($names, $schema_entry['name']);
                        foreach ($names as $name) {
                            $this->{$type_var}[strtolower($name)] = &$schema_entry;
                        }
                    }
                }
            }
        }
        $this->_initialized = true;
    }
223029
public function set($key, $value)
    {
        if (null === $value) {
            return $this->remove($key);
        }
        $this->clearRemoval($key);

        $original = $this->getOriginal($key);

        if ($value instanceof \stdClass && $original instanceof \stdClass) {
            if ($value == $original) {
                $this->clearChange($key);
            } else {
                $this->current[$key] = $value;
            }
            return $this;
        }

        if ($value === $original) {
            $this->clearChange($key);
        } else {
            if (($value instanceof \DateTime && $original instanceof \DateTime) && ($value->getTimestamp() === $original->getTimestamp())) {
                $this->clearChange($key);
            } else {
                $this->current[$key] = $value;
            }
        }
        return $this;
    }
321436
public function transform($value)
    {
        /* @var \Twig_Template $template */
        $template = $this->twig->loadTemplate($this->resource);
        $variables = array_replace($this->variables, ['data' => $value]);

        if (null !== $this->blockname) {
            $value = $template->renderBlock($this->blockname, $variables);
        } else {
            $value = $template->render($variables);
        }

        return $value;
    }
995731
private function projectEntry(Entry $entry)
    {
        $date = $entry->getDateCreated();
        if ($date) {
            yield 'ccm_date_created' => $this->dateFormatter->formatCustom(\DateTime::ATOM, $date);
        } else {
            yield 'ccm_date_created' => null;
        }

        $attributes = $entry->getAttributes();
        foreach ($attributes as $attribute) {
            yield $attribute->getAttributeKey()->getAttributeKeyHandle() => $attribute->getPlainTextValue();
        }
    }
193419
public function characteristicsCreateItem($entry) {
    $insert = $this->connection->insert('site_commerce_characteristics_item')->fields($entry);
    return $insert->execute();
  }
603295
protected function _createItem( array $entry )
	{
		$item = $this->_manager->createItem();

		foreach( $entry as $name => $value )
		{
			switch( $name )
			{
				case 'product.tag.id': $item->setId( $value ); break;
				case 'product.tag.label': $item->setLabel( $value ); break;
				case 'product.tag.typeid': $item->setTypeId( $value ); break;
				case 'product.tag.languageid':
					if( $value != '' ) {
						$item->setLanguageId( $value );
					}
					break;
			}
		}

		return $item;
	}
56845
public function reverseTransform($value)
    {  
        if (empty($value)){
            return new ArrayCollection();
        }
        
        if ($this->collection instanceof PersistentCollection){
            foreach ($this->collection as $item){
                $this->om->remove($item);
            }  
            
            $this->collection->clear();
        }

        $data =  explode(',', $value);
        $referenceClass = $this->referenceClass;
        $setInversedProperty = sprintf('set%s', ucfirst($this->inversedProperty));
        
        foreach ($data as $idx => $id){
            $inversedObject = $this->om->getReference($this->inversedClass, (int) $id);
            $referenceObject = new $referenceClass();
            $referenceObject->{$setInversedProperty}($inversedObject);
            $referenceObject->setPosition($idx);
            $this->collection->add($referenceObject);  
        }
        
        return $this->collection;
    }
1288739
protected function castToStdClass($value)
    {
        if (is_object($value) && !$value instanceof \stdClass) {
            $value = get_object_vars($value);
        }

        return $this->castToObject($value);
    }
1301872
protected function normalizeValue($value)
    {
        if (false === $value) {
            return $value;
        }

        $value = $this->remapXml($value);

        $isAssoc = array_keys($value) !== range(0, \count($value) - 1);
        $normalized = [];
        foreach ($value as $k => $v) {
            if (null !== $this->keyAttribute && \is_array($v)) {
                if (!isset($v[$this->keyAttribute]) && \is_int($k) && !$isAssoc) {
                    $ex = new InvalidConfigurationException(sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath()));
                    $ex->setPath($this->getPath());

                    throw $ex;
                } elseif (isset($v[$this->keyAttribute])) {
                    $k = $v[$this->keyAttribute];

                    // remove the key attribute when required
                    if ($this->removeKeyAttribute) {
                        unset($v[$this->keyAttribute]);
                    }

                    // if only "value" is left
                    if (array_keys($v) === ['value']) {
                        $v = $v['value'];
                        if ($this->prototype instanceof ArrayNode && ($children = $this->prototype->getChildren()) && \array_key_exists('value', $children)) {
                            $valuePrototype = current($this->valuePrototypes) ?: clone $children['value'];
                            $valuePrototype->parent = $this;
                            $originalClosures = $this->prototype->normalizationClosures;
                            if (\is_array($originalClosures)) {
                                $valuePrototypeClosures = $valuePrototype->normalizationClosures;
                                $valuePrototype->normalizationClosures = \is_array($valuePrototypeClosures) ? array_merge($originalClosures, $valuePrototypeClosures) : $originalClosures;
                            }
                            $this->valuePrototypes[$k] = $valuePrototype;
                        }
                    }
                }

                if (\array_key_exists($k, $normalized)) {
                    $ex = new DuplicateKeyException(sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath()));
                    $ex->setPath($this->getPath());

                    throw $ex;
                }
            }

            $prototype = $this->getPrototypeForChild($k);
            if (null !== $this->keyAttribute || $isAssoc) {
                $normalized[$k] = $prototype->normalize($v);
            } else {
                $normalized[] = $prototype->normalize($v);
            }
        }

        return $normalized;
    }
434103
public function getSectionOfEntry( $entry )
	{
		foreach( $this->getSections() as $section )
			if( in_array( $entry, $this->list[$section] ) )
				return $section;
		throw new InvalidArgumentException( 'Entry "'.$entry.'" not found in any Section.' );
	}
145651
protected function getPropertiesFromAtomEntry(Entry $entry)
    {
        $result = [];
        $content = $entry->getContent();
        if (!empty($content)) {
            $result = ContentPropertiesSerializer::unserialize(
                $content->getXml()->children(Resources::DSM_XML_NAMESPACE)
            );
        }

        return $result;
    }
699502
protected function _createItem( array $entry )
	{
		$item = $this->_manager->createItem();

		foreach( $entry as $name => $value )
		{
			switch( $name )
			{
				case 'locale.id': $item->setId( $value ); break;
				case 'locale.siteid': $item->setSiteId( $value ); break;
				case 'locale.languageid': $item->setLanguageId( $value ); break;
				case 'locale.currencyid': $item->setCurrencyId( $value ); break;
				case 'locale.position': $item->setPosition( $value ); break;
				case 'locale.status': $item->setStatus( $value ); break;
			}
		}

		return $item;
	}
1139999
public function getTransformedValue($value)
    {
        if(is_scalar($value) || (is_object($value) && method_exists($value, '__toString'))) {
            foreach($this->regex as $regex => $replace) {

                if(preg_match($regex, (string)$value))
                    return preg_replace($regex, $replace, $value);
            }
        }

       return $value;
    }
362922
protected function removeValuesFromEntry(array $entry, $values)
    {
        foreach ($values as $value) {
            if (isset($entry[$value])) {
                unset($entry[$value]);
            }
        }

        return $entry;
    }