本文整理汇总了PHP中Eccube\Application::form方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::form方法的具体用法?PHP Application::form怎么用?PHP Application::form使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Eccube\Application
的用法示例。
在下文中一共展示了Application::form方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* テンプレート一覧画面
*
* @param Application $app
* @param Request $request
*/
public function index(Application $app, Request $request)
{
$DeviceType = $app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
$Templates = $app['eccube.repository.template']->findBy(array('DeviceType' => $DeviceType));
$form = $app->form()->add('selected', 'hidden')->getForm();
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
$Template = $app['eccube.repository.template']->find($form['selected']->getData());
// path.(yml|php)の再構築
$file = $app['config']['root_dir'] . '/app/config/eccube/path';
if (file_exists($file . '.php')) {
$config = (require $file . '.php');
} elseif (file_exists($file . '.yml')) {
$config = Yaml::parse(file_get_contents($file . '.yml'));
}
$templateCode = $Template->getCode();
$config['template_code'] = $templateCode;
$config['template_realdir'] = $config['root_dir'] . '/app/template/' . $templateCode;
$config['template_html_realdir'] = $config['public_path_realdir'] . '/template/' . $templateCode;
$config['front_urlpath'] = $config['root_urlpath'] . RELATIVE_PUBLIC_DIR_PATH . '/template/' . $templateCode;
$config['block_realdir'] = $config['template_realdir'] . '/Block';
if (file_exists($file . '.php')) {
file_put_contents($file . '.php', sprintf('<?php return %s', var_export($config, true)) . ';');
}
if (file_exists($file . '.yml')) {
file_put_contents($file . '.yml', Yaml::dump($config));
}
$app->addSuccess('admin.content.template.save.complete', 'admin');
return $app->redirect($app->url('admin_store_template'));
}
}
return $app->render('Store/template.twig', array('form' => $form->createView(), 'Templates' => $Templates));
}
示例2: index
/**
* テンプレート一覧画面
*
* @param Application $app
* @param Request $request
*/
public function index(Application $app, Request $request)
{
$DeviceType = $app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
$Templates = $app['eccube.repository.template']->findBy(array('DeviceType' => $DeviceType));
$form = $app->form()->add('selected', 'hidden')->getForm();
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
$Template = $app['eccube.repository.template']->find($form['selected']->getData());
// path.ymlの再構築
$file = $app['config']['root_dir'] . '/app/config/eccube/path.yml';
$config = Yaml::parse($file);
$templateCode = $Template->getCode();
$config['template_code'] = $templateCode;
$config['template_realdir'] = $config['root_dir'] . '/app/template/' . $templateCode;
$config['template_html_realdir'] = $config['root_dir'] . '/html/template/' . $templateCode;
$config['front_urlpath'] = $config['root_urlpath'] . '/template/' . $templateCode;
$config['block_realdir'] = $config['template_realdir'] . '/Block';
file_put_contents($file, Yaml::dump($config));
$app->addSuccess('admin.content.template.save.complete', 'admin');
return $app->redirect($app->url('admin_store_template'));
}
}
return $app->render('Store/template.twig', array('form' => $form->createView(), 'Templates' => $Templates));
}
示例3: index
/**
* 退会画面.
*
* @param Application $app
* @param Request $request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
public function index(Application $app, Request $request)
{
$builder = $app->form();
$event = new EventArgs(array('builder' => $builder), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_INITIALIZE, $event);
$form = $builder->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
switch ($request->get('mode')) {
case 'confirm':
return $app->render('Mypage/withdraw_confirm.twig', array('form' => $form->createView()));
case 'complete':
/* @var $Customer \Eccube\Entity\Customer */
$Customer = $app->user();
// 会員削除
$email = $Customer->getEmail();
// メールアドレスにダミーをセット
$Customer->setEmail(Str::random(60) . '@dummy.dummy');
$Customer->setDelFlg(Constant::ENABLED);
$app['orm.em']->flush();
$event = new EventArgs(array('form' => $form, 'Customer' => $Customer), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_COMPLETE, $event);
// メール送信
$app['eccube.service.mail']->sendCustomerWithdrawMail($Customer, $email);
// ログアウト
$this->getSecurity($app)->setToken(null);
return $app->redirect($app->url('mypage_withdraw_complete'));
}
}
return $app->render('Mypage/withdraw.twig', array('form' => $form->createView()));
}
示例4: index
/**
* Index
*
* @param Application $app
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function index(Application $app, Request $request)
{
/* @var $form \Symfony\Component\Form\FormInterface */
$form = $app->form()->getForm();
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
switch ($request->get('mode')) {
case 'confirm':
return $app->renderView('Mypage/withdraw_confirm.twig', array('form' => $form->createView()));
case 'complete':
/* @var $Customer \Eccube\Entity\Customer */
$Customer = $app->user();
// 会員削除
$email = $Customer->getEmail();
// メールアドレスにダミーをセット
$Customer->setEmail(Str::random(60) . '@dummy.dummy');
$Customer->setDelFlg(Constant::ENABLED);
$app['orm.em']->flush();
// メール送信
$app['eccube.service.mail']->sendCustomerWithdrawMail($Customer, $email);
// ログアウト
$this->getSecurity($app)->setToken(null);
return $app->redirect($app->url('mypage_withdraw_complete'));
}
}
}
return $app->renderView('Mypage/withdraw.twig', array('form' => $form->createView()));
}
示例5: index
/**
* 新着情報一覧を表示する。
*
* @param Application $app
* @return \Symfony\Component\HttpFoundation\Response
*/
public function index(Application $app, Request $request)
{
$NewsList = $app['eccube.repository.news']->findBy(array(), array('rank' => 'DESC'));
$builder = $app->form();
$event = new EventArgs(array('builder' => $builder, 'NewsList' => $NewsList), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CONTENT_NEWS_INDEX_INITIALIZE, $event);
$form = $builder->getForm();
return $app->render('Content/news.twig', array('form' => $form->createView(), 'NewsList' => $NewsList));
}
示例6: index
public function index(Application $app, Request $request, $id = CsvType::CSV_TYPE_ORDER)
{
$CsvType = $app['eccube.repository.master.csv_type']->find($id);
if (is_null($CsvType)) {
throw new NotFoundHttpException();
}
$builder = $app->form();
$builder->add('csv_type', 'csv_type', array('label' => 'CSV出力項目', 'required' => true, 'constraints' => array(new Assert\NotBlank()), 'data' => $CsvType));
$CsvNotOutput = $app['eccube.repository.csv']->findBy(array('CsvType' => $CsvType, 'enable_flg' => Constant::DISABLED), array('rank' => 'ASC'));
$builder->add('csv_not_output', 'entity', array('class' => 'Eccube\\Entity\\Csv', 'property' => 'disp_name', 'required' => false, 'expanded' => false, 'multiple' => true, 'choices' => $CsvNotOutput));
$CsvOutput = $app['eccube.repository.csv']->findBy(array('CsvType' => $CsvType, 'enable_flg' => Constant::ENABLED), array('rank' => 'ASC'));
$builder->add('csv_output', 'entity', array('class' => 'Eccube\\Entity\\Csv', 'property' => 'disp_name', 'required' => false, 'expanded' => false, 'multiple' => true, 'choices' => $CsvOutput));
$event = new EventArgs(array('builder' => $builder, 'CsvOutput' => $CsvOutput, 'CsvType' => $CsvType), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_CSV_INDEX_INITIALIZE, $event);
$form = $builder->getForm();
if ('POST' === $request->getMethod()) {
$data = $request->get('form');
if (isset($data['csv_not_output'])) {
$Csvs = $data['csv_not_output'];
$rank = 1;
foreach ($Csvs as $csv) {
$c = $app['eccube.repository.csv']->find($csv);
$c->setRank($rank);
$c->setEnableFlg(Constant::DISABLED);
$rank++;
}
}
if (isset($data['csv_output'])) {
$Csvs = $data['csv_output'];
$rank = 1;
foreach ($Csvs as $csv) {
$c = $app['eccube.repository.csv']->find($csv);
$c->setRank($rank);
$c->setEnableFlg(Constant::ENABLED);
$rank++;
}
}
$app['orm.em']->flush();
$event = new EventArgs(array('form' => $form, 'CsvOutput' => $CsvOutput, 'CsvType' => $CsvType), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_CSV_INDEX_COMPLETE, $event);
$app->addSuccess('admin.shop.csv.save.complete', 'admin');
return $app->redirect($app->url('admin_setting_shop_csv', array('id' => $id)));
}
return $app->render('Setting/Shop/csv.twig', array('form' => $form->createView(), 'id' => $id));
}
示例7: index
public function index(Application $app, Request $request)
{
$form = $app->form()->getForm();
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
switch ($request->get('mode')) {
case 'twig':
// Twigキャッシュクリア
Cache::clear($app, false, true);
$app->addSuccess('admin.content.twig.cache.save.complete', 'admin');
break;
default:
break;
}
}
}
return $app->render('Content/cache.twig', array('form' => $form->createView()));
}
示例8: index
public function index(Application $app, Request $request)
{
$AuthorityRoles = $app['eccube.repository.authority_role']->findAllSort();
$form = $app->form()->add('AuthorityRoles', 'collection', array('type' => 'admin_authority_role', 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'data' => $AuthorityRoles))->getForm();
if (count($AuthorityRoles) == 0) {
// 1件もない場合、空行を追加
$form->get('AuthorityRoles')->add(uniqid(), 'admin_authority_role');
}
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
$data = $form->getData();
foreach ($AuthorityRoles as $AuthorityRole) {
$app['orm.em']->remove($AuthorityRole);
}
foreach ($data['AuthorityRoles'] as $AuthorityRole) {
$Authority = $AuthorityRole->getAuthority();
$denyUrl = $AuthorityRole->getDenyUrl();
if ($Authority && !empty($denyUrl)) {
$app['orm.em']->persist($AuthorityRole);
} else {
$id = $AuthorityRole->getId();
if (!empty($id)) {
$role = $app['eccube.repository.authority_role']->find($id);
if ($role) {
// 削除
$app['orm.em']->remove($AuthorityRole);
}
}
}
}
$app['orm.em']->flush();
$app->addSuccess('admin.sysmte.authority.save.complete', 'admin');
return $app->redirect($app->url('admin_setting_system_authority'));
}
}
return $app->render('Setting/System/authority.twig', array('form' => $form->createView()));
}
示例9: index
public function index(Application $app)
{
$Members = $app['eccube.repository.member']->findBy(array(), array('rank' => 'DESC'));
$form = $app->form()->getForm();
return $app->render('Setting/System/member.twig', array('form' => $form->createView(), 'Members' => $Members));
}
示例10: authenticationSetting
/**
* 認証キー設定画面
*
* @param Application $app
* @param Request $request
*/
public function authenticationSetting(Application $app, Request $request)
{
$form = $app->form()->getForm();
$BaseInfo = $app['eccube.repository.base_info']->get();
// 認証キーの取得
$form->add('authentication_key', 'text', array('label' => '認証キー', 'constraints' => array(new Assert\Regex(array('pattern' => "/^[0-9a-zA-Z]+\$/"))), 'data' => $BaseInfo->getAuthenticationKey()));
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
$data = $form->getData();
// 認証キーの登録
$BaseInfo->setAuthenticationKey($data['authentication_key']);
$app['orm.em']->flush($BaseInfo);
$app->addSuccess('admin.plugin.authentication.setting.complete', 'admin');
}
}
return $app->render('Store/authentication_setting.twig', array('form' => $form->createView()));
}
示例11: shippingMultiple
/**
* 複数配送処理
*/
public function shippingMultiple(Application $app, Request $request)
{
$cartService = $app['eccube.service.cart'];
// カートチェック
if (!$cartService->isLocked()) {
// カートが存在しない、カートがロックされていない時はエラー
return $app->redirect($app->url('cart'));
}
// カートチェック
if (count($cartService->getCart()->getCartItems()) <= 0) {
// カートが存在しない時はエラー
return $app->redirect($app->url('cart'));
}
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']);
if (!$Order) {
$app->addError('front.shopping.order.error');
return $app->redirect($app->url('shopping_error'));
}
// 複数配送時は商品毎でお届け先を設定する為、商品をまとめた数量を設定
$compItemQuantities = array();
foreach ($Order->getShippings() as $Shipping) {
foreach ($Shipping->getShipmentItems() as $ShipmentItem) {
$itemId = $ShipmentItem->getProductClass()->getId();
$quantity = $ShipmentItem->getQuantity();
if (array_key_exists($itemId, $compItemQuantities)) {
$compItemQuantities[$itemId] = $compItemQuantities[$itemId] + $quantity;
} else {
$compItemQuantities[$itemId] = $quantity;
}
}
}
// 商品に紐づく商品情報を取得
$shipmentItems = array();
$productClassIds = array();
foreach ($Order->getShippings() as $Shipping) {
foreach ($Shipping->getShipmentItems() as $ShipmentItem) {
if (!in_array($ShipmentItem->getProductClass()->getId(), $productClassIds)) {
$shipmentItems[] = $ShipmentItem;
}
$productClassIds[] = $ShipmentItem->getProductClass()->getId();
}
}
$form = $app->form()->getForm();
$form->add('shipping_multiple', 'collection', array('type' => 'shipping_multiple', 'data' => $shipmentItems, 'allow_add' => true, 'allow_delete' => true));
$form->handleRequest($request);
$errors = array();
if ($form->isSubmitted() && $form->isValid()) {
$data = $form['shipping_multiple'];
// 数量が超えていないか、同一でないとエラー
$itemQuantities = array();
foreach ($data as $mulitples) {
/** @var \Eccube\Entity\ShipmentItem $multipleItem */
$multipleItem = $mulitples->getData();
foreach ($mulitples as $items) {
foreach ($items as $item) {
$quantity = $item['quantity']->getData();
$itemId = $multipleItem->getProductClass()->getId();
if (array_key_exists($itemId, $itemQuantities)) {
$itemQuantities[$itemId] = $itemQuantities[$itemId] + $quantity;
} else {
$itemQuantities[$itemId] = $quantity;
}
}
}
}
foreach ($compItemQuantities as $key => $value) {
if (array_key_exists($key, $itemQuantities)) {
if ($itemQuantities[$key] != $value) {
$errors[] = array('message' => '数量の数が異なっています。');
// 対象がなければエラー
return $app->render('Shopping/shipping_multiple.twig', array('form' => $form->createView(), 'shipmentItems' => $shipmentItems, 'compItemQuantities' => $compItemQuantities, 'errors' => $errors));
}
}
}
// お届け先情報をdelete/insert
$shippings = $Order->getShippings();
foreach ($shippings as $Shipping) {
$Order->removeShipping($Shipping);
$app['orm.em']->remove($Shipping);
}
foreach ($data as $mulitples) {
/** @var \Eccube\Entity\ShipmentItem $multipleItem */
$multipleItem = $mulitples->getData();
foreach ($mulitples as $items) {
foreach ($items as $item) {
// 追加された配送先情報を作成
$Delivery = $multipleItem->getShipping()->getDelivery();
// 選択された情報を取得
$data = $item['customer_address']->getData();
if ($data instanceof CustomerAddress) {
// 会員の場合、CustomerAddressオブジェクトを取得
$CustomerAddress = $data;
} else {
// 非会員の場合、選択されたindexが取得される
$customerAddresses = $app['session']->get($this->sessionCustomerAddressKey);
$customerAddresses = unserialize($customerAddresses);
$CustomerAddress = $customerAddresses[$data];
//.........这里部分代码省略.........
示例12: edit
/**
* 商品規格の登録、更新、削除を行う
*/
public function edit(Application $app, Request $request, $id)
{
/** @var $Product \Eccube\Entity\Product */
$Product = $app['eccube.repository.product']->find($id);
if (!$Product) {
throw new NotFoundHttpException();
}
$form = $app->form()->add('product_classes', 'collection', array('type' => 'admin_product_class', 'allow_add' => true, 'allow_delete' => true))->getForm();
$ProductClasses = $this->getProductClassesExcludeNonClass($Product);
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
switch ($request->get('mode')) {
case 'edit':
// 新規登録
if (count($ProductClasses) > 0) {
// 既に登録されていれば最初の画面に戻す
return $app->redirect($app->url('admin_product_product_class', array('id' => $id)));
}
$addProductClasses = array();
$tmpProductClass = null;
foreach ($form->get('product_classes') as $formData) {
// 追加対象の行をvalidate
$ProductClass = $formData->getData();
if ($ProductClass->getAdd()) {
if ($formData->isValid()) {
$addProductClasses[] = $ProductClass;
} else {
// 対象行のエラー
return $this->render($app, $Product, $ProductClass, true, $form);
}
}
$tmpProductClass = $ProductClass;
}
if (count($addProductClasses) == 0) {
// 対象がなければエラー
$error = array('message' => '商品規格が選択されていません。');
return $this->render($app, $Product, $tmpProductClass, true, $form, $error);
}
// 選択された商品規格を登録
$this->insertProductClass($app, $Product, $addProductClasses);
// デフォルトの商品規格を更新
$defaultProductClass = $app['eccube.repository.product_class']->findOneBy(array('Product' => $Product, 'ClassCategory1' => null, 'ClassCategory2' => null));
$defaultProductClass->setDelFlg(Constant::ENABLED);
$app['orm.em']->flush();
$app->addSuccess('admin.product.product_class.save.complete', 'admin');
break;
case 'update':
// 更新
if (count($ProductClasses) == 0) {
// 商品規格が0件であれば最初の画面に戻す
return $app->redirect($app->url('admin_product_product_class', array('id' => $id)));
}
$checkProductClasses = array();
$removeProductClasses = array();
$tempProductClass = null;
foreach ($form->get('product_classes') as $formData) {
// 追加対象の行をvalidate
$ProductClass = $formData->getData();
if ($ProductClass->getAdd()) {
if ($formData->isValid()) {
$checkProductClasses[] = $ProductClass;
} else {
return $this->render($app, $Product, $ProductClass, false, $form);
}
} else {
// 削除対象の行
$removeProductClasses[] = $ProductClass;
}
$tempProductClass = $ProductClass;
}
if (count($checkProductClasses) == 0) {
// 対象がなければエラー
$error = array('message' => '商品規格が選択されていません。');
return $this->render($app, $Product, $tempProductClass, false, $form, $error);
}
// 登録対象と更新対象の行か判断する
$addProductClasses = array();
$updateProductClasses = array();
foreach ($checkProductClasses as $cp) {
$flag = false;
// 既に登録済みの商品規格か確認
foreach ($ProductClasses as $productClass) {
if ($productClass->getProduct()->getId() == $id && $productClass->getClassCategory1() == $cp->getClassCategory1() && $productClass->getClassCategory2() == $cp->getClassCategory2()) {
$updateProductClasses[] = $cp;
// 商品情報
$cp->setProduct($Product);
// 商品在庫
$productStock = $productClass->getProductStock();
if (!$cp->getStockUnlimited()) {
$productStock->setStock($cp->getStock());
} else {
$productStock->setStock(null);
}
$this->setDefualtProductClass($app, $productClass, $cp);
$flag = true;
break;
}
//.........这里部分代码省略.........
示例13: index
/**
* 新着情報一覧を表示する。
*
* @param Application $app
* @return \Symfony\Component\HttpFoundation\Response
*/
public function index(Application $app)
{
$NewsList = $app['eccube.repository.news']->findBy(array(), array('rank' => 'DESC'));
$form = $app->form()->getForm();
return $app->render('Content/news.twig', array('form' => $form->createView(), 'NewsList' => $NewsList));
}
示例14: index
/**
* 一覧画面
*
* @param Application $app
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function index(Application $app, Request $request)
{
$form = $app->form()->getForm();
$Questions = $app['plugin.Uzaitaikai.repository.question']->findAll();
return $app->render('Uzaitaikai/Resource/template/admin/config.twig', array('form' => $form->createView(), 'Questions' => $Questions));
}