PHP code example of crowd / ptt

1. Go to this page and download the library: Download crowd/ptt 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/ */

    

crowd / ptt example snippets


    new Crowd\PttBundle\PttBundle()

$message = \Swift_Message::newInstance()
        ->setSubject('Subject goes here')
        ->setFrom('[email protected]')
        ->setTo('[email protected]')
        ->setBody($this->renderView('FrontendBundle:MailTemplates:mailtemplate.html.twig',
                array('name' => $youCanPassVariables)));
        $this->get('mailer')->send($message);

    use Crowd\PttBundle\Controller\PttController;

    class FooController extends PttController {

    protected function fieldsToList()
    {
        return array(
            'title' => 'Title',
            'relatedUrl' => 'URL',
            'published' => 'Published'
            );
    }

    protected function listTitle()
    {
        return 'My new list Entity title';
    }

    protected function continueWithDeletion($entity)
    {
        if (//custom validation using $entity) {
            //not valid
            return array(false, 'Hey, this is an error message');
        } else {
            //valid
            return array(true, '');
        }
    }

    protected function beforeDeletion($entity)
    {
        //remove entities related to $entity
    }

    protected function editTitle()
    {
        return 'My new edit Entity title';
    }

    protected function entityInfo()
    {
        return array(
            'simple' => 'Foo',
            'lowercase' => 'foo',
            'plural' => 'foos'
            );
    }

    $pttForm = $this->get('pttForm');

    $pttForm->setEntity($entity);

    //Returns boolean indicating if the sent data is valid or not
    $pttForm->isValid();

    //Persists and flushes the entity
    $pttForm->save();

    //Returns the success message
    $pttForm->getSuccessMessage();

    //Returns the error message
    $pttForm->getErrorMessage();

    //Returns the html code for the form
    $pttForm->createView();

    use Crowd\PttBundle\Form\PttEntity;

    class MyEntity extends PttEntity {

    use Crowd\PttBundle\Form\PttTransEntity;

    class MyEntityTrans extends PttTranEntity {
json
    "smottt/wideimage" : "dev-master",
    "tpyo/amazon-s3-php-class" : "dev-master"

     /**
     * @var integer
     *
     * @ORM\Column(name="_order", type="text")
     */
    private $_order;

    /**
     * Set _order
     *
     * @param integer $_order
     *
     * @return Social
     */
    public function set_Order($_order)
    {
        $this->_order = $_order;

        return $this;
    }

    /**
     * Get _order
     *
     * @return integer
     */
    public function get_Order()
    {
        return $this->_order;
    }