PHP code example of arsthanea / page-actions-bundle

1. Go to this page and download the library: Download arsthanea/page-actions-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

arsthanea / page-actions-bundle example snippets


class LandingPageActionsController extends Controller {

    /**
     * @Route(name="landing_page_submit", path="submit", methods = {"POST"})
     *
     * @param Request         $request
     * @param NodeTranslation $nodeTranslation
     *
     * @return RedirectResponse
     */
    public function submitAction(Request $request, NodeTranslation $nodeTranslation) {
       // 
       // handle some form data
       //
       return $this->redirectToRoute('landing_page_thank_you', ["url" => $nodeTranslation->getUrl()]);
    }
    
    /**
     * @Route(name="landing_page_thank_you", path="thank-you")
     *
     * @param HasNodeInterface $page
     *
     * @return Response
     */
    public function submitAction(HasNodeInterface $page) {
       // 
       // notice that $page is referencing to current page
       // 
       return $this->render('@LandingPageBundle/Pages/ThankYou.html.twig, ["page" => $page]);
    }
    
}


# Entity\LandingPage.php

class LandingPage extends AbstractEntity implements PageActionsInterface {

// …
    public function getPageActions() {
        return ['landing_page']; 
    }
// …

}
twig
<form action={{ path("landing_page_submit", { "url": nodetranslation.url }) }}" method="POST">