Taylor J
Well-known member
So now I'm having an issue with a class extension using the extension system in the acp.
I believe I have everything setup properly to create a new ThreadType but whenever it gets to the portion where it should be using my TaylorJ\Blogs\XF\ForumType\Discussion instance but instead it goes to the one that XFRM uses/created when
My TaylorJ\Blogs\ForumType\Discussion:
My class extension:
And how I'm creating the thread on BlogPost creation:
Is there something else I'm missing that needs to be added in to make it know 'blogPost' is an allowed threadType?
I believe I have everything setup properly to create a new ThreadType but whenever it gets to the portion where it should be using my TaylorJ\Blogs\XF\ForumType\Discussion instance but instead it goes to the one that XFRM uses/created when
$this->getExtraAllowedThreadTypes
from the ForumTypes abstract handler is called and fails out even though the thread type blogPost is added as allowed I still get back a phrase error saying to "please_select_valid_thread_type".My TaylorJ\Blogs\ForumType\Discussion:
PHP:
<?php
namespace TaylorJ\Blogs\XF\ForumType;
use XF\Entity\Forum;
class Discussion extends XFCP_Discussion
{
public function getExtraAllowedThreadTypes(Forum $forum): array
{
$allowed = parent::getExtraAllowedThreadTypes($forum);
$allowed[] = 'blogPost';
return $allowed;
}
public function getCreatableThreadTypes(Forum $forum): array
{
$creatable = parent::getCreatableThreadTypes($forum);
$this->removeBlogPostTypeFromList($creatable);
return $creatable;
}
public function getFilterableThreadTypes(Forum $forum): array
{
$filterable = parent::getFilterableThreadTypes($forum);
$resourceTarget = \XF::db()->fetchOne("
SELECT 1
FROM xf_option
WHERE option_id = 'taylorjBlogsBlogPostForum' AS option AND
WHERE option.option_value = ?
LIMIT 1
", $forum->node_id);
if (!$resourceTarget)
{
$this->removeBlogPostTypeFromList($filterable);
}
return $filterable;
}
protected function removeBlogPostTypeFromList(array &$list)
{
$blogPostKey = array_search('blogPost', $list);
if ($blogPostKey !== false)
{
unset($list[$blogPostKey]);
}
}
}
My class extension:
And how I'm creating the thread on BlogPost creation:
PHP:
protected function setupResourceThreadCreation(Forum $forum)
{
/** @var Creator $creator */
$creator = $this->service('XF:Thread\Creator', $forum);
$creator->setIsAutomated();
$creator->setContent($this->blogPost->getExpectedThreadTitle(), $this->getThreadMessage(), false);
$creator->setDiscussionTypeAndDataRaw('blogPost');
$thread = $creator->getThread();
$thread->discussion_state = $this->blogPost->blog_post_state;
return $creator;
}
Is there something else I'm missing that needs to be added in to make it know 'blogPost' is an allowed threadType?
Last edited: