예제 #1
0
 public function testDifferentWorkspaces()
 {
     $this->markTestSkipped('Workspaces are not yet supported.');
     $this->getObjects()->clear('JarvesPublicationBundle:News');
     WorkspaceManager::setCurrent(0);
     $this->getObjects()->add('JarvesPublicationBundle:News', array('title' => 'News 1 in workspace live', 'lang' => 'en'));
     $this->getObjects()->add('JarvesPublicationBundle:News', array('title' => 'News 2 in workspace live', 'lang' => 'en'));
     WorkspaceManager::setCurrent(1);
     $this->getObjects()->add('JarvesPublicationBundle:News', array('title' => 'News 1 in workspace one', 'lang' => 'en'));
     $this->getObjects()->add('JarvesPublicationBundle:News', array('title' => 'News 2 in workspace one', 'lang' => 'en'));
     $this->getObjects()->add('JarvesPublicationBundle:News', array('title' => 'News 3 in workspace one', 'lang' => 'en'));
     //anything inserted and selecting works correctly?
     WorkspaceManager::setCurrent(0);
     $count = $this->getObjects()->getCount('JarvesPublicationBundle:News');
     $this->assertEquals(2, $count);
     WorkspaceManager::setCurrent(1);
     $count = $this->getObjects()->getCount('JarvesPublicationBundle:News');
     $this->assertEquals(3, $count);
     //anything inserted and selecting works correctly, also through propel directly?
     WorkspaceManager::setCurrent(0);
     $count = NewsQuery::create()->count();
     $this->assertEquals(2, $count);
     WorkspaceManager::setCurrent(1);
     $count = NewsQuery::create()->count();
     $this->assertEquals(3, $count);
 }
예제 #2
0
 public function testThroughPropel()
 {
     WorkspaceManager::setCurrent(0);
     ItemQuery::create()->deleteAll();
     ItemCategoryQuery::create()->deleteAll();
     WorkspaceManager::setCurrent(0);
     //todo
 }
예제 #3
0
파일: Propel.php 프로젝트: jarves/jarves
 /**
  * Since the core provide the pk as array('id' => 123) and not as array(123) we have to convert it for propel orm.
  *
  * @param  array $pk
  * @param  string $objectKey
  *
  * @return mixed Propel PK
  */
 public function getPropelPk($pk, $objectKey = null)
 {
     $definition = $this->getDefinition();
     if ($objectKey) {
         $definition = $this->objects->getDefinition($objectKey);
     }
     $result = [];
     foreach ($definition->getPrimaryKeyNames() as $primaryKey) {
         if (isset($pk[$primaryKey])) {
             $result[] = $pk[$primaryKey];
         }
     }
     if ($definition->getWorkspace()) {
         $result[] = isset($pk['workspaceId']) ? $pk['workspaceId'] : WorkspaceManager::getCurrent();
     }
     return 1 === count($result) ? $result[0] : $result;
 }
예제 #4
0
파일: Objects.php 프로젝트: jarves/jarves
 /**
  * Return only the primary keys of pItem as object.
  *
  * @param  string $objectKey
  * @param  array  $item
  *
  * @return string
  */
 public function getObjectPk($objectKey, $item)
 {
     $definition = $this->getDefinition($objectKey);
     $result = [];
     foreach ($definition->getPrimaryKeyNames() as $primaryKey) {
         if (isset($item[$primaryKey]) && null !== $item[$primaryKey]) {
             $result[$primaryKey] = $item[$primaryKey];
         }
     }
     if ($result && $definition->getWorkspace()) {
         $result['workspaceId'] = isset($item['workspaceId']) ? $item['workspaceId'] : WorkspaceManager::getCurrent();
     }
     return $result;
 }