php - Symfony2: best practive how to get data from another bundle? -
php - Symfony2: best practive how to get data from another bundle? -
i'm new symfony2 , there things don't right now. in case want display albums made band or artist. if user logged in want display on same page, if 1 album in collection of user or not.
i've different bundles "artistbundle", "userbundle", "albumbundle" etc. since user related info nil belongs in artistbundle ("separation of concerns") want info userbundle.
right see 2 ways this:
<?php namespace acme/artistbundle/controller; utilize acme/userbundle/user public function indexaction() { ... $user = new user($userid); $collectioninfo = $user->checkartistalbums($artistid); ... } this solution might work makes unit tests harder since i'm not using dependency injection (which right way think).
the other possibilty embedding userbundle controller in template. can't done since need info straight in output of artistbundle.
so "best practice" here? defining userbundle service? somehow configure artistbundle object of userbundle set in construction of object?
the separation of concerns have different bundles different things. controller can't separate, needs bring different things together, create play.
but bundles still separated. if think it's not separated because bring things in controller action, opposite case.
you controller helps separate things while bringing them using separated bundles.
php symfony2 interaction bundles
Comments
Post a Comment