protected function regionUpdate(Layout $layout, Region $region)
    {
        if ($region->isUpdated()) {

            $this
                ->db
                ->delete('ucms_layout_data')
                ->condition('layout_id', $layout->getId())
                ->condition('region', $region->getName())
                ->execute()
            ;

            $values = [];

            /* @var $item Item */
            foreach ($region as $delta => $item) {
                $values[] = [
                    $layout->getId(),
                    $region->getName(),
                    $item->getNodeId(),
                    $delta,
                    $item->getViewMode(),
                ];
            }

            if (!empty($values)) {
                $q = $this->db->insert('ucms_layout_data');
                $q->fields(['layout_id', 'region', 'nid', 'weight', 'view_mode']);
                foreach ($values as $row) {
                    $q->values($row);
                }
                $q->execute();
            }

            // And create the node references

            $region->toggleUpdateStatus(false);

            return true;
        }

        return false;
    }
protected function regionUpdate(Layout $layout, Region $region)
    {
        if ($region->isUpdated()) {

            $this
                ->db
                ->delete('ucms_layout_data')
                ->condition('layout_id', $layout->getId())
                ->condition('region', $region->getName())
                ->execute()
            ;

            $values = [];

            /* @var $item Item */
            foreach ($region as $delta => $item) {
                $values[] = [
                    $layout->getId(),
                    $region->getName(),
                    $item->getNodeId(),
                    $delta,
                    $item->getViewMode(),
                ];
            }

            if (!empty($values)) {
                $q = $this->db->insert('ucms_layout_data');
                $q->fields(['layout_id', 'region', 'nid', 'weight', 'view_mode']);
                foreach ($values as $row) {
                    $q->values($row);
                }
                $q->execute();
            }

            // And create the node references

            $region->toggleUpdateStatus(false);

            return true;
        }

        return false;
    }
protected function regionUpdate ( Layout $ layout , Region $ region ) { if ( $ region -> isUpdated ( ) ) { $ this -> db -> delete ( 'ucms_layout_data' ) -> condition ( 'layout_id' , $ layout -> getId ( ) ) -> condition ( 'region' , $ region -> getName ( ) ) -> execute ( ) ; $ values = [ ] ; /* @var $item Item */ foreach ( $ region as $ delta => $ item ) { $ values [ ] = [ $ layout -> getId ( ) , $ region -> getName ( ) , $ item -> getNodeId ( ) , $ delta , $ item -> getViewMode ( ) , ] ; } if ( ! empty ( $ values ) ) { $ q = $ this -> db -> insert ( 'ucms_layout_data' ) ; $ q -> fields ( [ 'layout_id' , 'region' , 'nid' , 'weight' , 'view_mode' ] ) ; foreach ( $ values as $ row ) { $ q -> values ( $ row ) ; } $ q -> execute ( ) ; } // And create the node references $ region -> toggleUpdateStatus ( false ) ; return true ; } return false ; }
Update a single region of a layout

You should never call this method directly.

@param Layout $layout
Layout to save
@param string $region
Set this to update only one region

@return boolean
True if the instance was saved, false if not modified
Update a single region of a layout