コード例 #1
0
ファイル: PropertyNodeTest.php プロジェクト: enhavo/enhavo
 public function testSetAndGetProperty()
 {
     $node = new PropertyNode();
     $node->setProperty('Property');
     $this->assertEquals('Property', $node->getProperty());
 }
コード例 #2
0
ファイル: MetadataFactory.php プロジェクト: enhavo/enhavo
 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;
 }