src/ApiBundle/Api/Resource/Page/PageSettingPart.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace ApiBundle\Api\Resource\Page;
use ApiBundle\Api\ApiRequest;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use ApiBundle\Api\Exception\ErrorCode;
use ApiBundle\Api\Annotation\Access;
use AppBundle\Common\ArrayToolkit;
class PageSettingPart extends PageSetting
{
/**
* @Access(roles="ROLE_ADMIN,ROLE_SUPER_ADMIN")
*/
public function add(ApiRequest $request, $portal)
{
$mode = $request->query->get('mode');
if (!in_array($mode, array('draft', 'published'))) {
throw new BadRequestHttpException('Mode is error', null, ErrorCode::INVALID_ARGUMENT);
}
$type = $request->query->get('type');
if (!in_array($type, array('discovery'))) {
throw new BadRequestHttpException('Type is error', null, ErrorCode::INVALID_ARGUMENT);
}
if (!in_array($portal, array('h5', 'miniprogram'))) {
throw new BadRequestHttpException('Portal is error', null, ErrorCode::INVALID_ARGUMENT);
}
$content = $request->request->all();
$method = 'add'.ucfirst($type);
return $this->$method($portal, $mode, $content);
}
protected function addDiscovery($portal, $mode = 'draft', $content = array())
{
if (!empty($content)) {
$setting = $this->getSettingService()->get("{$portal}_{$mode}_discovery");
if (empty($setting)) {
$setting = $this->getH5SettingService()->getDefaultDiscovery($portal);
}
$setting = ArrayToolkit::insert($setting, 1, $content);
$this->getSettingService()->set("{$portal}_{$mode}_discovery", $setting);
}
return $this->getDiscovery($portal, $mode);
}
protected function getSettingService()
{
return $this->service('System:SettingService');
}
protected function getH5SettingService()
{
return $this->service('System:H5SettingService');
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。