EntityViewDisplayEditForm.php in Facebook Instant Articles 8.2
File
src/Form/EntityViewDisplayEditForm.php
View source
<?php
namespace Drupal\fb_instant_articles\Form;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\fb_instant_articles\Regions;
use Drupal\field_ui\Form\EntityViewDisplayEditForm as CoreEntityViewDisplayEditForm;
class EntityViewDisplayEditForm extends CoreEntityViewDisplayEditForm {
const FBIA_VIEW_MODE = 'fb_instant_articles';
public function getRegions() {
$regions = parent::getRegions();
if ($this
->getEntity()
->getOriginalMode() === 'fb_instant_articles') {
$new_regions[Regions::REGION_HEADER] = [
'title' => $this
->t('Header'),
'message' => $this
->t('No fields are displayed in this region.'),
];
$new_regions[Regions::REGION_CONTENT] = [
'title' => $this
->t('Body'),
'message' => $this
->t('No fields are displayed in this region.'),
];
$new_regions[Regions::REGION_FOOTER] = [
'title' => $this
->t('Footer'),
'message' => $this
->t('No fields are displayed in this region.'),
];
$new_regions['hidden'] = $regions['hidden'];
$regions = $new_regions;
}
return $regions;
}
protected function getApplicablePluginOptions(FieldDefinitionInterface $field_definition) {
$options = parent::getApplicablePluginOptions($field_definition);
if ($this
->getEntity()
->getOriginalMode() !== 'fb_instant_articles') {
foreach ($options as $key => $label) {
if (preg_match('/^fbia_/', $key)) {
unset($options[$key]);
}
}
}
return $options;
}
}