How can I add the description of a module inside the module table of contant - grouping

I have my code organized as follows
Header files:
/**
* #defgroup alternator_controller Alternator Controller
* #ingroup application_layer
* #file alternator_controller.h
* #{
*/
/* Header code */
/**#}*/
Source files:
/**
* #ingroup alternator_controller
* #file alternator_controller.c
*
*/
This produces an table of content output like this:
I want the group description to be displayed next to the group in the index, i.e., the red letters in the image shall be changed by the module description
I have already trief placing the brief field in multiple locations without any luck.
/**
* #defgroup alternator_controller Alternator Controller
* #ingroup application_layer
* #file alternator_controller.h
* #brief DESCRIPTION HERE IS NOT DISPLAYED
* #{
* #brief DESCRIPTION HERE IS ALSO NOT DISPLAYED
*/
/* Header code */
/**#}*/
Any idea how can this be achieved (if possible at all)?

There is a possibility to have text with the #defgroup like:
/**
* #defgroup alternator_controller Alternator Controller
* #ingroup application_layer
* #{
* #brief DESCRIPTION HERE IS DISPLAYED
*/
/* Header code */
/**#}*/
and this will result in:

Related

How to implement multi user support using fos user bundle

I've been working on a multi users web application using symfony 3.4 framework with fos user bundle in order to easily manipulate users.
I've integrated the bundle and everything work fine except that the bundle features don't match my need when it comes to multi users through inheritance !
Is there any trick to implement the multi user inheritance in fos bundle ?
I've tried a lot of different tricks like changing the roles , changing the user model interface, using symfony groups but all of them seemed to be not working !
The thing that will solve [with an ugly way] my problem is to change the value of the discriminator column .
* #ORM\Table(name="fos_user")
* #ORM\InheritanceType("SINGLE_TABLE")
* #ORM\DiscriminatorColumn(name="typeutilisateur", type="string")
* #ORM\DiscriminatorMap({"Parent"="User","admin" =
"Administrateur","association"
="AsoociationsBundle\Entity\Association",
"Demandeurservice"="EldersStoryBundle\Entity\Demandeurservice",
"Formateur"="FormationBundle\Entity\Formateur"
,"Prestataire"="AnnonceEldersCareBundle\Entity\Prestataireservice"})
class User extends BaseUser
{
/**
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* #var string
*
* #ORM\Column(name="nom", type="string", length=30, nullable=true)
*/
private $nom;
/**
* #var string
*
* #ORM\Column(name="prenom", type="string", length=30, nullable=true)
*/
private $prenom;
/**
* #var string
*
* #ORM\Column(name="adresse", type="string", length=50)
*/
private $adresse;
/**
* #var string
*
* #ORM\Column(name="telephone", type="integer")
*/
private $telephone;
/**
* #var string
*
* #ORM\Column(name="sexe", type="string", length=30, nullable=true)
*/
private $sexe;
/**
* #var \DateTime
*
* #ORM\Column(name="datecreation", type="datetime")
*/
private $datecreation;
/**
* #var string
*
* #ORM\Column(name="avatar", type="string", length=255)
*/
private $avatar;
/**
* #ORM\ManyToMany(targetEntity="AppBundle\Entity\Group")
* #ORM\JoinTable(name="fos_user_user_group",
* joinColumns={#ORM\JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={#ORM\JoinColumn(name="group_id", referencedColumnName="id")}
* )
*/
protected $groups;
public function __construct()
{
parent::__construct();
}
}
/*This is the sub class*/
<?php
namespace EldersStoryBundle\Entity;
use AppBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;
/**
* Demandeurservice
*
* #ORM\Table(name="demandeurservice")
* #ORM\Entity(repositoryClass="EldersStoryBundle\
Repository\DemandeurserviceRepository")
*/
class Demandeurservice extends User
{
/**
* #var string
*
* #ORM\Column(name="typemaladie", type="string", length=50)
*/
private $typemaladie;
/**
* #var string
*
* #ORM\Column(name="descriptionmaladie", type="string", length=255)
*/
private $descriptionmaladie;
/**
* #var string
*
* #ORM\Column(name="etatmaladie", type="string", length=255)
*/
private $etatmaladie;
/**
* #var int
*
* #ORM\Column(name="pointelderly", type="integer")
*/
private $pointelderly;
}
Everytime i subscribe i get the row in the table but with a discriminator column value ="parent"
So is there any major way to get this done ? or at least to change the value of the discriminator column ?
Remove the DiscriminatorMap. If you don't create one, Doctrine will generate one automagically. So long as you don't go messing around with names of Entity objects (ie, change Person to Persona, or whatever) then that's your best bet. It's also more dynamic because if/when you add additional types, it will update it for you (when cache is removed).
See here, last bullet point quoted:
If no discriminator map is provided, then the map is generated automatically. The automatically generated discriminator map contains the lowercase short name of each class as key.

Index not created

I have a document with an index defined.
/** #ODM\Document */
class Stat
{
/** #ODM\Id(strategy="NONE", type="int") */
private $id;
/** #ODM\Field(type="string") */
private $period;
/** #ODM\ReferenceOne(targetDocument="Player") */
private $player;
/** #ODM\Field(type="string") #ODM\Index */
private $statType;
However, when I look at the indexes created in the collection, the only index is the _id.
To save the document I'm doing:
$stat = new Documents\Stat();
$stat->setId(1);
$stat->setPlayer($player);
$stat->setPeriod(1);
$stat->setStatType('goal');
$dm->persist($stat);
$dm->flush();
Is there something else I'm not doing?
Indexes are not created (nor ensured if they're in sync with mapping) during normal ODM usage.
If you're using Symfony then solving problem is easy, just run doctrine:mongodb:schema:create command from Symfony's console (and if you're using other framework, look for equivalent as command itself is provided by ODM).
If you want to control indexes from your code you can use SchemaManager which provides an API to control "schema" directly (you can also control indexes on per-document basis). Obtaining it is easy: $sm = $dm->getSchemaManager();.
// AppBundle/Document
namespace AppBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique as MongoDBUnique;
/**
* #MongoDB\Document(repositoryClass="AppBundle\Repository\ProduitRepository")
* #MongoDBUnique(fields="$noProduit")
*/
class Produit
{
/**
* #MongoDB\Id
*/
protected $id;
/**
* #MongoDB\String
* #MongoDB\UniqueIndex(order="asc")
*/
protected $noProduit;
/**
* #MongoDB\Field(type="string")
*/
protected $libelle;
// getter and setter
}
// AppBundle/Controller
$dm = $this->get('doctrine_mongodb')->getManager();
$dm->getSchemaManager()->ensureIndexes();
schema and database will be created automatically when you run your app.
For more info
visit this link
/**
* #ODM\Document
* #ODM\Indexes({
* #ODM\Index(keys={"statType"="asc"}),
* #ODM\UniqueIndex(keys={"period"="asc"})//For example unique index
* })
*/
class Stat
{
}
Then if you use symfony run php bin/console doctrine:mongodb:schema:create

Error Creating Many to Many Relationship Using Doctrine 2

I'm trying to generate the schema for my database using Doctrine 2's ZF2 module but with the following definition:
/**
* #ORM\ManyToMany(targetEntity="Tag")
* #ORM\JoinTable(name="Manytomany_Issuetag",
* #ORM\joinColumns={#ORM\JoinColumn(name="IssueId", referencedColumnName="id")},
* #ORM\inverseJoinColumns={#ORM\JoinColumn(name="TagId", referencedColumnName="id")}
* )
*/
protected $tags;
When I run vendor/bin/doctrine-module orm:schema-tool:update --dump-sql I receive the following error:
Annotation #ORM\joinColumns is not allowed to be declared on property Application\Entity\Issue::$tags. You may only use this annotation on these code elements: PROPERTY
Edit: As requested here is the working annotation
/**
* #ORM\ManyToMany(targetEntity="Tag")
* #ORM\JoinTable(name="Manytomany_Issuetag",
* joinColumns={#ORM\JoinColumn(name="IssueId", referencedColumnName="id")},
* inverseJoinColumns={#ORM\JoinColumn(name="TagId", referencedColumnName="id")}
* )
*/
protected $tags;
I think you need to drop a couple of the #ORM\ declarations, it should look like this (obviously without my comments)
/**
* #ORM\ManyToMany(targetEntity="Tag")
* #ORM\JoinTable(name="Manytomany_Issuetag",
* joinColumns={#ORM\JoinColumn(name="IssueId", referencedColumnName="id")},
* ^ drop the #ORM\
* inverseJoinColumns={#ORM\JoinColumn(name="TagId", referencedColumnName="id")}
* ^ drop the #ORM\
* )
*/
protected $tags;

OneToMany invalid Mapping

i am trying to create a oneToMany relationship. Since Doctrine only offers ManyToOne Unidirectional im using that. Somehow the validation of the mapping fails and I am not able to spot my mistake:
Validation Error:
[Mapping] FAIL - The entity-class 'Strego\TippBundle\Entity\BetRound'
mapping is invalid:
* The association Strego\TippBundle\Entity\BetRound#userStatus refers to the owning side field
Strego\TippBundle\Entity\UserBetRoundStatus#betRound which does not
exist.
My First Entity (BetRound):
<?php
namespace Strego\TippBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection as Collection;
use Strego\AppBundle\Entity\Base as BaseEntity;
/**
* Strego\TippBundle\Entity\BetRound
*
* #ORM\Table()
* #ORM\Entity
*/
class BetRound extends BaseEntity {
//......
/**
*
* #var Collection
* #ORM\OneToMany(targetEntity="UserBetRoundStatus", mappedBy="betRound", cascade={"all"})
*/
protected $userStatus;
}
My related Entity(UserBetRoundStatus)
<?php
namespace Strego\TippBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Strego\AppBundle\Entity\Base as BaseEntity;
/**
* Strego\TippBundle\Entity\Game
*
* #ORM\Table
* #ORM\Entity
* #UniqueEntity(fields={"user", "betRound"}, message="Unique Entity Validator Fails for UserStatus", groups="unique")
*
*/
class UserBetRoundStatus extends BaseEntity {
// .....
/*
* #var BetRound
* #ORM\ManyToOne(targetEntity="BetRound", inversedBy="userStatus")
* #ORM\JoinColumn(name="betround_id", referencedColumnName="id", nullable=false)
* #Assert\NotNull()
*/
protected $betRound;
}
I have found the issue:
/** <--------- you need two *
* #var BetRound
* #ORM\ManyToOne(targetEntity="BetRound", inversedBy="userStatus")
* #ORM\JoinColumn(name="betround_id", referencedColumnName="id", nullable=false)
* #Assert\NotNull()
*/
protected $betRound;

Doctrine2: Why is Mapping not detecting my composite keys

I have two tables/entities client and site that have a many to many relationship combined by a join table client_site. Here are how my entities are setup.
Here is the client table entity
/**
* #Entity
* #Table(name="client")
*/
class Client
{
/**
* #Id #Column(type="bigint")
* #GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ManyToMany(targetEntity="Site", inversedBy="clients")
* #JoinTable(name="client_site",
* joinColumns={#JoinColumn(name="c_id", referencedColumnName="id")},
* inverseJoinColumns={#JoinColumn(name="s_id", referencedColumnName="id")}
* )
*/
private $sites;
And the site table entity
/**
* #Entity
* #Table(name="site")
*/
class Site
{
/**
* #Id #Column(type="bigint")
* #GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ManyToMany(targetEntity="Client", mappedBy="sites")
*/
private $clients;
This is the client_site table entity
/**
* #Entity
* #Table(name="client_site",indexes={#index(name="FK_client_site",columns={"c_id"}),#index(name="FK_client_site_2",columns={"s_id"})})
*/
class ClientSite
{
/**
* #Id
* #ManyToOne(targetEntity="Client", inversedBy="ClientSite")
*/
private $client;
/**
* #Id
* #ManyToOne(targetEntity="Site", inversedBy="ClientSite")
*/
private $site;
This is the query I am trying to run
$query = Zend_Registry::get('em')
->createQuery('SELECT c, s
FROM Application\Models\Client c
JOIN c.sites s
WHERE c.is_active = 1');
$clients = $query->getResult();
And this is my error
No identifier/primary key specified for Entity 'Application\Models\ClientSite'. Every Entity must have an identifier/primary key.
I put the #Id on both fields in the ClientSite entity, as they are the composite primary keys for my joiner table. Can this not be done in Doctrine2? If it can't, what are my alternative options.
If you CAN do this, what have I done incorrectly?
This isn't currently supported by Doctrine 2.
However, they are working on adding support for this in an experimental branch. Apparently this might be included in the 2.1 release if it works without issues.