How does one reference a module as a param in JSDocs - jsdoc

Given a module like:
/** Config module
* #module Config
*/
export default class Config {
...
How do I specify a link to the Config module when specified as a param?
/**
* Foo
* #module Foo
*/
export default class Foo {
/**
* Create a new instance
* #constructor
* #param {Config} config - the config
*/
constructor(config) {
this.config = config;
}
I cannot seem to get the Config to register as a link

Simple prefix with module:
See below
/**
* Foo
* #module Foo
*/
export default class Foo {
/**
* Create a new instance
* #constructor
* #param {module:Config} config - the config
*/
constructor(config) {
this.config = config;
}

Related

How to send a scheduled email based on a date for the user using Laravel 8?

I want to send 7 days prior to the user, Theirs Selected plan is going to expire. I have implemented using command and cron jobs to run the command. But it is not working. Please anybody guide me to correct my mistake?
app/Console/Commands/AutoPlanRenewalMail.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Mail;
use App\Mail\PlanRenewalMail;
use App\User;
class AutoPlanRenewalMail extends Command
{
/**
* The name and signature of the console command.
*
* #var string
*/
protected $signature = 'auto:planrenewal';
/**
* The console command description.
*
* #var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* #return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* #return int
*/
public function handle()
{
$users = User::whereNotNull('plan_validity')->get();
$check = true;
foreach($users as $user){
if(Carbon::parse($user->plan_validity)->diffInDays(Carbon::now()) == 7){ //Or however your date field on user is called
Mail::to($user)->send(new PlanRenewalMail($user));
}
}
return 0;
}
}
app/Console/kernal.php
<?php
namespace App\Console;
use App\Console\Commands\AutoPlanRenewalMail;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* #var array
*/
protected $commands = [
AutoPlanRenewalMail::class,
];
/**
* Define the application's command schedule.
*
* #param \Illuminate\Console\Scheduling\Schedule $schedule
* #return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->command('auto:planrenewal')->daily();
}
/**
* Register the commands for the application.
*
* #return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
app/Mail/PlanRenewalMail.php
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class PlanRenewalMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* #return void
*/
public function __construct()
{
//
}
/**
* Build the message.
*
* #return $this
*/
public function build()
{
//return $this->view('view.name');
return $this->subject("{{ ENV('APP_NAME') }} EXPIRING")
->view('emails.plan-renewal-mail');
}
}
cron jobs
* * * * * /usr/local/bin/php /home/username(changed to my username)/public_html/artisan schedule:run >> /dev/null 2>&1
then included email template blade file. But any email didn't get still. Is there any coding errors?

Rest API - Why is Postman sending me back empty curly brackets with GET

I'm working on a REST API. Hence I created my entities like for example this one musee.php
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Musee
*
* #ORM\Table(name="musee")
* #ORM\Entity(repositoryClass="AppBundle\Repository\MuseeRepository")
*/
class Musee
{
/**
* #var int
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue
*/
private $id;
/**
* #var string
*
* #ORM\Column(type="string", nullable=false)
*/
private $nom;
/**
* #var string
*
* #ORM\Column(type="string", nullable=false)
*/
private$adresse;
/**
* #var integer
*
* #ORM\Column(type="integer", nullable=false)
*/
private $horaireOuverture;
/**
* #var integer
*
* #ORM\Column(type="integer", nullable=false)
*/
private $horaireFermeture;
/**
* #ORM\OneToMany(targetEntity="AppBundle\Entity\Bateau", mappedBy="musee")
* #ORM\JoinColumn(referencedColumnName="id")
*/
private $bateaux;
/**
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* #param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* #return string
*/
public function getNom()
{
return $this->nom;
}
/**
* #param string $nom
*/
public function setNom($nom)
{
$this->nom = $nom;
}
/**
* #return string
*/
public function getAdresse()
{
return $this->adresse;
}
/**
* #param string $adresse
*/
public function setAdresse($adresse)
{
$this->adresse = $adresse;
}
/**
* #return int
*/
public function getHoraireOuverture()
{
return $this->horaireOuverture;
}
/**
* #param int $horaireOuverture
*/
public function setHoraireOuverture($horaireOuverture)
{
$this->horaireOuverture = $horaireOuverture;
}
/**
* #return int
*/
public function getHoraireFermeture()
{
return $this->horaireFermeture;
}
/**
* #param int $horaireFermeture
*/
public function setHoraireFermeture($horaireFermeture)
{
$this->horaireFermeture = $horaireFermeture;
}
/**
* #return mixed
*/
public function getBateaux()
{
return $this->bateaux;
}
/**
* #param mixed $bateaux
*/
public function setBateaux($bateaux)
{
$this->bateaux = $bateaux;
}
}
My MuseeRepository also exists and in my config.yml I put (both were installed with composer) :
# Nelmio CORS
nelmio_cors:
defaults:
allow_credentials: false
allow_origin: ['*']
allow_headers: ['Content-Type']
allow_methods: ['POST', 'PATCH', 'GET', 'DELETE', 'OPTIONS']
max_age: 3600
paths:
'^/api':
# FosRest
fos_rest:
routing_loader:
include_format: false
view:
view_response_listener: true
format_listener:
rules:
- { path: '^/', priorities: ['json'], fallback_format: 'json' }
In my MuseeController here is what I put:
<?php
/**
* Created by PhpStorm.
* User: Fanny
* Date: 28/03/2018
* Time: 16:13
*/
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\FOSRestController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use FOS\RestBundle\View\View;
use AppBundle\Entity\Musee;
class MuseeController extends Controller
{
/**
* #Rest\View(serializerGroups={"musee"})
* #Rest\Get("/musee")
*/
// Fonction qui renvoie toutes all musee
public function findMusee()
{
$musee = $this->getDoctrine()
->getRepository('AppBundle:Musee')
->findAll();
return $musee;
}
}
I also used a serializer file, I wonder if my problem does not come from there... Though all this elements are in my database as I generated it with doctrine.
AppBundle\Entity\Musee:
attributes:
id:
groups: ['musee']
nom:
groups: ['musee']
adresse:
groups: ['musee']
horaire_ouverture:
groups: ['musee']
horaire_fermeture:
groups: ['musee']
bateaux:
groups: ['musee']
My problem is when I try to call my localhost:8000/musee, I get the good amount of brackets compared to what is inside my database, but they appear empty.
I think I might be missing a step but I'm not sure where to search. Where do you think I should look?
UPDATE:
The version of Symfony that I have is 3.4.
I enabled serializer in my config.yml and installed with composer : jms/serializer-bundle.
In my app Kernel I have :
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new Nelmio\CorsBundle\NelmioCorsBundle(),
The problem is common to all my entities. I get the right amount of brackets but no content inside.
FOSRestBundle's docs cover the serialization here: Enable a Serializer
But CSS seems to be falling apart presently, so I'll quote it:
C) Enable a Serializer
This bundle needs a serializer to work correctly. In most cases, you'll need to enable a serializer or install one. This bundle tries the following (in the given order) to determine the serializer to use:
The one you configured using fos_rest.services.serializer (if you did).
The JMS serializer, if the JMSSerializerBundle is available (and registered).
The Symfony Serializer if it's enabled (or any service called serializer).
Questions:
Which version of Symfony do you use?
Have you enabled Serializer component?
Is the issue limited to Musee or all entities?
Please update the question with these and we can follow up.
Update:
Can't help but wonder if it has anything to do with all services becoming private in Symfony 3.4. Maybe FOSRestBundle cannot find the JMSSerializerBundle. Which version of FOSRestBundle you have installed?
I see that all released versions of FOSRestBundle specify the ^3.0 dependency requirement, but the above is specific to v3.4.
That happens because you are returning an array of entities instead of valid json response. I am working in REST/API too, but without FOSRest, so I cant be completely sure how serialization happens with FOSREST, but definitively is that.
A workaround could be returning a JSONResponse in your controller, with all of your entities serialized somehow instead of returning the array of entities as you are currently doing here
return $musee;
I recreated my project and this time didn't get an error... I'm not sure of what was the reason but I used the same Symfony versions and commands. So there was probably a problem somewhere even if I try to compare both and din't see any difference. I'll try to tell you if I find it.

How do I document a module where module.exports is a function?

I'm trying to document a node module that exports a function, but I'm not getting any reference to the function in my jsdocs output.
The output, using the default template, Just looks like this:
Module: testModule
With nothing under the heading.
Here's what I've tried so far:
try 1
/**
* #module testModule
*/
'use strict';
/**
* #function module:testModule
* #param {String} x Log string
*/
module.exports = function(x) {
console.log(x);
};
try 2
/**
* #module testModule
*/
'use strict';
/**
* #param {String} x Log string
*/
module.exports = function(x) {
console.log(x);
};
Well, this seems like a bug, but I found a work around.
It will only work if you include a description. Like this:
/**
* #module testModule
*/
'use strict';
/**
* Some Description
*
* #function module:testModule
* #param {String} x Log string
*/
module.exports = function(x) {
console.log(x);
};

babel Cli inline attribute not working on babel-cli

I'm trying to use inline attribute declaration. the code below works fine on babelJs website (Experimental option input is checked) but it doesn't work using babel-cli. expect to log inlineAttribute.
/**
* Created by Ala on 25/02/2016.
*/
/**
* Class Human
*/
class Human{
inlineAttribute = 60;
/**
* #constructor
* #param name
*/
constructor(name){
this.name = name;
}
}
var Ala = new Human("Ala");
console.log (Ala.inlineAttribute);

Generate merged entity class files with symfony2

I'm a little bit stuck with my poor knowledge of Symfony2 and Doctrine. Here is what I'm trying to do: I have two different files containing a class definition of the same class. I want to merge these two into a new class file.
I have an existing entity class file Foo.php:
/**
* #ORM\Entity
* #ORM\Table(name="foo")
*/
class Foo
{
/**
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue
*
* #var int
*/
protected $id;
/**
* #ORM\Column(type="string")
*
* #var string
*/
protected $name;
/**
* #param string $name
* #return void
*/
public function setName($name)
{
$this->name = (string) $name;
}
/**
* #return string name
*/
public function getName()
{
return $this->name;
}
protected function someMagic($in) {
die('no magic happens.');
}
}
and a second entity class file with the same name Foo.php:
/**
* #ORM\Entity
* #ORM\Table(name="foo")
*/
class Foo
{
/**
* #ORM\Column(type="string")
*
* #var string
*/
protected $color;
/**
* #param string $name
* #return void
*/
public function setColor($color)
{
$this->color = $this->someColorMagic($color);
}
/**
* #return string name
*/
public function getColor()
{
return $this->color;
}
protected function someMagic($in) {
return 'magic: ' . $out;
}
}
How can I merge these two together (not at runtime, just during installation of a symfony application - could be done with a symfony console command like foobar:install) so I get a merged class Foo written to a file FooExtended.php that contains properties and methods of both classes and the doctrine annotations preserved?
Does Symfony (or the DoctrineBundle within) support stuff like this out of the box? Or can someone point me into the right direction how this can be achieved?
It now turned out with some changes in design I can solve my problem with simple class inheritance. So there is no need for a class merging at design time.