getCurrent() public static method

public static getCurrent ( )
Beispiel #1
0
 /**
  * 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;
 }
Beispiel #2
0
 /**
  * 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;
 }