open-orchestra/open-orchestra-display-bundle

View on GitHub
DisplayBundle/DisplayBlock/Strategies/AddThisStrategy.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace OpenOrchestra\DisplayBundle\DisplayBlock\Strategies;

use OpenOrchestra\ModelInterface\Model\ReadBlockInterface;
use Symfony\Component\HttpFoundation\Response;

/**
 * Class AddThisStrategy
 */
class AddThisStrategy extends AbstractDisplayBlockStrategy
{
    const NAME = 'add_this';

    /**
     * Check if the strategy support this block
     *
     * @param ReadBlockInterface $block
     *
     * @return boolean
     */
    public function support(ReadBlockInterface $block)
    {
        return self::NAME === $block->getComponent();
    }

    /**
     * Perform the show action for a block
     *
     * @param ReadBlockInterface $block
     *
     * @return Response
     */
    public function show(ReadBlockInterface $block)
    {
        $parameters = array(
            'pubid' => $block->getAttribute('pubid'),
            'class' => $block->getStyle(),
            'id' => $block->getId(),
            'addThisClass' => $block->getAttribute('addThisClass'),
        );

        return $this->render('OpenOrchestraDisplayBundle:Block/AddThis:show.html.twig', $parameters);
    }

    /**
     * @param ReadBlockInterface $block
     *
     * @return array
     */
    public function getCacheTags(ReadBlockInterface $block)
    {
        return array();
    }

    /**
     * Get the name of the strategy
     *
     * @return string
     */
    public function getName()
    {
        return 'add_this';
    }
}