Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

use BusinessEntity::id instead name and rename variable from entityName to businessEntityId #172

Merged
merged 4 commits into from
Aug 13, 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: 3 additions & 3 deletions Bundle/BlogBundle/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function indexAction(Request $request, $blogId = null, $tab = 'articles')

if ($blog instanceof BusinessEntityPagePattern) {
//we can use the business entity properties on the seo
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($blog->getBusinessEntityName());
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($blog->getBusinessEntityId());
$businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
}

Expand Down Expand Up @@ -125,7 +125,7 @@ public function settingsAction(Request $request, BasePage $blog)
//if the page is a business entity page
if ($blog instanceof BusinessEntityPagePattern) {
//we can use the business entity properties on the seo
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($blog->getBusinessEntityName());
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($blog->getBusinessEntityId());
$businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
}

Expand Down Expand Up @@ -185,7 +185,7 @@ public function categoryAction(Request $request, BasePage $blog)
//if the page is a business entity page
if ($blog instanceof BusinessEntityPagePattern) {
//we can use the business entity properties on the seo
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($blog->getBusinessEntityName());
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($blog->getBusinessEntityId());
$businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
}

Expand Down
2 changes: 1 addition & 1 deletion Bundle/BlogBundle/Form/ArticleType.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
);

$articlePatterns = function(EntityRepository $repo) {
return $repo->getInstance()->andWhere("pattern.businessEntityName = 'article'");
return $repo->getInstance()->andWhere("pattern.businessEntityId = 'article'");
};
$builder->add('pattern', null, array(
'label' => 'form.view.type.pattern.label',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ public function __construct(EntityManager $em)
*/
public function setDefaultDateValue(WidgetFilterSetDefaultValueEvent $event)
{
$data = $event->getData();
$form = $event->getForm();
$businessEntityName = $event->getBusinessEntityName();
if ($businessEntityName == 'article') {
$businessEntityId = $event->getBusinessEntityName();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi avoir laissé getBusinessEntityName() ici ?

if ($businessEntityId == 'article') {
$articles = $this->em->getRepository('VictoireBlogBundle:Article')->getAll(true)->run();
$options = $form->getConfig()->getOptions()['data'];
$years = $months = $days = array();
Expand Down
8 changes: 4 additions & 4 deletions Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function setEntityManager(EntityManagerInterface $entityManager)
*/
public function findById($id)
{
$businessEntity = $this->reader->findById(strtolower($id));
$businessEntity = $this->reader->findById($id);
if ($businessEntity === null) {
throw new \Exception("\"".$id."\" does not seems to be a valid BusinessEntity");
}
Expand Down Expand Up @@ -165,13 +165,13 @@ public function getEntityByPageAndBusinessIdentifier(BusinessEntityPagePattern $
{
$entity = null;

$businessEntityName = $page->getBusinessEntityName();
$businessEntityId = $page->getBusinessEntityId();

$businessEntity = $this->findById($businessEntityName);
$businessEntity = $this->findById($businessEntityId);

//test the result
if ($businessEntity === null) {
throw new \Exception('The business entity ['.$businessEntityName.'] was not found.');
throw new \Exception('The business entity ['.$businessEntityId.'] was not found.');
}

$entity = $this->findEntityByBusinessEntityAndAttribute($businessEntity, $attributeName, $entityIdentifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function createAction(Request $request, $id)
$businessEntity = $this->getBusinessEntity($id);

$view = new BusinessEntityPagePattern();
$view->setBusinessEntityName($businessEntity->getName());
$view->setBusinessEntityId($businessEntity->getId());

$form = $this->createCreateForm($view);

Expand Down Expand Up @@ -79,7 +79,7 @@ public function createAction(Request $request, $id)
*/
private function createCreateForm(BusinessEntityPagePattern $view)
{
$id = $view->getBusinessEntityName();
$id = $view->getBusinessEntityId();
$businessProperty = $this->getBusinessProperties($view);

$form = $this->createForm(
Expand Down Expand Up @@ -111,7 +111,7 @@ public function newAction($id)
$businessEntity = $this->getBusinessEntity($id);

$view = new BusinessEntityPagePattern();
$view->setBusinessEntityName($businessEntity->getName());
$view->setBusinessEntityId($businessEntity->getId());

$form = $this->createCreateForm($view);

Expand Down Expand Up @@ -155,7 +155,7 @@ public function editAction(View $view)
$deleteForm = $this->createDeleteForm($view->getId());

//the business property link to the page
$businessEntityId = $view->getBusinessEntityName();
$businessEntityId = $view->getBusinessEntityId();
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($businessEntityId);

$businessProperties = $businessEntityPagePatternHelper->getBusinessProperties($businessEntity);
Expand Down Expand Up @@ -327,9 +327,9 @@ private function getBusinessProperties(BusinessEntityPagePattern $view)
{
$businessEntityHelper = $this->get('victoire_core.helper.business_entity_helper');
//the name of the business entity link to the business entity page pattern
$businessEntityName = $view->getBusinessEntityName();
$businessEntityId = $view->getBusinessEntityId();

$businessEntity = $businessEntityHelper->findById(strtolower($businessEntityName));
$businessEntity = $businessEntityHelper->findById($businessEntityId);
$businessProperties = $businessEntity->getBusinessPropertiesByType('businessParameter');

$businessProperty = array();
Expand Down
8 changes: 4 additions & 4 deletions Bundle/BusinessEntityPageBundle/Entity/BusinessEntityPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BusinessEntityPage extends Page

/**
* The entity static Url page
* @var unknown
* @var string
*
* @ORM\Column(name="staticUrl", type="text", length=255, nullable=true)
*/
Expand Down Expand Up @@ -63,9 +63,9 @@ public function getEntityProxy()
*
* @return string
**/
public function getBusinessEntityName()
public function getBusinessEntityId()
{
return $this->getTemplate()->getBusinessEntityName();
return $this->getTemplate()->getBusinessEntityId();
}

/**
Expand All @@ -79,7 +79,7 @@ public function getBusinessEntity()
if ($this->businessEntity === null) {
//if there is a proxy
if ($this->getEntityProxy() !== null) {
$this->businessEntity = $this->getEntityProxy()->getEntity($this->getBusinessEntityName());
$this->businessEntity = $this->getEntityProxy()->getEntity($this->getBusinessEntityId());

return $this->businessEntity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class BusinessEntityPagePattern extends Template implements WebViewInterface
{
//This trait add the query and business_entity_name columns
//This trait add the query and business_entity_id columns
use \Victoire\Bundle\QueryBundle\Entity\Traits\QueryTrait;
use \Victoire\Bundle\PageBundle\Entity\Traits\WebViewTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
parent::buildForm($builder, $options);

$builder
->add('businessEntityName', 'hidden')
->add('businessEntityId', 'hidden')
->add('query')
->add('slug', null, array(
'label' => 'victoire.form.business_entity_page_pattern.slug.label'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function getIdentifierPositionInUrl(BusinessEntityPagePattern $bepPattern
// preg_match_all('/\{\%\s*([^\%\}]*)\s*\%\}|\{\{\s*([^\}\}]*)\s*\}\}/i', $url, $matches);

//the business property link to the page
$businessEntityId = $bepPattern->getBusinessEntityName();
$businessEntityId = $bepPattern->getBusinessEntityId();

$businessEntity = $this->businessEntityHelper->findById($businessEntityId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public function findPagePatternByBusinessEntity(BusinessEntity $businessEntity)

/**
* get the pagePatterns for the business entity query
* @param string $entityName
* @param string $businessEntityId
*
* @return QueryBuilder
*/
public function getPagePatternByBusinessEntity($entityName)
public function getPagePatternByBusinessEntity($businessEntityId)
{
return $this->createQueryBuilder('businessEntityPagePattern')
->where('businessEntityPagePattern.businessEntityName = :entityName')
->setParameter(':entityName', $entityName)
->where('businessEntityPagePattern.businessEntityId = :entityId')
->setParameter(':entityId', $businessEntityId)
->orderBy('businessEntityPagePattern.updatedAt', 'ASC');
}

Expand Down
2 changes: 1 addition & 1 deletion Bundle/CoreBundle/Cache/Builder/CacheBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function addWidgetBusinessEntity($widgetName, $businessEntity)
if (!array_key_exists($widgetName, $widgets)) {
$widgets[$widgetName] = array('businessEntities' => array());
}
$widgets[$widgetName]['businessEntities'][$businessEntity->getName()] = $businessEntity;
$widgets[$widgetName]['businessEntities'][$businessEntity->getId()] = $businessEntity;
$this->cache->save(BusinessEntity::CACHE_WIDGETS, $widgets);
}
}
16 changes: 8 additions & 8 deletions Bundle/CoreBundle/Entity/BaseEntityProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ public function getId()
/**
* Get the entity of the proxy
*
* @param string $entityName
* @param string $entityId
* @return Object
* @throws \Exception
*/
public function getEntity($entityName)
public function getEntity($entityId)
{
//test the entity name
if ($entityName == null) {
throw new \Exception('The businessEntityName is not defined for the entityProxy with the id:'.$this->getId());
if ($entityId == null) {
throw new \Exception('The businessEntityId is not defined for the entityProxy with the id:'.$this->getId());
}

$functionName = 'get'.ucfirst($entityName);
$functionName = 'get'.ucfirst($entityId);
$entity = call_user_func(array($this, $functionName));

return $entity;
Expand All @@ -62,14 +62,14 @@ public function getEntity($entityName)
/**
* Set the entity
* @param $entity
* @param $entityName
* @param $entityId
*
* @throws \Exception
*/
public function setEntity($entity, $entityName)
public function setEntity($entity, $entityId)
{
//set the entity
$method = 'set'.ucfirst($entityName);
$method = 'set'.ucfirst($entityId);

//set the entity
call_user_func(array($this, $method), $entity);
Expand Down
8 changes: 4 additions & 4 deletions Bundle/CoreBundle/Form/EntityProxyFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public function buildForm(FormBuilderInterface $builder, array $options)
//add the link to the business entity instance
//it depends of the form
$builder
->add($options['entity_name'], 'entity', array(
'label' => 'entity_proxy.form.label',
->add($options['business_entity_id'], 'entity', array(
'label' => false,
'required' => false,
'empty_value' => 'entity_proxy.form.empty_value',
'class' => $options['namespace'],
'attr' => array(
'class' => 'add_'.$options['entity_name'].'_link picker_entity_select',
'class' => 'add_'.$options['business_entity_id'].'_link picker_entity_select',
),
));
}
Expand All @@ -42,7 +42,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Victoire\Bundle\CoreBundle\Entity\EntityProxy',
'entity_name' => null,
'business_entity_id' => null,
'namespace' => null,
'widget' => null,
'translation_domain' => 'victoire',
Expand Down
12 changes: 6 additions & 6 deletions Bundle/CoreBundle/Form/WidgetType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$this->options = $options;

$namespace = $options['namespace'];
$entityName = $options['entityName'];
$businessEntityId = $options['businessEntityId'];
$mode = $options['mode'];

if ($entityName !== null) {
if ($businessEntityId !== null) {
if ($namespace === null) {
throw new \Exception('The namespace is mandatory if the entity_name is given.');
throw new \Exception('The namespace is mandatory if the business_entity_id is given.');
}
if ($mode === null) {
throw new \Exception('The mode is mandatory if the entity_name is given.');
throw new \Exception('The mode is mandatory if the business_entity_id is given.');
}
}

Expand Down Expand Up @@ -130,7 +130,7 @@ protected function addEntityFields($form)
'widget' => $options['widget'],
))
->add('entity_proxy', 'entity_proxy', array(
'entity_name' => $options['entityName'],
'business_entity_id' => $options['businessEntityId'],
'namespace' => $options['namespace'],
'widget' => $options['widget'],
));
Expand Down Expand Up @@ -170,7 +170,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
$resolver->setOptional(array('slot'));
$resolver->setOptional(array('mode'));
$resolver->setOptional(array('namespace'));
$resolver->setOptional(array('entityName'));
$resolver->setOptional(array('businessEntityId'));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Bundle/CoreBundle/Helper/ViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function cleanVirtualViews(&$viewsReferences)
}
}
/**
* This method get all views (BasePage and Template) in DB and return the references, including non persisted Business entity page (pattern and businessEntityName based)
* This method get all views (BasePage and Template) in DB and return the references, including non persisted Business entity page (pattern and businessEntityId based)
* @return array the computed views as array
*/
public function getAllViewsReferences()
Expand Down Expand Up @@ -226,7 +226,7 @@ public function buildViewReference(View $view, $entity = null)
// for each business entity
foreach ($entities as $entity) {
// only if related pattern entity is the current entity
if ($view->getBusinessEntityName() === $businessEntity->getId()) {
if ($view->getBusinessEntityId() === $businessEntity->getId()) {
$currentPattern = clone $view;
$page = $this->businessEntityPageHelper->generateEntityPageFromPattern($currentPattern, $entity);
$this->updatePageParametersByEntity($page, $entity);
Expand Down Expand Up @@ -414,7 +414,7 @@ public function cloneView(View $view, $templateName = null)
*/
protected function cloneBusinessEntityPagePattern(BusinessEntityPagePattern $view)
{
$businessEntityId = $view->getBusinessEntityName();
$businessEntityId = $view->getBusinessEntityId();
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($businessEntityId);
$businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
}
Expand Down
14 changes: 7 additions & 7 deletions Bundle/CoreBundle/Resources/views/Widget/Form/new.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
<ul class="vic-nav vic-nav-tabs vic-modal-nav-tabs">
<li class="{% if constant('MODE_STATIC', widget) == widget.mode %}vic-active {% endif %}vic-seperate"><a href="#picker-static" data-toggle="vic-tab">Manuel</a></li>
{% for class, namespace in classes %}
<li{% if not loop.last %} class="{% if widget.businessEntityName == class %}vic-active {% endif %}vic-seperate"{% endif %}><a href="#picker-{{class}}" data-toggle="vic-tab">{{ ('form.widget.tab.' ~ class|lower ~ '.label')|trans({}, 'victoire') }}</a></li>
<li class="{% if not loop.last %}vic-seperate{% endif %}{% if widget.businessEntityId == class|lower %} vic-active{% endif %}"><a href="#picker-{{ class|lower }}" data-toggle="vic-tab">{{ ('form.widget.tab.' ~ class|lower ~ '.label')|trans({}, 'victoire') }}</a></li>
{% endfor %}
</ul>
{% endif %}

<div class="vic-tab-content vic-modal-tab-content">
{% for class, form in forms %}
{% set isActive = class == widget.mode or widget.businessEntityName == class and widget.mode == constant('MODE_BUSINESS_ENTITY', widget) %}
<div class="vic-tab-pane {% if isActive %}vic-active{% endif %}" id="picker-{{class}}">
{% set isActive = class == widget.mode or widget.businessEntityId == class|lower and widget.mode == constant('MODE_BUSINESS_ENTITY', widget) %}
<div class="vic-tab-pane{% if isActive %} vic-active{% endif %}" id="picker-{{ class|lower }}">

{% if class != constant('MODE_STATIC', widget) and is_granted('ROLE_VICTOIRE_DEVELOPER') %}
<ul class="vic-nav vic-nav-tabs vic-modal-nav-tabs">
<li class="{% if widget.mode == constant('MODE_ENTITY', widget) %}vic-active {% endif %}vic-seperate"><a href="#picker-{{class}}-entity" data-toggle="vic-tab">{{ ('form.widget.tab.picker.label')|trans({}, 'victoire') }}</a></li>
<li{% if widget.mode == constant('MODE_QUERY', widget) %} class="vic-active"{% endif %}><a href="#picker-{{class}}-query" data-toggle="vic-tab">{{ ('form.widget.tab.query.label')|trans({}, 'victoire') }}</a></li>
<li class="{% if widget.mode == constant('MODE_ENTITY', widget) %}vic-active {% endif %}vic-seperate"><a href="#picker-{{ class|lower }}-entity" data-toggle="vic-tab">{{ ('form.widget.tab.picker.label')|trans({}, 'victoire') }}</a></li>
<li{% if widget.mode == constant('MODE_QUERY', widget) %} class="vic-active"{% endif %}><a href="#picker-{{ class|lower }}-query" data-toggle="vic-tab">{{ ('form.widget.tab.query.label')|trans({}, 'victoire') }}</a></li>

{% if is_business_entity_allowed(class, view) %}
<li{% if widget.mode == constant('MODE_BUSINESS_ENTITY', widget) %} class="vic-active"{% endif %}><a href="#picker-{{class}}-businessEntity" data-toggle="vic-tab">{{ ('form.widget.tab.entity_instance.label')|trans({}, 'victoire') }}</a></li>
{% if is_business_entity_allowed(class|lower, view) %}
<li{% if widget.mode == constant('MODE_BUSINESS_ENTITY', widget) %} class="vic-active"{% endif %}><a href="#picker-{{ class|lower }}-businessEntity" data-toggle="vic-tab">{{ ('form.widget.tab.entity_instance.label')|trans({}, 'victoire') }}</a></li>
{% endif %}
</ul>
<div class="vic-tab-content vic-modal-tab-content">
Expand Down
2 changes: 1 addition & 1 deletion Bundle/CoreBundle/Resources/views/Widget/new.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{% block form %}
{% if entity != null %}
{% block form_entity %}
<div id="picker-{{entity}}-{{ form.mode.vars.data }}" class="vic-tab-pane {% if form.mode.vars.data == widget.mode %}vic-active{% endif %}">
<div id="picker-{{ entity|lower }}-{{ form.mode.vars.data }}" class="vic-tab-pane vic-mode-{{ widget.mode }} {% if form.mode.vars.data == widget.mode %}vic-active{% endif %}">
{{ form_start(form) }}
{{form_rest(form)}}
{{ form_end(form) }}
Expand Down
Loading