Knp\Bundle\KnpBundlesBundle\Controller\BundleController::settingsAction PHP Method

settingsAction() public method

public settingsAction ( Request $request, $id )
$request Symfony\Component\HttpFoundation\Request
    public function settingsAction(Request $request, $id)
    {
        /* @var $bundle Bundle */
        $bundle = $this->getRepository('Bundle')->find($id);
        if (!$bundle) {
            throw new NotFoundHttpException('The bundle does not exist.');
        }
        // Save only if sender is owner of bundle
        if (null !== ($owner = $this->get('security.context')->getToken()->getUser()) && $bundle->isOwnerOrContributor($owner)) {
            $state = $request->request->get('state');
            $license = $request->request->get('license');
            if ($state || $license) {
                $bundle->setState($state);
                $bundle->setLicenseType($license);
                $em = $this->get('doctrine')->getManager();
                $em->persist($bundle);
                $em->flush();
                $request->getSession()->setFlash('notice', 'Bundle settings change was successful');
            }
        }
        return $this->redirect($this->generateUrl('bundle_show', array('ownerName' => $bundle->getOwnerName(), 'name' => $bundle->getName())));
    }