Upgrade to Pro — share decks privately, control downloads, hide ads and more …

EC-CUBE3コードリーディング #5

amidaike
March 16, 2016

EC-CUBE3コードリーディング #5

amidaike

March 16, 2016
Tweet

More Decks by amidaike

Other Decks in Programming

Transcript

  1. FormTypeΛ࢖ͬͨDBొ࿥ • StudyType.phpͷ಺༰
 <?php namespace Eccube\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface;

    use Symfony\Component\Validator\Constraints as Assert; class StudyType extends AbstractType { /** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('customer_agreement', 'textarea', array( 'required' => true, 'label' => 'ձһن໿', 'constraints' => array( new Assert\NotBlank()), )); } /** * {@inheritdoc} */ public function getName() { return 'study'; } }
  2. FormTypeΛ࢖ͬͨDBొ࿥ • StudyController.phpͷ಺༰
 <?php namespace Eccube\Controller; use Eccube\Application; use Eccube\Controller\AbstractController;

    use Eccube\Entity\Help; use Symfony\Component\HttpFoundation\Request; class StudyController extends AbstractController { public function index(Application $app, Request $request) { $Help = $app['eccube.repository.help']->find(2); if (!$Help) { $Help = new Help(); } $builder = $app['form.factory']->createBuilder('study', $Help); $form = $builder->getForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $Help = $form->getData(); $app['orm.em']->persist($Help); $app['orm.em']->flush(); return $app->redirect($app->url('study')); } return $app->render('study.twig', array( 'form' => $form->createView(), )); } }
  3. FormTypeΛ࢖ͬͨDBొ࿥ • study.twigͷ಺༰
 {% extends 'default_frame.twig' %} {% block main

    %} <div class="row"> <div class="col-md-6 col-md-offset-3"> <form action="{{ url('study') }}" method="post"> {{ form_widget(form._token) }} {{ form_row(form.customer_agreement) }} <p> <button type="submit" class="btn btn-primary btn- block">ొ࿥</button> </p> </form> </div> </div> {% endblock %}
  4. EC-CUBE3ίʔυϦʔσΟϯά • AdminσΟϨΫτϦ௚Լʹ͸؅ཧը໘༻ίϯτϩʔ ϥʔ͕ଘࡏ σΟϨΫτϦ໊ ػೳ໊ AdminController ϩάΠϯը໘ɺ؅ཧը໘τοϓ Content ίϯςϯπ؅ཧ༻

    Customer ձһ؅ཧ༻ Order ड஫؅ཧ༻ Product ঎඼؅ཧ༻ Setting جຊ৘ใઃఆɺγεςϜ৘ใઃఆ༻ Store ΦʔφʔζετΞ༻
  5. EC-CUBE3Λ࢖ͬͨ։ൃࢦ਑ • ຊ൪؀ڥͷΠϯετʔϧɺ൓ө࡞ۀ
 ຊ൪؀ڥߏங͸ɺGit͔Β࠷৽ϑΝΠϧΛऔಘ͠ɺ
 php composer.phar install --no-dev
 Λ࣮ߦ͠ඞཁͳϥΠϒϥϦΛΠϯετʔϧ͔ͯ͠Β
 http://υϝΠϯ໊/install.php


    ΛߦͬͯEC-CUBE3ΛΠϯετʔϧ͠·͢ɻ
 ιʔεमਖ਼͕ߦΘΕͨ৔߹ɺຊ൪؀ڥ΁ͷ൓ө͸GitΛ࢖ͬͯ൓өͤ͞ ΔΑ͏ʹ͠·͢ɻ
 ։ൃ׬ྃ → Git΁push → ຊ൪؀ڥ͔ΒGitͰ࠷৽ιʔεΛmerge
 ͱ͍͏ྲྀΕʹͳΓ·͢ɻ