src/GridFieldDateFinder.php
public function convertDateFields()
    {
        $grid_field = $this->getGridField();
        $config = $grid_field->getConfig();
        $db = Config::inst()->get($grid_field->getModelClass(), "db");
        $dates = self::config()->date_fields;
        $fields = $this->findDateFields();

        // First setup columns
        foreach ($config->getComponents() as $component) {
            $class = get_class($component);
            $is_header = ($component instanceof GridFieldSortableHeader);
            $is_columns = ClassInfo::classImplements(
                $class,
                GridField_ColumnProvider::class
            );

            // If we are working with a set of data columns, look for
            // date/datetime columns
            if ($is_columns && method_exists($component, "getDisplayFields")) {
                $display_fields = $component->getDisplayFields($grid_field);
                foreach ($fields as $field) {
                    $display_fields = $this->changeKeys(
                        $field["Sort"],
                        $field["Column"],
                        $display_fields
                    );
                }
                $component->setDisplayFields($display_fields);
            }

            // If we are working with sortable headers, look for
            // date/datetime columns
            if ($is_header && count($component->getFieldSorting()) == 0) {
                $sort_fields = [];
                foreach ($fields as $field) {
                    $sort_fields[$field["Column"]] = $field["Sort"];
                }
                $component->setFieldSorting($sort_fields);
            }
        }

        $this->setGridField($grid_field);

        return $this;
    }
public function convertDateFields()
    {
        $grid_field = $this->getGridField();
        $config = $grid_field->getConfig();
        $db = Config::inst()->get($grid_field->getModelClass(), "db");
        $dates = self::config()->date_fields;
        $fields = $this->findDateFields();

        // First setup columns
        foreach ($config->getComponents() as $component) {
            $class = get_class($component);
            $is_header = ($component instanceof GridFieldSortableHeader);
            $is_columns = ClassInfo::classImplements(
                $class,
                GridField_ColumnProvider::class
            );

            // If we are working with a set of data columns, look for
            // date/datetime columns
            if ($is_columns && method_exists($component, "getDisplayFields")) {
                $display_fields = $component->getDisplayFields($grid_field);
                foreach ($fields as $field) {
                    $display_fields = $this->changeKeys(
                        $field["Sort"],
                        $field["Column"],
                        $display_fields
                    );
                }
                $component->setDisplayFields($display_fields);
            }

            // If we are working with sortable headers, look for
            // date/datetime columns
            if ($is_header && count($component->getFieldSorting()) == 0) {
                $sort_fields = [];
                foreach ($fields as $field) {
                    $sort_fields[$field["Column"]] = $field["Sort"];
                }
                $component->setFieldSorting($sort_fields);
            }
        }

        $this->setGridField($grid_field);

        return $this;
    }
public function convertDateFields ( ) { $ grid_field = $ this -> getGridField ( ) ; $ config = $ grid_field -> getConfig ( ) ; $ db = Config :: inst ( ) -> get ( $ grid_field -> getModelClass ( ) , "db" ) ; $ dates = self :: config ( ) -> date_fields ; $ fields = $ this -> findDateFields ( ) ; // First setup columns foreach ( $ config -> getComponents ( ) as $ component ) { $ class = get_class ( $ component ) ; $ is_header = ( $ component instanceof GridFieldSortableHeader ) ; $ is_columns = ClassInfo :: classImplements ( $ class , GridField_ColumnProvider :: class ) ; // If we are working with a set of data columns, look for // date/datetime columns if ( $ is_columns && method_exists ( $ component , "getDisplayFields" ) ) { $ display_fields = $ component -> getDisplayFields ( $ grid_field ) ; foreach ( $ fields as $ field ) { $ display_fields = $ this -> changeKeys ( $ field [ "Sort" ] , $ field [ "Column" ] , $ display_fields ) ; } $ component -> setDisplayFields ( $ display_fields ) ; } // If we are working with sortable headers, look for // date/datetime columns if ( $ is_header && count ( $ component -> getFieldSorting ( ) ) == 0 ) { $ sort_fields = [ ] ; foreach ( $ fields as $ field ) { $ sort_fields [ $ field [ "Column" ] ] = $ field [ "Sort" ] ; } $ component -> setFieldSorting ( $ sort_fields ) ; } } $ this -> setGridField ( $ grid_field ) ; return $ this ; }
Get any date fields from the passed list and convert to .Nice format.

@param GridField $field GridField want to convert

@return self
Get any date fields from the passed list and convert to . Nice format .