You are here

private function EasyMetaForm::init in Easymeta 8

Init function to build metas to load.

1 call to EasyMetaForm::init()
EasyMetaForm::buildForm in src/Form/EasyMetaForm.php
Implements \Drupal\Core\Form\FormInterface::buildForm().

File

src/Form/EasyMetaForm.php, line 150

Class

EasyMetaForm
Build and process meta form.

Namespace

Drupal\easymeta\Form

Code

private function init() {
  $title = new MetaType();
  $title
    ->setFieldType("textfield");
  $title
    ->setLabel(t("Title"));
  $title
    ->setName("title");
  $title
    ->setIsTitle(TRUE);
  array_push($this->metasType, $title);
  $description = new MetaType();
  $description
    ->setFieldType("textarea");
  $description
    ->setLabel(t("Description"));
  $description
    ->setName("description");
  $description
    ->setNameProperty("description");
  $description
    ->setTag("meta");
  $description
    ->setIsTitle(FALSE);
  array_push($this->metasType, $description);
  $keywords = new MetaType();
  $keywords
    ->setFieldType("textfield");
  $keywords
    ->setLabel(t("Keywords"));
  $keywords
    ->setName("keywords");
  $keywords
    ->setNameProperty("keywords");
  $keywords
    ->setTag("meta");
  $keywords
    ->setIsTitle(FALSE);
  array_push($this->metasType, $keywords);
  $moduleHandler = \Drupal::service('easymeta.meta_service');
  if ($moduleHandler
    ->getServiceMetaValue() == 1) {
    $ogtitle = new MetaType();
    $ogtitle
      ->setFieldType("textfield");
    $ogtitle
      ->setLabel(t("Og Title"));
    $ogtitle
      ->setName("og_title");
    $ogtitle
      ->setProperty("og:title");
    $ogtitle
      ->setNameProperty(NULL);
    $ogtitle
      ->setTag("meta");
    $ogtitle
      ->setIsTitle(FALSE);
    array_push($this->metasType, $ogtitle);
    $ogdescription = new MetaType();
    $ogdescription
      ->setFieldType("textarea");
    $ogdescription
      ->setLabel(t("Og description"));
    $ogdescription
      ->setName("og_description");
    $ogdescription
      ->setProperty("og:description");
    $ogdescription
      ->setTag("meta");
    $ogdescription
      ->setNameProperty(NULL);
    $ogdescription
      ->setIsTitle(FALSE);
    array_push($this->metasType, $ogdescription);
    $ogImage = new MetaType();
    $ogImage
      ->setFieldType("managed_file");
    $ogImage
      ->setLabel(t("Og Image"));
    $ogImage
      ->setName("og_image");
    $ogImage
      ->setProperty("og:image");
    $ogImage
      ->setTag("meta");
    $ogImage
      ->setNameProperty(NULL);
    $ogImage
      ->setIsTitle(FALSE);
    array_push($this->metasType, $ogImage);
  }
  return $this->metasType;
}