Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve integration with Profiler, actions & collection column types #130

Merged
merged 2 commits into from
Sep 21, 2024

Conversation

Kreyu
Copy link
Owner

@Kreyu Kreyu commented Sep 20, 2024

  • Actions created by the ActionsColumnType now contains a valid reference to their data table
  • Columns created by the CollectionColumnType now contains a valid reference to their data table, and each nested column is now named by their index (0, 1, 2, etc.) instead of generic __name__
  • Two new data table events - PRE_INITIALIZE and POST_INITIALIZE
  • Completely overhauled integration with Symfony Profiler

@Kreyu Kreyu changed the title Improve integration with Profiler Improve integration with Profiler, actions & collection column types Sep 20, 2024
@Kreyu Kreyu merged commit a5de2c3 into main Sep 21, 2024
16 checks passed
@nicodemuz
Copy link

I can't seem to use CollectionColumnType:

            ->addColumn('rifeProgramFrequencies', CollectionColumnType::class, [
                'entry_options' => [
                    'formatter' => function (RifeProgramFrequency $rifeProgramFrequency): string {
                        return $rifeProgramFrequency->getFrequency();
                    },
                ],
            ])

image

@Kreyu
Copy link
Owner Author

Kreyu commented Oct 4, 2024

I can't seem to use CollectionColumnType:

            ->addColumn('rifeProgramFrequencies', CollectionColumnType::class, [
                'entry_options' => [
                    'formatter' => function (RifeProgramFrequency $rifeProgramFrequency): string {
                        return $rifeProgramFrequency->getFrequency();
                    },
                ],
            ])

Hey @nicodemuz, try setting a property path inside the entry_options that will direct the bundle on which property should be displayed:

 ->addColumn('rifeProgramFrequencies', CollectionColumnType::class, [
     'entry_options' => [
         'property_path' => 'frequency',
     ],
 ])

Because the CollectionColumnType creates "fake" columns inside itself for each entry in the collection, the property path will default to column name, which in this case would be 0, 1, 2, etc. (index of each entry).

The formatter callback is applied on the data retrieved from the entity, so it's later in the process. Alternatively, you can use the getter instead of property path:

 ->addColumn('rifeProgramFrequencies', CollectionColumnType::class, [
     'entry_options' => [
         'getter' => function (RifeProgramFrequency $rifeProgramFrequency): string {
             return $rifeProgramFrequency->getFrequency();
         },
     ],
 ])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants