mirror of
https://github.com/flarum/core.git
synced 2025-08-28 02:20:14 +02:00
Added post extender with type method, deprecated ConfigurePostTypes (#2101)
This commit is contained in:
committed by
GitHub
parent
5842dd1200
commit
cee87848fe
39
src/Extend/Post.php
Normal file
39
src/Extend/Post.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Extend;
|
||||
|
||||
use Flarum\Extension\Extension;
|
||||
use Flarum\Post\Post as PostModel;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
class Post implements ExtenderInterface
|
||||
{
|
||||
private $postTypes = [];
|
||||
|
||||
/**
|
||||
* Register a new post type. This is generally done for custom 'event posts',
|
||||
* such as those that appear when a discussion is renamed.
|
||||
*
|
||||
* @param string $postType: The ::class attribute of the custom Post type that is being added.
|
||||
*/
|
||||
public function type(string $postType)
|
||||
{
|
||||
$this->postTypes[] = $postType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function extend(Container $container, Extension $extension = null)
|
||||
{
|
||||
foreach ($this->postTypes as $postType) {
|
||||
PostModel::setModel($postType::$type, $postType);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user