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

use SabaiApps\Directories\Application;
use SabaiApps\Directories\Component\Field\Type\AbstractType;

class ContentCountFieldType extends AbstractType {

	protected function _fieldTypeInfo() {
		return array(
			'label'     => 'Content count',
			'creatable' => false,
		);
	}

	public function fieldTypeSchema( array $settings = array() ) {
		return array(
			'columns' => array(
				'value'        => array(
					'type'     => Application::COLUMN_INTEGER,
					'notnull'  => true,
					'unsigned' => true,
					'was'      => 'value',
					'default'  => 0,
					'length'   => 10,
				),
				'content_name' => array(
					'type'    => Application::COLUMN_VARCHAR,
					'notnull' => true,
					'length'  => 40,
					'was'     => 'content_name',
					'default' => '',
				),
				'merged'       => array(
					'type'     => Application::COLUMN_INTEGER,
					'notnull'  => true,
					'unsigned' => true,
					'was'      => 'merged',
					'default'  => 0,
					'length'   => 10,
				),
			),
			'indexes' => array(
				'value'        => array(
					'fields' => array( 'value' => array( 'sorting' => 'ascending' ) ),
					'was'    => 'value',
				),
				'merged'       => array(
					'fields' => array( 'merged' => array( 'sorting' => 'ascending' ) ),
					'was'    => 'merged',
				),
				'content_name' => array(
					'fields' => array( 'content_name' => array( 'sorting' => 'ascending' ) ),
					'was'    => 'content_name',
				),
			),
		);
	}
}
