Filter nested context array.

@param  array $properties
@return array
11555
protected function filterNestedContext(array $properties = [])
    {
        $func = function($value, $key) {
            return ($value && $key !== '@context');
        };

        if (!defined('ARRAY_FILTER_USE_BOTH')) {
            $return = [];
            foreach ($properties as $k => $v) {
                if (call_user_func($func, $v, $k)) {
                    $return[$k] = $v;
                }
            }

            return $return;
        }

        return array_filter($properties, $func, ARRAY_FILTER_USE_BOTH);
    }
303775
public function Field($properties = array())
    {
        $options = array();

        foreach ($this->getOptions()->filter('Selected', true) as $option) {
            $options[] = $option->Title;
        }

        $field = ReadonlyField::create($this->name . '_Readonly', $this->title);

        $field->setForm($this->form);
        $field->setValue(implode(', ', $options));
        return $field->Field();
    }
269020
public function setHeaders($headers)
    {
        $_headers = [];

        if (is_array($headers)) {
            $_headers = $headers;
        } elseif ($headers instanceof Traversable) {
            $_headers = iterator_to_array($headers);
        } else {
            $type = is_object($headers)
                ? get_class($headers) . " object"
                : "scalar " . gettype($headers);

            throw new PropertiesException ("Headers should be array or iterable, {$type} given instead");
        }

        $this->properties['headers'] = $_headers;
    }
12941
protected function buildContext(array $properties)
    {
        $items = [];

        foreach ($properties as $key => $value) {
            $items[] = [
                    'Key' => $this->sanitizeString($key),
                    'Value' => $this->sanitizeString($value),
            ];
        }

        if (!$items) {
            return [];
        }

        return ['Entry' => $items];
    }
1327689
public function flat(array $properties): string
    {
        Assert::isMap($properties);

        return $this->arrayImploder->byGlue($properties, ';', ':');
    }
105234
public function setProperties(array $properties) : DataSet
    {
        $this->properties = [];

        foreach ($properties as $key => $value) {
            $this->addProperty($key, $value);
        }

        return $this;
    }
597608
public function withProperties(array $properties): self
    {
        $query = $this;

        foreach ($properties as $property => $cypher) {
            $query = $query->withProperty($property, $cypher);
        }

        return $query;
    }
690226
public function getPropertiesValues($properties)
    {
        $returnValue = array();
        if(!is_array($properties)){
			throw new common_exception_InvalidArgumentType(__CLASS__, __FUNCTION__, 0, 'array', $properties);
        }
        $returnValue = $this->getImplementation()->getPropertiesValues($this, $properties/*, $last*/);
        return (array) $returnValue;
    }
765954
public function setProperties(array $properties) {
		foreach ($this->properties as $prop) {
			$prop->setParent(null);
		}

		$this->properties->clear();

		foreach ($properties as $prop) {
			$this->setProperty($prop);
		}

		return $this;
	}
520358
private function filterOrganizations(array $organizations)
    {
        foreach ($organizations as $organization) {
            foreach ($organizations as $childKey => $child) {
                if ($this->hasRecursiveChild($organization, $child)) {
                    unset($organizations[$childKey]);
                }
            }
        }

        return array_values($organizations);
    }
48115
protected function filterFields(array $fields): array
    {
        // get table columns, aliased
        $columns = $this->table->getSchema()->columns();
        foreach ($columns as $index => $column) {
            $columns[$index] = $this->table->aliasField($column);
        }

        // filter out virtual fields
        foreach ($fields as $index => $field) {
            if (!in_array($field, $columns)) {
                unset($fields[$index]);
            }
        }

        return $fields;
    }
407665
final public static function format_properties($properties) {
        foreach ($properties as $property => $definition) {
            // Ensures that null is set to its default.
            if (!isset($definition['null'])) {
                $properties[$property]['null'] = NULL_NOT_ALLOWED;
            }
            if (!isset($definition['description'])) {
                $properties[$property]['description'] = $property;
            }

            // If an array is provided, it may be a nested array that is unformatted so rinse and repeat.
            if (is_array($definition['type'])) {
                $properties[$property]['type'] = static::format_properties($definition['type']);
            }
        }
        return $properties;
    }
454118
protected function valProperties(array $properties)
    {
        $validatedProperties = $this->propertyListFactory->create();

        // Run through all validated properties
        foreach (array_filter(array_map([$this, 'valProp'], $properties)) as $property) {
            $validatedProperties->add($property);
        }

        return $validatedProperties;
    }
826670
protected function filterNotSavedProperties(array $properties)
    {
        foreach ($this->getMetadata()->getAttributes() as $fieldKey => $propMeta) {
            if (true === $propMeta->shouldSave() || !isset($properties[$fieldKey])) {
                continue;
            }
            unset($properties[$fieldKey]);
        }
        return $properties;
    }
381582
public function data(array $properties = null)
    {
        $data = [];
        $properties = $this->properties($properties);
        foreach ($properties as $propertyIdent => $property) {
            // Ensure objects are properly encoded.
            $val = $this->propertyValue($propertyIdent);
            $val = $this->serializedValue($val);
            $data[$propertyIdent] = $val;
        }

        return $data;
    }
748349
public function initialize(array $properties = null)
    {
        $attributes = [];
        $embedOne = [];
        $embedMany = [];

        if (null !== $properties) {
            $attributes = $this->applyDefaultAttrValues($attributes);
            foreach ($properties as $key => $value) {
                if (true === $this->isAttribute($key)) {
                    // Load attribute.
                    $attributes[$key] = $this->convertAttributeValue($key, $value);
                } else if (true === $this->isEmbedHasOne($key) && is_array($value)) {
                    // Load embed one.
                    $embedOne[$key] = $this->getStore()->loadEmbed($this->getMetadata()->getEmbed($key)->embedMeta, $value);
                }
            }
        }

        foreach ($this->getMetadata()->getEmbeds() as $key => $embeddedPropMeta) {
            // Always load embedded collections, regardless if data is set.
            if (true === $embeddedPropMeta->isOne()) {
                continue;
            }
            $embeds = !isset($properties[$key]) ? [] : $properties[$key];
            $embedMany[$key] = $this->getStore()->createEmbedCollection($embeddedPropMeta, $embeds);
        }

        $this->attributes    = (null === $this->attributes) ? new Attributes($attributes) : $this->attributes->replace($attributes);
        $this->hasOneEmbeds  = (null === $this->hasOneEmbeds) ? new Embeds\HasOne($embedOne) : $this->hasOneEmbeds->replace($embedOne);
        $this->hasManyEmbeds = (null === $this->hasManyEmbeds) ? new Embeds\HasMany($embedMany) : $this->hasManyEmbeds->replace($embedMany);

        if (true === $this->getState()->is('new')) {
            // Ensure default values are applied to new models.
            $this->apply([]);
        }

        $this->doDirtyCheck();
        return $this;
    }
366355
protected function normalizeProperties($properties)
	{
		foreach ($properties as $property => $type)
		{
			if (preg_match('/(.*?)\(\d+\).*/i', $type, $matches))
			{
				$type = $matches[1];

				$properties[$property] = $type;
			}

			switch ($type)
			{
				case 'text':
				case 'tinytext':
				case 'mediumtext':
				case 'longtext':
				case 'blob':
					$properties[$property] = 'text';
				break;

				case 'int':
				case 'integer':
				case 'smallint':
				case 'tinyint':
				case 'bigint':
				case 'mediumint':
				case 'year':
					$properties[$property] = 'integer';
				break;

				case 'datetime':
				case 'date':
				case 'timestamp':
				case 'time':
					$properties[$property] = 'date';
				break;

				case 'varchar':
				case 'char':
				default:
					$properties[$property] = 'string';
				break;
			}
		}

		return $properties;
	}