You are here

class ContentTypeConfigService in Content Planner 8

Class ContentTypeConfigService.

Hierarchy

Expanded class hierarchy of ContentTypeConfigService

3 files declare their use of ContentTypeConfigService
Calendar.php in modules/content_calendar/src/Component/Calendar.php
CalendarController.php in modules/content_calendar/src/Controller/CalendarController.php
KanbanService.php in modules/content_kanban/src/KanbanService.php
1 string reference to 'ContentTypeConfigService'
content_calendar.services.yml in modules/content_calendar/content_calendar.services.yml
modules/content_calendar/content_calendar.services.yml
1 service uses ContentTypeConfigService
content_calendar.content_type_config_service in modules/content_calendar/content_calendar.services.yml
Drupal\content_calendar\ContentTypeConfigService

File

modules/content_calendar/src/ContentTypeConfigService.php, line 11

Namespace

Drupal\content_calendar
View source
class ContentTypeConfigService {

  /**
   * Drupal\Core\Config\ConfigFactoryInterface definition.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Constructs a new ContentTypeConfigService object.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * Load all config entities.
   *
   * @return \Drupal\content_calendar\Entity\ContentTypeConfig[]
   */
  public function loadAllEntities() {
    return ContentTypeConfig::loadMultiple();
  }

  /**
   * Load config entity by Content Type.
   *
   * @param string $content_type
   *
   * @return bool|\Drupal\content_calendar\Entity\ContentTypeConfig|null|static
   */
  public function loadEntityByContentType($content_type) {
    if ($entity = ContentTypeConfig::load($content_type)) {
      return $entity;
    }
    return FALSE;
  }

  /**
   * Create new config entity.
   *
   * @param string $node_type
   * @param string $label
   * @param string $color
   *
   * @return int
   */
  public function createEntity($node_type, $label, $color = '#0074bd') {
    $entity_build = [
      'id' => $node_type,
      'label' => $label,
      'color' => $color,
    ];
    $entity = ContentTypeConfig::create($entity_build);
    return $entity
      ->save();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentTypeConfigService::$configFactory protected property Drupal\Core\Config\ConfigFactoryInterface definition.
ContentTypeConfigService::createEntity public function Create new config entity.
ContentTypeConfigService::loadAllEntities public function Load all config entities.
ContentTypeConfigService::loadEntityByContentType public function Load config entity by Content Type.
ContentTypeConfigService::__construct public function Constructs a new ContentTypeConfigService object.