for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* (c) FSi sp. z o.o. <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FSi\Bundle\AdminBundle\Admin\Display;
use FSi\Bundle\AdminBundle\Admin\AbstractElement;
use FSi\Bundle\AdminBundle\Display\Display;
use FSi\Bundle\AdminBundle\Exception\RuntimeException;
use Symfony\Component\OptionsResolver\OptionsResolver;
abstract class GenericDisplayElement extends AbstractElement implements Element
{
* {@inheritdoc}
public function getRoute()
return 'fsi_admin_display';
}
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
* @return mixed
public function configureOptions(OptionsResolver $resolver)
$resolver->setDefaults([
'template' => null,
]);
$resolver->setAllowedTypes('template', ['null', 'string']);
public function createDisplay($object)
if (!is_object($object)) {
throw new RuntimeException("createDisplay method accepts only objects.");
$display = $this->initDisplay($object);
if (!is_object($display) || !$display instanceof Display) {
throw new RuntimeException('initDisplay should return instanceof FSi\\Bundle\\AdminBundle\\Display\\Display');
return $display;
* @param mixed $object
* @return Display
abstract protected function initDisplay($object);