Details
-
Improvement
-
Resolution: Obsolete
-
Medium
-
4.2.0
-
None
Description
It would be really helpful to get a new function (e.g. eZContentObjectState::fetchByFullIdentifier() or modify eZContentObjectState::fetchByIdentifier()) that returns the ID of an object state by it full id (e.g. 'ez_lock/locked' ). A possible implementation could be:
public static function fetchStateIDByIdentifier( $stateIdentifier )
{
list( $groupString, $stateString ) = explode( '/', $stateIdentifier );
$db = eZDB::instance();
$query = 'SELECT ezcobj_state.id FROM ezcobj_state, ezcobj_state_group
WHERE ezcobj_state.identifier=\ . $db->escapeString( trim( $stateString ) ). '\' AND
ezcobj_state_group.identifier=\ . $db->escapeString( trim( $groupString ) ) . '\' AND
ezcobj_state.group_id=ezcobj_state_group.id';
$result = $db->arrayQuery( $query );
if ( is_array( $result ) && count( $result) == 1 && array_key_exists( '0', $result ) && array_key_exists( 'id', $result['0'] ) )
{
return array( 'result' => $result['0']['id'] );
}
return array( 'result' => -1 );
}