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

Handle cases such as 'Class.RelationName' #174

Merged
merged 2 commits into from
Nov 19, 2020
Merged

Handle cases such as 'Class.RelationName' #174

merged 2 commits into from
Nov 19, 2020

Conversation

wilr
Copy link
Owner

@wilr wilr commented Nov 19, 2020

No description provided.

@obj63mc
Copy link

obj63mc commented Nov 19, 2020

When that is used I get the following -

[Warning] strpos() expects parameter 1 to be string, array given at line 166

My actual class is like the following so there are multiple many_many types on the class. Note I just worked around this by overwriting the ImagesForSitemap function in my blog post extension.

private static $many_many = [
    'Brands' => Brand::class,
    'Products' => Product::class,
    'RelatedArticles' => BlogPost::class
];

private static $many_many_extraFields = [
    'Brands' => [
      'SortOrder' => 'Int'
  	],
	'Products' => [
      'SortOrder' => 'Int'
  	],
	'RelatedArticles' => [
      'SortOrder' => 'Int'
  	],
];

private static $belongs_to = [
    'FeedItem' => FeedItem::class
];

private static $belongs_many_many = [
    'BlogPosts' => BlogPost::class.'.RelatedArticles',
    'Events' => Event::class,
    'Promotions' => Promotion::class
];

attached are screenshots of the full error messages returned from the error stacks.

Error1
Error2
Error3
Error4

@obj63mc
Copy link

obj63mc commented Nov 19, 2020

When testing and further debugging I was able to get the following outputted when looking at what $type was -

array(3) { ["through"]=> string(35) "SilverStripe\CMS\Model\SiteTreeLink" ["from"]=> string(6) "Parent" ["to"]=> string(6) "Linked" }

@wilr
Copy link
Owner Author

wilr commented Nov 19, 2020

@obj63mc Ah yep sorry just needed to move it after the through check.

@obj63mc
Copy link

obj63mc commented Nov 19, 2020

With that last update, tested, all is working as expected now.

@wilr wilr merged commit 56b25a4 into master Nov 19, 2020
@wilr
Copy link
Owner Author

wilr commented Nov 19, 2020

Thanks!

@wilr wilr deleted the pr/172 branch November 19, 2020 20:53
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