Get the fields to create a join with a subClass.

@param $meta
@param $value

@return string
326073
private function getSubClassFields($meta, $value)
    {
        foreach ($meta->subClasses as $subClass) {
            $delimiter = strpos($subClass, '/') > 0 ? '/' : '\\';
            $temp = explode($delimiter, $subClass);
            $tempMeta = $this->em->getClassMetadata($subClass);
            if (end($temp) == $value) {
                return [
                    'table'       => $subClass,
                    'parentField' => $meta->getIdentifierColumnNames()[0],
                    'targetField' => $tempMeta->getIdentifierColumnNames()[0],
                    'meta'        => $tempMeta,
                ];
            }
        }
    }
979781
public static function getRelationshipAsPropertyName(
        $value,
        $className,
        ReflectionClass $reflection,
        Driver $serializer
    ) {
        $methods = [];
        foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
            if (ltrim($method->class, '\\') !== ltrim($className, '\\')) {
                continue;
            }

            $name = $method->name;
            $reflectionMethod = $reflection->getMethod($name);

            if (!self::isAllowedEloquentModelFunction($name) || $reflectionMethod->getNumberOfParameters() > 0) {
                continue;
            }

            if (in_array($name, $value->getHidden(), true)) {
                continue;
            }

            try {
                $returned = $reflectionMethod->invoke($value);

                if (!(\is_object($returned) && self::isAnEloquentRelation($returned))) {
                    continue;
                }

                $relationData = $returned->getResults();

                if ($relationData instanceof Traversable) {
                    //Something traversable with Models
                    $items = [];

                    foreach ($relationData as $model) {
                        if ($model instanceof Model) {
                            $items[] = self::getModelData($serializer, $model);
                        }
                    }

                    $methods[$name] = [
                        Serializer::MAP_TYPE => 'array',
                        Serializer::SCALAR_VALUE => $items,
                    ];
                } elseif ($relationData instanceof Model) {
                    //Single element returned.
                    $methods[$name] = self::getModelData($serializer, $relationData);
                }

            } catch (ErrorException $e) {
            }
        }

        return $methods;
    }
55741
protected function extractCacheMetadata($metakey, $value) {
		if (is_array($value) || $value instanceof \ArrayObject) {
			if (!array_key_exists($metakey, $value))
				return null;
				
			return $value[$metakey];
		}
		elseif (is_object($value)) {
			if (!property_exists($value, $metakey))
				return null;
				
			return $value->$metakey;
		}
	
		return null;
	}
1100025
private function getValues($value)
    {
        if (is_array($value)) {
            $newValue = [];

            foreach ($value as $itemValue) {
                $newValue = array_merge($newValue, $this->getValues($itemValue));
            }

            return [$newValue];
        }

        $metadataFactory = $this->em->getMetadataFactory();
        $unitOfWork      = $this->em->getUnitOfWork();

        if (is_object($value) && $metadataFactory->hasMetadataFor(StaticClassNameConverter::getClass($value))) {
            $class     = $metadataFactory->getMetadataFor(get_class($value));
            $persister = $unitOfWork->getEntityPersister($class->getClassName());

            if ($class->isIdentifierComposite()) {
                $newValue = [];

                foreach ($persister->getIdentifier($value) as $innerValue) {
                    $newValue = array_merge($newValue, $this->getValues($innerValue));
                }

                return $newValue;
            }
        }

        return [$this->getIndividualValue($value)];
    }
132497
public static MetaAttribute findAttribute(MetaDataObject meta, Object value) {
		if (value == null) {
			throw new IllegalArgumentException("null as value not supported");
		}

		for (MetaAttribute attr : meta.getAttributes()) {
			if (attr.getName().equals(TYPE_ATTRIBUTE)) {
				continue;
			}
			if (attr.isDerived()) {
				// we only consider persisted classes, not derived ones like
				// "value" itself
				continue;
			}
			if (attr.getType().getImplementationClass().isAssignableFrom(value.getClass())) {
				return attr;
			}
		}
		throw new IllegalArgumentException("cannot find anyType attribute for value '" + value + '\'');
	}
1340754
public function addMeta($key, $value)
    {
        $meta = call_user_func_array("{$this->metaModel}::firstOrNew", [['key' => $key, $this->getMetaForeignKey() => $this->getKey()]]);
        $meta->value = $value;

        return $this->meta()->save($meta);
    }
1088165
private function getTypes($field, $value, ClassMetadata $class)
    {
        $property = $class->getProperty($field);
        $types    = [];

        switch (true) {
            case $property instanceof FieldMetadata:
                $types = array_merge($types, [$property->getType()]);
                break;

            case $property instanceof AssociationMetadata:
                $class = $this->em->getClassMetadata($property->getTargetEntity());

                if (! $property->isOwningSide()) {
                    $property = $class->getProperty($property->getMappedBy());
                    $class    = $this->em->getClassMetadata($property->getTargetEntity());
                }

                $joinColumns = $property instanceof ManyToManyAssociationMetadata
                    ? $property->getJoinTable()->getInverseJoinColumns()
                    : $property->getJoinColumns();

                foreach ($joinColumns as $joinColumn) {
                    /** @var JoinColumnMetadata $joinColumn */
                    $referencedColumnName = $joinColumn->getReferencedColumnName();

                    if (! $joinColumn->getType()) {
                        $joinColumn->setType(PersisterHelper::getTypeOfColumn($referencedColumnName, $class, $this->em));
                    }

                    $types[] = $joinColumn->getType();
                }

                break;

            default:
                $types[] = null;
                break;
        }

        if (is_array($value)) {
            return array_map(static function ($type) {
                return $type->getBindingType() + Connection::ARRAY_PARAM_OFFSET;
            }, $types);
        }

        return $types;
    }
1317865
public function meta(Usuario $usuario, $name, $value = null)
    {
        $repo = $this->storage->getRepository(UsuarioMeta::class);
        
        if ($value === null) {
            $metadata = $repo->get($usuario, self::ATTR_NAMESPACE, $name);
        } else {
            $metadata = $repo->set($usuario, self::ATTR_NAMESPACE, $name, $value);
        }
        
        return $metadata;
    }
583777
public function transformInput(FieldMetadata $metadata, $value) {

        $repo = $metadata->options['repository'];
        $repo = is_callable($repo) ? $repo() : $repo;

        return $repo->getReference((int)$value);
    }
926371
protected function serialization($value)
    {
        $value = parent::serialization($value);
        $data = [];

        if (!empty($value[self::META_KEY])) {
            $data[self::META_KEY] = $value[self::META_KEY];
            unset($value[self::META_KEY]);
        }

        if (!empty($value[self::LINKS])) {
            $data[self::LINKS] = $value[self::LINKS];
            unset($value[self::LINKS]);
        }

        $data = array_merge(['data' => $value], $data);

        return $data;
    }
1077520
private function compileJoinName(JoinMetadata $metadata)
    {
        return implode(' ', array_filter([
            $metadata->isNaturalJoin() ? 'NATURAL' : '',
            $this->compileJoinPrefix($metadata->getJoinType()),
            $metadata->isOuterJoin() ? 'OUTER' : '',
            $this->compileJoinSuffix($metadata->getJoinType())
        ]));
    }
1031761
public function getMetaComponents()
    {
        // Return array of Meta Data Control fields
        return [
            $this->getFieldnameToken()     => $this->generateTokenComponent(),
            $this->getFieldnameStep()      => $this->generateStepField(),
            $this->getFieldnameSteps()     => $this->generateStepsField(),
            $this->getFieldnameSubmitted() => $this->generateSubmittedField(),
            $this->getFieldnameUpload()    => $this->generateUploadField(),
        ];
    }
471047
private function getAssociationColumnName(ClassMetadata $meta, $fieldName)
    {
        $mapping = $meta->getAssociationMapping($fieldName);

        return current($mapping['joinColumnFieldNames']);
    }
298506
public function whereMeta($meta, $operator = null, $value = null)
	{
		if (null === $value) {
			$value = $operator;
			$operator = '=';
		}
		
		$metas = is_array($meta) ? $meta : array($meta => array($value, $operator));
		
		foreach ($metas as $m => $d) {
			$v = is_array($d) ? Arr::get($d, 0) : $d;
			$o = is_array($d) ? Arr::get($d, 1, '=') : '=';
			
			if (is_object($m)) {
				$this->filters[]['metas'][] = array('id' => $m->id, 'value' => $v, 'operator' => $o);
			}
			else {
				$this->filters[]['metas'][] = array('name' => $m, 'value' => $v, 'operator' => $o);
			}
		}
		
		return $this;
	}
931336
public function updateDataConfigObj( $model, $meta ) {

		$config = $model->getDataMeta( 'config' );
		$key	= $meta->key;
		$config	= !empty( $config ) ? $config : new \StdClass();

		$config->$key = $meta->value;

		$model->updateDataMeta( 'config', $config );

		$model->refresh();

		return $model;
	}
332891
public function setMeta( $value ) {
    if( !( $value instanceof JsonMeta ) ) throw new \TypeError( 'Meta must be a subclass of ' . JsonMeta::class, $value );
    else $this->_meta = $value;

    return $this;
  }
884616
private function getFieldsWithFilterTypeFromMetadata(ClassMetadata $metadata)
    {
        $mapping = array(
            'string' => 'ORM\StringFilterType',
            'text' => 'ORM\StringFilterType',
            'integer' => 'ORM\NumberFilterType',
            'smallint' => 'ORM\NumberFilterType',
            'bigint' => 'ORM\NumberFilterType',
            'decimal' => 'ORM\NumberFilterType',
            'boolean' => 'ORM\BooleanFilterType',
            'date' => 'ORM\DateFilterType',
            'datetime' => 'ORM\DateFilterType',
            'time' => 'ORM\DateFilterType',
        );

        $fields = array();

        foreach ($this->getFieldsFromMetadata($metadata) as $fieldName) {
            $type = $metadata->getTypeOfField($fieldName);
            $filterType = isset($mapping[$type]) ? $mapping[$type] : null;

            preg_match_all('/((?:^|[A-Z])[a-z]+)/', $fieldName, $matches);
            $fieldTitle = ucfirst(strtolower(implode(' ', $matches[0])));

            if (!is_null($filterType)) {
                $fields[$fieldName] = array('filterType' => $filterType, 'fieldTitle' => $fieldTitle);
            }
        }

        return $fields;
    }