Neos\ContentRepository\Domain\Model\NodeType::getDefaultValuesForProperties PHP Method

getDefaultValuesForProperties() public method

The default value is configured for each property under the "default" key.
    public function getDefaultValuesForProperties()
    {
        $this->initialize();
        if (!isset($this->fullConfiguration['properties'])) {
            return array();
        }
        $defaultValues = array();
        foreach ($this->fullConfiguration['properties'] as $propertyName => $propertyConfiguration) {
            if (isset($propertyConfiguration['defaultValue'])) {
                $type = isset($propertyConfiguration['type']) ? $propertyConfiguration['type'] : '';
                switch ($type) {
                    case 'DateTime':
                        $defaultValues[$propertyName] = new \DateTime($propertyConfiguration['defaultValue']);
                        break;
                    default:
                        $defaultValues[$propertyName] = $propertyConfiguration['defaultValue'];
                }
            }
        }
        return $defaultValues;
    }

Usage Example

 /**
  * @test
  */
 public function defaultValuesForPropertiesHandlesDateTypes()
 {
     $nodeType = new NodeType('Neos.ContentRepository:Base', array(), array('properties' => array('date' => array('type' => 'DateTime', 'defaultValue' => '2014-09-23'))));
     $this->assertEquals($nodeType->getDefaultValuesForProperties(), array('date' => new \DateTime('2014-09-23')));
 }
All Usage Examples Of Neos\ContentRepository\Domain\Model\NodeType::getDefaultValuesForProperties