<?php
namespace SabaiApps\Directories\Component\Entity\FieldType;

use SabaiApps\Directories\Component\Field;
use SabaiApps\Directories\Component\Entity\Type\IEntity;

class MetaFieldType extends Field\Type\AbstractType {

	protected function _fieldTypeInfo() {
		return array(
			'label'      => __( 'Additional Settings', 'directories-pro' ),
			'admin_only' => true,
			'icon'       => 'fas fa-cog',
			'load_empty' => true,
		);
	}

	public function fieldTypeOnSaveValues( Field\IField $field, array $values, ?array $currentValues = null, array &$extraArgs = array() ) {
		$extraArgs['entity_meta'][ $field->getFieldName() ] = $values[0];
	}

	public function fieldTypeOnLoadValues( Field\IField $field, array &$values, IEntity $entity, array $allValues ) {
		// if ($this->_application->getPlatform()->hasEntityMeta($entity->getType(), $entity->getId(), $field->getFieldName())) {
		// $values = [$this->_application->getPlatform()->getEntityMeta($entity->getType(), $entity->getId(), $field->getFieldName())];
		// }
	}
}
