Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[LeadGenerationBundle] added initial LeadGenerationBundle version #471

Merged
merged 1 commit into from
Jun 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Kunstmaan/LeadGenerationBundle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
.idea
vendor/*
composer.lock
composer.phar
*.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

namespace Kunstmaan\LeadGenerationBundle\AdminList;

use Doctrine\ORM\EntityManager;
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM;
use Kunstmaan\AdminListBundle\AdminList\Configurator\AbstractDoctrineORMAdminListConfigurator;
use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper;

class PopupAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator
{
/**
* @param EntityManager $em The entity manager
* @param AclHelper $aclHelper The acl helper
*/
public function __construct(EntityManager $em, AclHelper $aclHelper = null)
{
parent::__construct($em, $aclHelper);

$this->setListTemplate('KunstmaanLeadGenerationBundle:AdminList:popup-list.html.twig');
$this->setEditTemplate('KunstmaanLeadGenerationBundle:AdminList:popup-edit.html.twig');
$this->setAddTemplate('KunstmaanLeadGenerationBundle:AdminList:popup-edit.html.twig');
}

/**
* Configure the visible columns
*/
public function buildFields()
{
$this->addField('id', 'Id', true);
$this->addField('name', 'Name', true);
$this->addField('classname', 'Type', false);
$this->addField('htmlId', 'Html id', true);
$this->addField('ruleCount', '# of Rules', false);
}

/**
* Build filters for admin list
*/
public function buildFilters()
{
$this->addFilter('name', new ORM\StringFilterType('name'), 'Name');
$this->addFilter('htmlId', new ORM\StringFilterType('htmlId'), 'htmlId');
}

/**
* Get bundle name
*
* @return string
*/
public function getBundleName()
{
return 'KunstmaanLeadGenerationBundle';
}

/**
* Get entity name
*
* @return string
*/
public function getEntityName()
{
return 'Popup\AbstractPopup';
}

/**
* @param object|array $item
*
* @return bool
*/
public function canEdit($item)
{
return true;
}

/**
* Configure if it's possible to delete the given $item
*
* @param object|array $item
*
* @return bool
*/
public function canDelete($item)
{
return true;
}

/**
* Configure if it's possible to add new items
*
* @return bool
*/
public function canAdd()
{
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
<?php

namespace Kunstmaan\LeadGenerationBundle\AdminList;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder;
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM;
use Kunstmaan\AdminListBundle\AdminList\Configurator\AbstractDoctrineORMAdminListConfigurator;
use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper;
use Kunstmaan\LeadGenerationBundle\Entity\Popup\AbstractPopup;

class RulesAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator
{
/**
* @var int
*/
protected $popupId;

/**
* @param EntityManager $em The entity manager
* @param AclHelper $aclHelper The acl helper
* @param int $id The if of the popup
*/
public function __construct(EntityManager $em, AclHelper $aclHelper = null, $id)
{
parent::__construct($em, $aclHelper);

$this->setPopupId($id);
$this->setListTemplate('KunstmaanLeadGenerationBundle:AdminList:rules-list.html.twig');
$this->setEditTemplate('KunstmaanLeadGenerationBundle:AdminList:rules-edit.html.twig');
$this->setAddTemplate('KunstmaanLeadGenerationBundle:AdminList:rules-edit.html.twig');
}

/**
* @param QueryBuilder $queryBuilder
* @param array $params
*/
public function adaptQueryBuilder(QueryBuilder $queryBuilder, array $params = array())
{
$queryBuilder->where('b.popup = :id');
$queryBuilder->setParameter('id', $this->getPopupId());
$queryBuilder->orderBy('b.id', 'ASC');
}

/**
* Return the url to list all the items
*
* @return array
*/
public function getIndexUrl()
{
return array(
'path' => 'kunstmaanleadgenerationbundle_admin_rule_abstractrule_detail',
'params' => array('popup' => $this->getPopupId())
);
}

/**
* Get the edit url for the given $item
*
* @param object $item
*
* @return array
*/
public function getEditUrlFor($item)
{
$params = array('id' => $item->getId(), 'popup' => $this->getPopupId());
$params = array_merge($params, $this->getExtraParameters());

return array(
'path' => 'kunstmaanleadgenerationbundle_admin_rule_abstractrule_edit',
'params' => $params
);
}

/**
* Get the delete url for the given $item
*
* @param object $item
*
* @return array
*/
public function getDeleteUrlFor($item)
{
$params = array('id' => $item->getId(), 'popup' => $this->getPopupId());
$params = array_merge($params, $this->getExtraParameters());

return array(
'path' => 'kunstmaanleadgenerationbundle_admin_rule_abstractrule_delete',
'params' => $params
);
}

/**
* Configure the visible columns
*/
public function buildFields()
{
$this->addField('id', 'Id', true);
$this->addField('classname', 'Type', false);
$this->addField('jsProperties', 'Properties', false);
}

/**
* Build filters for admin list
*/
public function buildFilters()
{
$this->addFilter('id', new ORM\StringFilterType('id'), 'Id');
}

public function getValue($item, $columnName)
{
if ($columnName == 'jsProperties') {
return json_encode($item->getJsProperties());
}

return parent::getValue($item, $columnName);
}

/**
* Get bundle name
*
* @return string
*/
public function getBundleName()
{
return 'KunstmaanLeadGenerationBundle';
}

/**
* Get entity name
*
* @return string
*/
public function getEntityName()
{
return 'Rule\AbstractRule';
}

/**
* @param object $entity
* @return object
*/
public function decorateNewEntity($entity)
{
$entity->setPopup($this->getPopup());

return $entity;
}

/**
* @param object|array $item
*
* @return bool
*/
public function canEdit($item)
{
return true;
}

/**
* Configure if it's possible to delete the given $item
*
* @param object|array $item
*
* @return bool
*/
public function canDelete($item)
{
return true;
}

/**
* Configure if it's possible to add new items
*
* @return bool
*/
public function canAdd()
{
return true;
}

/**
* @return int
*/
public function getPopupId()
{
return $this->popupId;
}

/**
* @param int $popupId
*/
public function setPopupId($popupId)
{
$this->popupId = $popupId;
}

/**
* @return AbstractPopup
*/
public function getPopup()
{
return $this->em->getRepository('KunstmaanLeadGenerationBundle:Popup\AbstractPopup')->find($this->getPopupId());
}
}
Loading