Example #1
0
 /**
  * Edit node source parameters.
  *
  * @param array                               $data
  * @param RZ\Roadiz\Core\Entities\NodesSources $nodeSource
  *
  * @return void
  */
 private function editNodeSource($data, NodesSources $nodeSource)
 {
     if (isset($data['title'])) {
         $nodeSource->setTitle($data['title']);
     } else {
         // empty title
         $nodeSource->setTitle("");
     }
     $fields = $nodeSource->getNode()->getNodeType()->getFields();
     foreach ($fields as $field) {
         if (isset($data[$field->getName()])) {
             $this->setValueFromFieldType($data[$field->getName()], $nodeSource, $field);
         } else {
             $this->setValueFromFieldType(null, $nodeSource, $field);
         }
     }
     $this->getService('em')->flush();
 }
Example #2
0
 /**
  *
  */
 public function testNodesSources()
 {
     $n = new Node();
     $t = new Translation();
     // Arrange
     $a = new NodesSources($n, $t);
     $a->setTitle('Test node');
     // Assert
     $this->assertNotNull($a);
 }