public function testSetAndGetType() { $node = new PropertyNode(); $node->setType('Type'); $this->assertEquals('Type', $node->getType()); }
public function create($resource) { $className = null; if (is_string($resource)) { $className = $resource; } else { $className = $this->getClassName($resource); // ...Entity/Article } $configuration = $this->getConfiguration($className); // array(properties => array(title, teaser, ...)) if ($configuration === null) { return null; } $metadata = new Metadata(); $metadata->setBundleName($this->getBundleName($className)); $metadata->setHumanizedBundleName($this->getHumanizedBundleName($className)); $metadata->setClassName($className); $metadata->setEntityName($this->getEntityName($resource)); if ($configuration['properties']) { $properties = []; foreach ($configuration['properties'] as $property => $config) { if (is_array($config[0])) { foreach ($config[0] as $type => $options) { $propertyNode = new PropertyNode(); $propertyNode->setType($type); // type: Plain $propertyNode->setOptions($options); // weight, type $propertyNode->setProperty($property); //property: title $properties[] = $propertyNode; } } else { $propertyNode = new PropertyNode(); $propertyNode->setType($config[0]); $propertyNode->setOptions(null); $propertyNode->setProperty($property); $properties[] = $propertyNode; } } $metadata->setProperties($properties); } return $metadata; }