Inheritance: extends Model
    /**
     * @param Bundle $bundle
     * @param $property
     * @return bool
     */
    public function saveFileBased(Bundle $bundle, $property)
    {
        $xml = $bundle->exportFileBased($property);
        $xmlFile = $bundle->getPropertyFilePath($property);
        $emptyXml = '<config>
  <bundle/>
</config>';
        if ($xml == $emptyXml) {
            if ($this->localFilesystem->has($xmlFile)) {
                return $this->localFilesystem->delete($xmlFile);
            } else {
                return true;
            }
        } else {
            return $this->localFilesystem->write($xmlFile, $xml);
        }
    }
Beispiel #2
0
 /**
  * @param Bundle $bundle
  */
 public function addConfig(Bundle $bundle)
 {
     $this->configElements[$this->normalizeBundleName($bundle->getBundleName())] = $bundle;
 }
Beispiel #3
0
    /**
     * @group test
     */
    public function testRelations()
    {
        $xml = <<<EOF
<bundle>
<objects>
  <object id="User">
    <label>Test</label>
    <class>tests.store.core.user</class>
    <fields>
      <field id="id" type="number" primaryKey="true">
        <label>ID</label>
      </field>
      <field id="name" type="text">
        <label>Name</label>
      </field>
      <field id="groupMembership" type="object">
        <label>Group membership</label>
        <object>test/group</object>
        <objectRelation>nToM</objectRelation>
        <objectLabel>name</objectLabel>
      </field>
    </fields>
  </object>
  <object id="Group">
    <label>Test Group</label>
    <class>tests.store.core.group</class>
    <fields>
      <field id="id" type="number" primaryKey="true">
        <label>ID</label>
      </field>
      <field id="name" type="text">
        <label>Name</label>
      </field>
    </fields>
  </object>
</objects>
</bundle>
EOF;
        $configs = new Configs($this->getJarves());
        $this->getJarves()->setConfigs($configs);
        $bundle = new Bundle('TestBundle');
        $bundle->initialize($xml);
        $configs->addConfig($bundle);
        $configs->boot();
        $testObject = $bundle->getObject('User');
        $this->assertCount(1, $testObject->getRelations());
        $this->assertTrue($testObject->hasRelation('groupMembership'));
        $testBundle = $configs->getConfig('TestBundle');
        $this->assertCount(3, $testBundle->getObjects());
        $userGroup = $testBundle->getObject('userGroup');
        $this->assertTrue($userGroup->hasRelation('user'));
        $this->assertTrue($userGroup->hasRelation('groupMembership'));
    }
Beispiel #4
0
    /**
     * @group test
     */
    public function testFieldTypes()
    {
        $xml = <<<EOF
<bundle>
  <fieldTypes>
    <field-type id="text" service="jarves.field.types.text">
      <label>Text</label>
    </field-type>
    <field-type id="tab" service="jarves.field.types.tab" userInterfaceOnly="true">
      <label>Tab</label>
    </field-type>
  </fieldTypes>
</bundle>
EOF;
        $bundleConfig = new Bundle('MyBundle');
        $bundleConfig->initialize($xml);
        $this->assertEquals(2, count($bundleConfig->getFieldTypesArray()));
        $this->assertEquals('jarves.field.types.text', $bundleConfig->getFieldTypes()[0]->getService());
        $this->assertEquals('text', $bundleConfig->getFieldTypes()[0]->getId());
        $this->assertEquals(false, $bundleConfig->getFieldTypes()[0]->isUserInterfaceOnly());
        $this->assertEquals(true, $bundleConfig->getFieldTypes()[1]->isUserInterfaceOnly());
        $exportedXml = $bundleConfig->toXml();
        $this->assertEquals($xml, $exportedXml);
    }