Elastica\Type\Mapping::toArray PHP Method

toArray() public method

Converts the mapping to an array.
public toArray ( ) : array
return array Mapping as array
    public function toArray()
    {
        $type = $this->getType();
        if (empty($type)) {
            throw new InvalidException('Type has to be set');
        }
        return [$type->getName() => $this->_mapping];
    }

Usage Example

Example #1
0
 public function testEnableTtl()
 {
     $client = $this->_getClient();
     $index = $client->getIndex('test');
     $index->create(array(), true);
     $type = $index->getType('test');
     $mapping = new Mapping($type, array());
     $mapping->enableTtl();
     $data = $mapping->toArray();
     $this->assertTrue($data[$type->getName()]['_ttl']['enabled']);
 }
All Usage Examples Of Elastica\Type\Mapping::toArray