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

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

Avatar for amidaike amidaike
February 17, 2016

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

Avatar for amidaike

amidaike

February 17, 2016
Tweet

More Decks by amidaike

Other Decks in Programming

Transcript

  1. ϑΥʔϜͱDB࿈ܞ෦෼Λ࡞੒͠Α͏ • FormΛ࢖ͬͯग़ྗ͢Δύλʔϯ
 $app->get('/hello/{name}', function(\Symfony\Component \HttpFoundation\Request $request, $name) use($app) {

    $builder = $app['form.factory']- >createBuilder('entry'); $form = $builder->getForm(); return $app->render('study.twig', array( 'name' => $name, 'form' => $form->createView(), )); });
  2. ϑΥʔϜͱDB࿈ܞ෦෼Λ࡞੒͠Α͏ • DB͔Β஋Λऔಘ͠ը໘Λग़ྗ͢Δύλʔϯ
 $app->get('/hello/{name}', function(\Symfony\Component \HttpFoundation\Request $request, $name) use($app) {

    $Product = $app['eccube.repository.product']- >find(1); return $app->render('study.twig', array( 'name' => $name, 'Product' => $Product, )); });
  3. ϑΥʔϜͱDB࿈ܞ෦෼Λ࡞੒͠Α͏ • study.twigͷ಺༰
 {% extends 'default_frame.twig' %} {% block main

    %} ͜Μʹͪ͸ {{ name }} ͞Μ <br> ঎඼໊͸ {{ Product.name }} Ͱ͢ɻ {% endblock %}
  4. ςʔϒϧΛ࡞੒͠Α͏ • Eccube.Entity.Study.dcm.ymlͷ಺༰
 Eccube\Entity\Study: type: entity table: dtb_study repositoryClass: Eccube\Repository\StudyRepository

    id: id: type: integer nullable: false id: true column: study_id generator: strategy: AUTO options: unsigned: true fields: name: type: string length: 100 url: type: string nullable: true length: 200 create_date: type: datetime nullable: false update_date: type: datetime nullable: false lifecycleCallbacks: { }
  5. ςʔϒϧΛ࡞੒͠Α͏ • EntityΫϥεΛ࡞੒ޙɺ࣮ࡍʹMySQL΍Postgresʹରͯ͠ςʔϒϧ Λ࡞੒͠·͢ɻ࡞੒ํ๏͸2௨Γ͋Γɺmigrationͱݺ͹ΕΔ࢓૊ ΈΛ࢖͏͔ɺdoctirneίϚϯυΛ࢖ͬͯςʔϒϧΛ࡞੒͢Δ͔ͷ2 ௨Γ͋Γ·͢ɻࠓճ͸͕࣌ؒͳ͍ͨΊdoctrineίϚϯυΛ࢖͏ํ๏ Λઆ໌͠·͢ɻ
 
 
 


    
 ɾDB΁ͷϚΠάϨʔγϣϯํ๏ vendor/bin/doctrine orm:schema-tool:update Λ࣮ߦͯ͠migrationՄೳ͔Ͳ͏͔Λ֬ೝ͢Δɻ vendor/bin/doctrine orm:schema-tool:update --dump-sql Λ࣮ߦͯ͠sqlΛ֬ೝ vendor/bin/doctrine orm:schema-tool:update --force Λ࣮ߦͯ͠DB΁ϚΠάϨʔγϣϯ
  6. EC-CUBE3ίʔυϦʔσΟϯά • AdminσΟϨΫτϦ௚Լʹ͸؅ཧը໘༻ίϯτϩʔ ϥʔ͕ଘࡏ σΟϨΫτϦ໊ ػೳ໊ AdminController ϩάΠϯը໘ɺ؅ཧը໘τοϓ Content ίϯςϯπ؅ཧ༻

    Customer ձһ؅ཧ༻ Order ड஫؅ཧ༻ Product ঎඼؅ཧ༻ Setting جຊ৘ใઃఆɺγεςϜ৘ใઃఆ༻ Store ΦʔφʔζετΞ༻