@param AbstractModel $model
@param mixed $row

@return AbstractModel
766505
public function hydrate(AbstractModel $model, $row)
    {
        if (!$row) {
            return $model;
        }

        $p = (array) get_object_vars($row);
        $reflection = new \ReflectionClass($model);
        foreach ($p as $property => $value) {
            try {
                $property = $reflection->getProperty($property);
                $property->setAccessible(true);
                $property->setValue($model, $value);
            } catch (\Exception $e) {
                $this->log(ILog::T_ERROR, $e->getMessage());
                continue;
            }
        }

        $this->hydrateRelations($model);

        return $model;
    }
509944
public function moveUp(Model\RowInterface $row)
    {
        $sibling = $this->editor->getRepository()->findSiblingRow($row, false);
        if (null === $sibling) {
            throw new InvalidOperationException(
                "The row can't be moved up as no sibling row has been found."
            );
        }

        $row->setPosition($row->getPosition() - 1);
        $sibling->setPosition($sibling->getPosition() + 1);

        $this->sortChildrenByPosition($row->getContainer(), 'rows');

        return $sibling;
    }
200327
public function hydrateRelations(AbstractModel $model)
    {
        if (!$this->queryBuilder->fetchCacheData($model)) {
            return $model;
        }
        $reflection = new \ReflectionClass($model);

        foreach ($this->queryBuilder->fetchCacheData($model)['relationList'] as $relation) {
            $injectionModel = new $relation['model']();
            try {
                $property = $reflection->getProperty($relation['target']);
            } catch (\Exception $e) {
                $this->log(ILog::T_ERROR, $e->getMessage());
                continue;
            }

            $property->setAccessible(true);

            /**
             * @todo implement dynamic mappings from doc head
             */
            if (!$this->lazyLoading) {
                $mappingProperty = $reflection->getProperty($relation['mapping_id']);
                $mappingProperty->setAccessible(true);
                $this->findOneBy($injectionModel, ['id' => $mappingProperty->getValue($model)]);
                unset($mappingProperty);
            }
            $property->setValue($model, $injectionModel);
        }

        return $model;
    }
54011
protected function evict($property, AbstractModel $model)
    {
        $key = $model->getCompositeKey();
        if (isset($this->{$property})) {
            unset($this->{$property}[$key]);
        }

        if ('models' === $property) {
            $keys = array_flip($this->modelKeyMap);
            if (isset($keys[$key])) {
                unset($keys[$key]);
                $this->modelKeyMap = array_keys($keys);
                $this->totalCount--;
            }
        }
        return $this;
    }
1151694
public function willRemove(AbstractModel $model)
    {
        $key = $model->getCompositeKey();
        return isset($this->removed[$key]);
    }
311648
public function update(AbstractModel $model, $where = null)
    {
        $datas = $model->toArrayCurrentNoPredicate();

        if ($where === null) {
            foreach ($this->tableGateway->getPrimaryKey() as $key) {
                $where[$key] = $datas[$key];
                unset($datas[$key]);
            }
        }

        return (count($datas) > 0) ?
            $this->tableGateway->update($datas, $where) : false;
    }
433319
public function mapModels($rows){
        $rst = array();
        foreach($rows as $row){
            $rst[] = $this->map($row);
        }
        
        return $rst;
    }
1192462
public function getModelNameForRow(array $row)
    {
        if (isset($row['gtf_field_type']) && ('appointment' === $row['gtf_field_type'])) {
            return self::APPOINTMENTS_NAME;
        }
        if ((! isset($row['gtf_field_type'])) && isset($row[$this->_modelField]) && $row[$this->_modelField]) {
            return $row[$this->_modelField];
        }
        return self::FIELDS_NAME;
    }
170061
public function visitRow(RowInterface $row)
    {
        $template = 'row/base.twig';

        return $this
            ->loadTemplate($template)
            ->render(
                [
                    "hash" => $row->getId(),
                    "classes" => $row->getClasses(),
                    "data" => $row->getData(),
                    "writables" => $row->getWritableBearer()->getWritables(),
                    "labels" => $row->getLabels(),
                    "highlightable" => $row->isHighlightable(),
                    "onClick" => $row->getOnClick(),
                ]
            );
    }
194155
public function hydrate(AbstractModel $object, $data = [])
    {
        if (!empty($data)) {
            foreach ($data as $k => $v) {

                if (in_array($k, $object::$properties)) {

                    $method = $this->camelize(
                        sprintf('set_%s', $k)
                    );

                    if (!is_callable([$object, $method])) {
                        throw new RuntimeException(sprintf(
                            'Trying to call method "%s" on "%s" but it does not exist or is private.',
                            $method,
                            get_class($object)
                        ));
                    } else {
                        $object->$method($v);
                    }
                }
            }
        }

        return $object;
    }
563138
public function map($row){
        $class = $this->modelClass;
        $model = new $class($this->db, $row, false);
        $model->setAttribute('table', $this->table)->setAttribute('pk', $this->pk);
        return $model;
    }
1024470
public function push(AbstractModel $model)
    {
        $this->validateAdd($model);
        if (true === $this->willAdd($model)) {
            return $this;
        }
        if (true === $this->willRemove($model)) {
            $this->evict('removed', $model);
            $this->set('models', $model);
            return $this;
        }
        if (true === $this->hasOriginal($model)) {
            return $this;
        }
        $this->set('added', $model);
        $this->set('models', $model);
        return $this;
    }
926396
public function getBuilder(AbstractModel $model): ?AbstractBuilder {
		if ($model instanceof PhpClass) {
			return $this->classBuilder;
		}

		if ($model instanceof PhpConstant) {
			return $this->constantBuilder;
		}

		if ($model instanceof PhpFunction) {
			return $this->functionBuilder;
		}

		if ($model instanceof PhpInterface) {
			return $this->interfaceBuilder;
		}

		if ($model instanceof PhpMethod) {
			return $this->methodBuilder;
		}

		if ($model instanceof PhpParameter) {
			return $this->parameterBuilder;
		}

		if ($model instanceof PhpProperty) {
			return $this->propertyBuilder;
		}

		if ($model instanceof PhpTrait) {
			return $this->traitBuilder;
		}

		return null;
	}
436369
public function createModels($rows)
    {
        $models = [];
        foreach ($rows as $row) {
            $models[] = $this->createModel($row);
        }

        return $models;
    }
1018439
private function fillModel(AbstractModel $model, array $data)
    {
        if (!$data) {
            return $model;
        }

        $reflection = new \ReflectionClass($model);
        foreach($reflection->getProperties() as $property) {
            $property->setAccessible(true);
            $property->setValue($model, $data[$property->getName()]);
            $property->setAccessible(false);
        }

        return $model;
    }
1215324
public function generateSelectForModel(AbstractModel $model, $param)
    {
        $cacheData = $this->fetchCacheData($model);
        if (isset($cacheData[self::RELATION_INDEX])) {
            $this->checkRelations($cacheData[self::RELATION_INDEX]);
        }

        /**
         * select Strategy
         */
        $strategy = new MySQLSelectStrategy(
            $cacheData[self::TABLE_DATA_INDEX],
            array_keys($param),
            $param
        );

        $strategy->setTransformer($this->paramTransformer);

        return  [
            $strategy->generateSQLStatement(),
            $param,
            self::SELECT_QUERY
        ];
    }
700534
public function buildRow(Model\RowInterface $row)
    {
        $view = new RowView();
        $attributes = $view->getAttributes()->addClass('cms-row');

        if ($this->editor->isEnabled()) {
            $container = $row->getContainer();

            $attributes
                ->setId('cms-row-' . $row->getId())
                ->setData([
                    'id'       => $row->getId(),
                    'position' => $row->getPosition(),
                    'actions'  => [
                        'add'       => !is_null($container),
                        //'edit'         => true,
                        'layout'    => true,
                        //'change_type'  => !$row->isNamed(),
                        'move_up'   => !$row->isFirst(),
                        'move_down' => !$row->isLast(),
                        'remove'    => !$row->isAlone(),
                    ],
                ]);
        }

        // Layout
        $this->editor->getLayoutAdapter()->buildRow($row, $view);

        foreach ($row->getBlocks() as $block) {
            $view->blocks[] = $this->buildBlock($block);
        }

        return $view;
    }