本文整理汇总了PHP中SplSubject::getConfigServiceVerify方法的典型用法代码示例。如果您正苦于以下问题:PHP SplSubject::getConfigServiceVerify方法的具体用法?PHP SplSubject::getConfigServiceVerify怎么用?PHP SplSubject::getConfigServiceVerify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplSubject
的用法示例。
在下文中一共展示了SplSubject::getConfigServiceVerify方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* @param View|\SplSubject $subject
*/
public function update(\SplSubject $subject)
{
$viewConfig = $subject->getConfigServiceVerify()->getByObject($subject->getName(), new ViewConfig());
if ($viewConfig == null) {
throw new \Exception('Please fill ViewConfig for the ' . $subject->getName() . '. I can\'t work on');
}
$result['rowcount'] = $subject->getParam('rowcount', $viewConfig->rows);
if ($result['rowcount'] != $viewConfig->rows) {
$viewConfig->rows = $result['rowcount'];
$subject->getViewConfigVerify()->rows = $result['rowcount'];
$subject->getConfigServiceVerify()->saveByObject($viewConfig);
}
$subject->setData($result);
}
示例2: update
/**
* @param \SplSubject|View $subject
*
* @throws \Exception
*/
public function update(\SplSubject $subject)
{
$data = $subject->getParam('data', null);
$view = $subject->getParam('view', null);
if ($data == null || $view == null) {
throw new \Exception('Please specify data param');
}
$data = ucfirst($data);
$viewConfig = $subject->getConfigServiceVerify()->getByObject($data . '.' . $view, new ViewConfig());
if ($viewConfig == null) {
throw new \Exception('Please fill ViewConfig for the ' . $data . '.' . $view);
}
$this->viewViewConfig = $viewConfig;
$modelConfig = $subject->getModelServiceVerify()->getParsedModelConfig($data);
$aclData = $subject->getAclServiceVerify()->getAclConfig($data);
$fieldConfigs = ['fields' => [], 'labels' => []];
foreach ($viewConfig->fields as $field) {
if (array_key_exists($field, $modelConfig['fields'])) {
$fieldConfigs['fields'][$field] = false;
}
}
// ksort( $modelConfig['fields']);
uasort($modelConfig['fields'], function ($a, $b) {
return strcmp($a['label'], $b['label']);
});
foreach ($modelConfig['fields'] as $field => $fConfig) {
if ($fConfig['type'] == 'field') {
//check $field in acl
if (!array_key_exists($field, $aclData->fields) || !in_array($aclData->fields[$field], ['read', 'write'])) {
unset($fieldConfigs['fields'][$field]);
continue;
}
}
if ($fConfig['type'] == 'alias') {
//check $fConfig['source'] in acl
if (!array_key_exists($fConfig['source'], $aclData->fields) || !in_array($aclData->fields[$fConfig['source']], ['read', 'write'])) {
unset($fieldConfigs['fields'][$field]);
continue;
}
}
if ($fConfig['type'] == 'source') {
if ($fConfig['source'] !== $field || !array_key_exists($fConfig['source'], $aclData->fields) || !in_array($aclData->fields[$fConfig['source']], ['read', 'write'])) {
unset($fieldConfigs['fields'][$field]);
continue;
}
}
if ($fConfig['type'] == 'pk') {
continue;
}
$fieldConfigs['fields'][$field] = in_array($field, $viewConfig->fields) ? true : false;
$fieldConfigs['labels'][$field] = $fConfig['label'];
}
$result = [];
$result['fieldconfigs'] = $fieldConfigs;
$result['params'] = ['data' => $data, 'view' => $view];
$subject->setData($result);
$this->postVerify($subject);
}