本文整理汇总了PHP中Eccube\Application::json方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::json方法的具体用法?PHP Application::json怎么用?PHP Application::json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Eccube\Application
的用法示例。
在下文中一共展示了Application::json方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: imageAdd
public function imageAdd(Application $app, Request $request)
{
$images = $request->files->get('payment_register');
$filename = null;
if (isset($images['payment_image_file'])) {
$image = $images['payment_image_file'];
$extension = $image->guessExtension();
$filename = date('mdHis') . uniqid('_') . '.' . $extension;
$image->move($app['config']['image_temp_realdir'], $filename);
}
return $app->json(array('filename' => $filename), 200);
}
示例2: addImage
public function addImage(Application $app, Request $request)
{
if (!$request->isXmlHttpRequest()) {
throw new BadRequestHttpException();
}
$images = $request->files->get('admin_product');
$files = array();
if (count($images) > 0) {
foreach ($images as $img) {
foreach ($img as $image) {
//ファイルフォーマット検証
$mimeType = $image->getMimeType();
if (0 !== strpos($mimeType, 'image')) {
throw new UnsupportedMediaTypeHttpException();
}
$extension = $image->getClientOriginalExtension();
$filename = date('mdHis') . uniqid('_') . '.' . $extension;
$image->move($app['config']['image_temp_realdir'], $filename);
$files[] = $filename;
}
}
}
$event = new EventArgs(array('images' => $images, 'files' => $files), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_PRODUCT_ADD_IMAGE_COMPLETE, $event);
$files = $event->getArgument('files');
return $app->json(array('files' => $files), 200);
}
示例3: searchCustomerById
/**
* 顧客情報を検索する.
*
* @param Application $app
* @param Request $request
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function searchCustomerById(Application $app, Request $request)
{
if ($request->isXmlHttpRequest()) {
$app['monolog']->addDebug('search customer by id start.');
/** @var $Customer \Eccube\Entity\Customer */
$Customer = $app['eccube.repository.customer']->find($request->get('id'));
if (is_null($Customer)) {
$app['monolog']->addDebug('search customer by id not found.');
return $app->json(array(), 404);
}
$app['monolog']->addDebug('search customer by id found.');
$data = array('id' => $Customer->getId(), 'name01' => $Customer->getName01(), 'name02' => $Customer->getName02(), 'kana01' => $Customer->getKana01(), 'kana02' => $Customer->getKana02(), 'zip01' => $Customer->getZip01(), 'zip02' => $Customer->getZip02(), 'pref' => is_null($Customer->getPref()) ? null : $Customer->getPref()->getId(), 'addr01' => $Customer->getAddr01(), 'addr02' => $Customer->getAddr02(), 'email' => $Customer->getEmail(), 'tel01' => $Customer->getTel01(), 'tel02' => $Customer->getTel02(), 'tel03' => $Customer->getTel03(), 'fax01' => $Customer->getFax01(), 'fax02' => $Customer->getFax02(), 'fax03' => $Customer->getFax03(), 'company_name' => $Customer->getCompanyName());
return $app->json($data);
}
}
示例4: addImage
public function addImage(Application $app, Request $request)
{
$images = $request->files->get('admin_product');
$files = array();
if (count($images) > 0) {
foreach ($images as $img) {
foreach ($img as $image) {
$extension = $image->getClientOriginalExtension();
$filename = date('mdHis') . uniqid('_') . '.' . $extension;
$image->move($app['config']['image_temp_realdir'], $filename);
$files[] = $filename;
}
}
}
return $app->json(array('files' => $files), 200);
}
示例5: ajax
function ajax(Application $app, Request $request)
{
//if (! $request->isXmlHttpRequest()) {
// return "";
//}
$latestHistoryId = (int) $app['request']->get('latest');
switch ($app['request']->get('type')) {
case 'list':
if ($latestHistoryId > 0) {
$groups = $app['eccube.plugin.customer_tracker.repository.history']->getLatestHistoryGroups($latestHistoryId);
} else {
$timeRange = (int) $app['request']->get('timerange');
$groups = $app['eccube.plugin.customer_tracker.repository.history']->getGroupedHistory($timeRange);
}
// change groups to array
if ($groups) {
foreach ($groups as $key => $histories) {
$data = array();
foreach ($histories as $history) {
$data[] = $history->getDataArray();
}
$groups[$key] = $data;
}
}
return $app->json($groups);
case 'force':
if ($latestHistoryId > 0) {
$groupedHistory = $app['eccube.plugin.customer_tracker.repository.history']->getLatestHistoryGroups($latestHistoryId);
} else {
$timeRange = (int) $app['request']->get('timerange');
$groupedHistory = $app['eccube.plugin.customer_tracker.repository.history']->getGroupedHistory($timeRange);
}
if (sizeof($groupedHistory) > 0) {
$latestHistory = array_values($groupedHistory)[0][0];
}
$relations = $app['eccube.plugin.customer_tracker.repository.history']->getUriRelations($groupedHistory);
if ($latestHistory) {
$relations['latestHistoryId'] = $latestHistory->getId();
}
return $app->json($relations);
}
return "";
}
示例6: searchCustomerById
/**
* 顧客情報を検索する.
*
* @param Application $app
* @param Request $request
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function searchCustomerById(Application $app, Request $request)
{
if ($request->isXmlHttpRequest()) {
$app['monolog']->addDebug('search customer by id start.');
/** @var $Customer \Eccube\Entity\Customer */
$Customer = $app['eccube.repository.customer']->find($request->get('id'));
$event = new EventArgs(array('Customer' => $Customer), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_EDIT_SEARCH_CUSTOMER_BY_ID_INITIALIZE, $event);
if (is_null($Customer)) {
$app['monolog']->addDebug('search customer by id not found.');
return $app->json(array(), 404);
}
$app['monolog']->addDebug('search customer by id found.');
$data = array('id' => $Customer->getId(), 'name01' => $Customer->getName01(), 'name02' => $Customer->getName02(), 'kana01' => $Customer->getKana01(), 'kana02' => $Customer->getKana02(), 'zip01' => $Customer->getZip01(), 'zip02' => $Customer->getZip02(), 'pref' => is_null($Customer->getPref()) ? null : $Customer->getPref()->getId(), 'addr01' => $Customer->getAddr01(), 'addr02' => $Customer->getAddr02(), 'email' => $Customer->getEmail(), 'tel01' => $Customer->getTel01(), 'tel02' => $Customer->getTel02(), 'tel03' => $Customer->getTel03(), 'fax01' => $Customer->getFax01(), 'fax02' => $Customer->getFax02(), 'fax03' => $Customer->getFax03(), 'company_name' => $Customer->getCompanyName());
$event = new EventArgs(array('data' => $data, 'Customer' => $Customer), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_ORDER_EDIT_SEARCH_CUSTOMER_BY_ID_COMPLETE, $event);
$data = $event->getArgument('data');
return $app->json($data);
}
}
示例7: imageAdd
public function imageAdd(Application $app, Request $request)
{
if (!$request->isXmlHttpRequest()) {
throw new BadRequestHttpException();
}
$images = $request->files->get('payment_register');
$filename = null;
if (isset($images['payment_image_file'])) {
$image = $images['payment_image_file'];
//ファイルフォーマット検証
$mimeType = $image->getMimeType();
if (0 !== strpos($mimeType, 'image')) {
throw new UnsupportedMediaTypeHttpException();
}
$extension = $image->guessExtension();
$filename = date('mdHis') . uniqid('_') . '.' . $extension;
$image->move($app['config']['image_temp_realdir'], $filename);
}
$event = new EventArgs(array('images' => $images, 'filename' => $filename), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_PAYMENT_IMAGE_ADD_COMPLETE, $event);
$filename = $event->getArgument('filename');
return $app->json(array('filename' => $filename), 200);
}