DefaultListFactory.php
39 lines
| 1 | <?php namespace NestedPages\Entities\DefaultList; |
| 2 | |
| 3 | use NestedPages\Entities\PostType\PostTypeRepository; |
| 4 | use NestedPages\Entities\DefaultList\NestedViewLink; |
| 5 | |
| 6 | /** |
| 7 | * Add the Nested Pages link to default table subsubsub |
| 8 | */ |
| 9 | class DefaultListFactory { |
| 10 | |
| 11 | /** |
| 12 | * Post Type Repository |
| 13 | */ |
| 14 | private $post_type_repo; |
| 15 | |
| 16 | /** |
| 17 | * Post Type |
| 18 | */ |
| 19 | private $post_type; |
| 20 | |
| 21 | |
| 22 | public function __construct() |
| 23 | { |
| 24 | $this->post_type_repo = new PostTypeRepository; |
| 25 | $this->addNestedViewLinks(); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Loop through Post Types & add link to activated types |
| 30 | */ |
| 31 | private function addNestedViewLinks() |
| 32 | { |
| 33 | foreach($this->post_type_repo->getPostTypesObject() as $type){ |
| 34 | if ( !$type->np_enabled ) continue; |
| 35 | new NestedViewLink($type); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | } |