本文整理汇总了PHP中Roles::fromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Roles::fromArray方法的具体用法?PHP Roles::fromArray怎么用?PHP Roles::fromArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Roles
的用法示例。
在下文中一共展示了Roles::fromArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromArray
public static function fromArray($data)
{
$settings = new UserRoles();
foreach ($data as $key => $value) {
if (property_exists(get_class($settings), $key)) {
if ($key == "userRoles") {
$_tmp = new Roles();
foreach ($value as $keys => $val) {
$_tmp = Roles::fromArray($val);
$myArray[] = $_tmp;
}
$settings->{$key} = $myArray;
//var_dump($myArray);
}
}
}
// var_dump($settings);
return $settings;
}
示例2: createRole
function createRole($aData)
{
$con = Propel::getConnection(RolesPeer::DATABASE_NAME);
try {
$con->begin();
$sRolCode = $aData['ROL_CODE'];
$sRolSystem = $aData['ROL_SYSTEM'];
$status = $fields['ROL_STATUS'] = 1 ? 'ACTIVE' : 'INACTIVE';
$oCriteria = new Criteria('rbac');
$oCriteria->add(RolesPeer::ROL_CODE, $sRolCode);
$oCriteria->add(RolesPeer::ROL_SYSTEM, $sRolSystem);
$oDataset = RolesPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aRow = $oDataset->getRow();
if (is_array($aRow)) {
return $aRow;
}
if (!isset($aData['ROL_NAME'])) {
$aData['ROL_NAME'] = '';
}
$rol_name = $aData['ROL_NAME'];
unset($aData['ROL_NAME']);
$obj = new Roles();
$obj->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($obj->validate()) {
$result = $obj->save();
$con->commit();
$obj->setRolName($rol_name);
G::auditLog("CreateRole", "Role Name: " . $rol_name . " - Role Code: " . $aData['ROL_CODE'] . " - Role Status: " . $status);
} else {
$e = new Exception("Failed Validation in class " . get_class($this) . ".");
$e->aValidationFailures = $this->getValidationFailures();
throw $e;
}
return $result;
} catch (exception $e) {
$con->rollback();
throw $e;
}
}