toArray

Retorna uma representação em formato de array associativo do schema

@param array $properties

@return array
429561
public function toArray($properties = null)
    {
        $array = [];

        if (!empty($this->getMeta())) {
            $array['meta'] = $this->getMeta();
        }

        if (!empty($this->getPropertyContainer())) {
            $array['properties'] = [];

            foreach ($this->getPropertyContainer()->getProperties() as $item) {
                if (method_exists(
                    $item,
                    'toArray'
                )) {
                    $array['properties'][] = $item->toArray();
                }
            }
        }
        if (!empty($this->getDatabaseContainer())) {
            $array['database'] = $this->getDatabaseContainer()->getDatabase()->toArray();
        }

        return $array;
    }
213237
protected static function getRelations(array $properties)
    {
        $relations = [];

        foreach ($properties as $property) {
            if (!is_null($relation = ForeignRelationship::get($property))) {
                $relations[] = $relation;
            }
        }

        return $relations;
    }
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();
    }
1154351
public function fill(array $properties)
    {
        foreach ($properties as $key => $value)
        {
            $this->setAttribute($key, $value);
        }

        return $this;
    }
729
public function Field($properties = array())
    {
        if ($this->value) {
            $val = Convert::raw2xml($this->value);
            $val = DBCurrency::config()->get('currency_symbol')
                . number_format(preg_replace('/[^0-9.-]/', '', $val), 2);
            $valforInput = Convert::raw2att($val);
        } else {
            $valforInput = '';
        }
        return "<input class=\"text\" type=\"text\" disabled=\"disabled\""
        . " name=\"" . $this->name . "\" value=\"" . $valforInput . "\" />";
    }
575776
public function &toArray()
    {
        if (!isset($this->__propertyToData[Schema::DEFAULT_MAPPING])) {
            return $this->__arrayOfData;
        }
        if (null === $this->__mappedProperties) {
            $properties = array();
            foreach ($this->__arrayOfData as $propertyName => $property) {
                if (isset($this->__propertyToData[Schema::DEFAULT_MAPPING][$propertyName])) {
                    $propertyName = $this->__propertyToData[Schema::DEFAULT_MAPPING][$propertyName];
                }
                $properties[$propertyName] = $property;
            }
            $this->__mappedProperties = $properties;
        }
        return $this->__mappedProperties;
    }
850925
public static function serialize(array $values): array
    {
        $serializedData = [];

        foreach ($values as $property => $value) {
            if (is_array($value)) {
                $value = self::serialize($value);
            }

            if ($value instanceof Serializable) {
                $value = $value->serialize();
            }

            $serializedData[$property] = $value;
        }

        return $serializedData;
    }
228052
public function getModels($properties = array('*'))
    {
        // First, we will simply get the raw results from the query builders which we
        // can use to populate an array with Eloquent models. We will pass columns
        // that should be selected as well, which are typically just everything.
        $results = $this->query->get($properties);

        // Once we have the results, we can spin through them and instantiate a fresh
        // model instance for each records we retrieved from the database. We will
        // also set the proper connection name for the model after we create it.
        return $this->resultsToModels($this->model->getConnectionName(), $results, $properties);
    }
701959
public function Field($properties = array())
    {
        if ($this->isReadonly()) {
            $nullableCheckbox = new CheckboxField_Readonly($this->getIsNullId());
        } else {
            $nullableCheckbox = new CheckboxField($this->getIsNullId());
        }

        $nullableCheckbox->setValue(is_null($this->dataValue()));

        return sprintf(
            '%s %s&nbsp;<span>%s</span>',
            $this->valueField->Field(),
            $nullableCheckbox->Field(),
            $this->getIsNullLabel()
        );
    }
1076522
public function toArray()
    {
        $properties = $this->properties;

        foreach ($properties as $name => $value) {
            if ($value instanceof Entity) {
                $properties[$name] = $value->toArray();
            }
        }

        return $properties;
    }
440979
protected function parseProperties(array $properties)
    {
        $parsed = [];

        foreach ($properties as $propertyString) {
            if (!mb_strpos($propertyString, ':')) {
                list($key, $value) = $this->parseBooleanShortcut($propertyString);
                $parsed[Type::camelCase($key)] = $value;
                continue;
            }


            list($key, $value) = explode(':', $propertyString, 2);


            if (!$this->isNestedShortCut($value)) {
                $parsed[Type::camelCase($key)] = $value;
                continue;
            }

            $type = $this->stringToType(trim($value, '[]'));

            $parsed[Type::camelCase($key)] = $type;
        }

        return $parsed;
    }
281365
public function load($properties = array())
    {
        $keys = $this->getIdentifyingData();

        if (empty($keys)) {
            throw new AnDomainEntityException('Trying to load an entity without any identifying data');
        }

        //prevent from creating two differne entities
        if (!$this->_persisted) {
            //if found another entity
            $entity = $this->getRepository()->find($keys, false);

            if ($entity && $entity !== $this) {
                $this->reset();

                return $entity->load($properties);
            }
        }

        settype($properties, 'array');

        if (empty($properties)) {
            //only load serializbale properties (i.e. attributes, many to one relationships)
            $properties = array();

            foreach ($this->getEntityDescription()->getProperty() as $property) {
                if ($property->isSerializable()) {
                    $properties[] = $property->getName();
                }
            }

            $keys = array_keys($this->getEntityDescription()->getIdentifyingProperties());
            $properties = array_diff($properties, $keys);
        }

        if ($this->_data->load($properties)) {
            //enttiy has been fetched for the first time
            if (!$this->_persisted) {
                $keys = $this->getIdentifyingData();
                $this->_persisted = true;
                $this->getRepository()->getSpace()->insertEntity($this, $keys);
                $this->reset();
            } else {
                //the loaded properties are no longer modified
                foreach ($properties as $property) {
                    unset($this->_modified[$property]);
                }

                //reset the element if there are no modified
                if (count($this->_modified) === 0) {
                    $this->reset();
                }
            }
        } else {
            //if a persisted entity can not be loaded then
            //it must mean the data doesn't exists in the store
            //can we assume then the data has been somehow deleted ?
            //if that's the case then we need to set the state to destroyed
            if ($this->persisted()) {
                $this->getRepository()->getSpace()->setEntityState($this, AnDomain::STATE_DESTROYED);
            } else {
                $this->reset();
            }
        }

        return $this;
    }
460983
public static function get(array $properties)
    {
        if (!array_key_exists('columns', $properties)) {
            throw new Exception('An index requires at least one column.');
        }

        $index = new Index();

        foreach ((array) $properties['columns'] as $column) {
            $index->addColumn($column);
        }

        if (array_key_exists('name', $properties) && !empty($properties['name'])) {
            $index->setName($properties['name']);
        }

        if (array_key_exists('type', $properties) && !empty($properties['type'])) {
            $index->setType($properties['type']);
        }

        return $index;
    }
827327
public function toArray()
    {
        $array = array();

        foreach($this->_data as $key=>$value)
            $array[$key] = ($value instanceof PropertyReference) ? $value->value() : $value;

        return $array;
    }
206249
public function toArray(array $keys = [], $accessLevel = \ReflectionProperty::IS_PUBLIC, $underscoreKeys = false)
    {
        $collection = [];
        $reflection = new \ReflectionObject($this);
        
        foreach ($reflection->getProperties($accessLevel) as $property) {
            
            if (empty($keys) || in_array($property->getName(), $keys, true)) {
                
                $propertyValue = $property->getValue($this);
                $propertyName = $underscoreKeys ? Inflector::underscore($property->getName()) : $property->getName();
                
                $collection[$propertyName] = ($propertyValue instanceof EntityInterface)
                    ? $propertyValue->toArray([], $accessLevel) : $propertyValue;
                
            }
        }
        
        return $collection;
    }
908974
protected function setForeignRelationFromArray(array $properties)
    {
        if (Helpers::isKeyExists($properties, 'is-foreign-relation') && !$properties['is-foreign-relation']) {
            return $this;
        }

        $relation = ForeignRelationship::predict($this->name, Helpers::getModelsPath());

        if (Helpers::isKeyExists($properties, 'foreign-relation')) {
            $relation = ForeignRelationship::get((array) $properties['foreign-relation']);

            if (!is_null($relation)) {
                $this->setOnStore($properties);
                $this->setOnUpdate($properties);
            }

        } else if (Helpers::isKeyExists($properties, 'foreign-constraint')) {
            $constraint = $this->getForeignConstraintFromArray((array) $properties);

            if (!is_null($constraint)) {
                $relation = $constraint->getForeignRelation();
            }
        }

        $this->setForeignRelation($relation);

        return $this;
    }
682220
public function sliceProperties(array $properties)
    {
        $actions = $this->internalDataListActions;
        $actions[] = ['sliceProperties', $properties];
        $data = $this->internalDataListUpdateData($this->internalDataListData, $actions);
        $className = get_class($this);
        $list = new $className();
        $class = $this->internalDataListClasses['IvoPetkov\DataListObject'];
        $tempObject = new $class();
        foreach ($data as $index => $object) {
            $object = $this->internalDataListUpdateValueIfNeeded($data, $index);
            $newObject = clone($tempObject);
            foreach ($properties as $property) {
                $newObject[$property] = isset($object->$property) ? $object->$property : null;
            }
            $list->push($newObject);
        }
        return $list;
    }