src/Entity/Api/Article.php line 70

Open in your IDE?
  1. <?php
  2. namespace  App\Entity\Api;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. use ApiPlatform\Core\Annotation\ApiFilter;
  7. use ApiPlatform\Core\Annotation\ApiProperty;
  8. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  9. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
  10. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  11. /**
  12.  * 
  13.  * @ORM\Entity(repositoryClass="App\Repository\ArticleRepository")
  14.  * @ApiResource(
  15.  * collectionOperations={
  16.  * "get": {
  17.  *             "method": "GET",
  18.  *              "openapi_context": {
  19.  *                 "responses": {
  20.  *                     "200": {
  21.  *                         "description" : "Article collection",
  22.  *                         "content": {
  23.  *                            "application/json": {
  24.  *                                  "schema": {
  25.  *                                      "example" : "{""data"": [{ ""id"": 0, ""name"": ""string"", ""icon"": ""string"", ""teaser"": ""string"", ""body"": ""string"", ""published"": 0, ""priority"": 0, ""author"": ""string"", ""publishedFrom"": ""2022-08-09T09:36:57.901Z"", ""publishedTo"": ""2022-08-09T09:36:57.901Z"", ""slug"": ""string"", ""seoTitle"": ""string"", ""metadata"": ""string"", ""category"": ""string"", ""site"": [ ""string"" ], ""lang"": ""string"", ""statistic"": ""string"" }], ""meta"": {""current_page"": 1,""from"": 0,""to"": 30,""per_page"": ""30"",""last_page"": 8,""total"": 211 }}",
  26.  *                                      "type": "object",
  27.  *                                      "properties" : {
  28.  *                                          "data" :  {
  29.  *                                              "type": "array",
  30.  *                                               "items": {
  31.  *                                                  "$ref":"#/components/schemas/Article"
  32.  *                                                  }
  33.  *                                              
  34.  *                                          },
  35.  *                                          "meta": {
  36.  *                                              "type": "object",
  37.  *                                              "properties": {
  38.  *                                                  "current_page":{"type": "integer"},
  39.  *                                                  "from":{"type": "integer"},
  40.  *                                                  "to":{"type": "integer"},
  41.  *                                                  "per_page":{"type": "integer"},
  42.  *                                                  "last_page":{"type": "integer"},
  43.  *                                                  "total":{"type": "integer"}
  44.  *                                                  } 
  45.  *                                             
  46.  *                                           }
  47.  *                                      }
  48.  *                                  }
  49.  *                              }
  50.  *                         },
  51.  *                     },
  52.  *                 },
  53.  *             },
  54.  *         },
  55.  * },
  56.  * itemOperations={"get"},
  57.  * graphql={}
  58.  *
  59.  * )
  60.  * @ApiFilter(SearchFilter::class, properties={"name":"partial", "category":"exact", "slug":"exact","site":"exact","published":"exact"})
  61.  * @ApiFilter(DateFilter::class, properties={"publishedFrom"})
  62.  * @ApiFilter(OrderFilter::class, properties={"publishedFrom","priority"})
  63.  * 
  64.  * 
  65.  */
  66. class Article  {
  67.    
  68.     /**
  69.      * @ORM\Id
  70.      * @ORM\Column(type="integer")
  71.      * @ORM\GeneratedValue(strategy="AUTO")
  72.      */
  73.     protected $id;
  74.     /**
  75.      * @ORM\Column(type="string", length=500)
  76.      * @ApiFilter(SearchFilter::class)
  77.      */
  78.     protected $name;
  79.     /**
  80.      * @ORM\Column(type="string", length=255, nullable=true)
  81.      */
  82.     protected $icon;
  83.     /**
  84.      * @ORM\Column(type="text", length=2000, nullable=true)
  85.      */
  86.     protected $teaser;
  87.     /**
  88.      * @ORM\Column(type="text", length=5000, nullable=true)
  89.      */
  90.     protected $body;
  91.     /**
  92.      * @ORM\Column(type="integer")
  93.      */
  94.     protected $published;
  95.     /**
  96.      * @ORM\Column(type="integer", nullable=true)
  97.      */
  98.     protected $priority;
  99.     /**
  100.      * @ORM\Column(type="string", length=200)
  101.      */
  102.     protected $author;
  103.     /**
  104.      * @ORM\Column(type="datetime", name="published_from",nullable=true)
  105.      */
  106.     private $publishedFrom;
  107.     /**
  108.      * @ORM\Column(type="datetime", name="published_to",nullable=true)
  109.      */
  110.     private $publishedTo;
  111.     /**
  112.      * @ORM\Column(type="string")
  113.      */
  114.     protected $slug;
  115.     /**
  116.      * @ORM\Column(type="string",name="seo_title", length=255, nullable=true)
  117.      */
  118.     protected $seoTitle;
  119.     /**
  120.      * @ORM\Column(type="string",length=5000, nullable=true)
  121.      */
  122.     protected $metadata;
  123.      /**
  124.      * @ORM\Column(type="string",length=5000, nullable=true)
  125.      */
  126.     protected $search;
  127.      /**
  128.      * @ORM\Column(type="string",length=255, nullable=true)
  129.      */
  130.     protected $category;
  131.     /**
  132.      * @ORM\Column(type="array", nullable=true)
  133.      * @ApiProperty(attributes={"openapi_context"={"enum":{"one", "two"}}})
  134.      */
  135.     protected $site;
  136.      /**
  137.      * @ORM\Column(type="string", nullable=true)
  138.      * @ApiFilter(SearchFilter::class)
  139.      */
  140.     protected $lang;
  141.     protected $statistic;
  142.     
  143.     
  144.     
  145.    
  146.     /**
  147.      * Get the value of id
  148.      */ 
  149.     public function getId()
  150.     {
  151.         return $this->id;
  152.     }
  153.     /**
  154.      * Set the value of id
  155.      *
  156.      * @return  self
  157.      */ 
  158.     public function setId($id)
  159.     {
  160.         $this->id $id;
  161.         return $this;
  162.     }
  163.     /**
  164.      * Get the value of name
  165.      */ 
  166.     public function getName()
  167.     {
  168.         return $this->name;
  169.     }
  170.     /**
  171.      * Set the value of name
  172.      *
  173.      * @return  self
  174.      */ 
  175.     public function setName($name)
  176.     {
  177.         $this->name $name;
  178.         return $this;
  179.     }
  180.     /**
  181.      * Get the value of icon
  182.      */ 
  183.     public function getIcon()
  184.     {
  185.         return $this->icon;
  186.     }
  187.     /**
  188.      * Set the value of icon
  189.      *
  190.      * @return  self
  191.      */ 
  192.     public function setIcon($icon)
  193.     {
  194.         $this->icon $icon;
  195.         return $this;
  196.     }
  197.     /**
  198.      * Get the value of teaser
  199.      */ 
  200.     public function getTeaser()
  201.     {
  202.         return $this->teaser;
  203.     }
  204.     /**
  205.      * Set the value of teaser
  206.      *
  207.      * @return  self
  208.      */ 
  209.     public function setTeaser($teaser)
  210.     {
  211.         $this->teaser $teaser;
  212.         return $this;
  213.     }
  214.     /**
  215.      * Get the value of body
  216.      */ 
  217.     public function getBody()
  218.     {
  219.         return $this->body;
  220.     }
  221.     /**
  222.      * Set the value of body
  223.      *
  224.      * @return  self
  225.      */ 
  226.     public function setBody($body)
  227.     {
  228.         $this->body $body;
  229.         return $this;
  230.     }
  231.     /**
  232.      * Get the value of published
  233.      */ 
  234.     public function getPublished()
  235.     {
  236.         return $this->published;
  237.     }
  238.     /**
  239.      * Set the value of published
  240.      *
  241.      * @return  self
  242.      */ 
  243.     public function setPublished($published)
  244.     {
  245.         $this->published $published;
  246.         return $this;
  247.     }
  248.     /**
  249.      * Get the value of priority
  250.      */ 
  251.     public function getPriority()
  252.     {
  253.         return $this->priority;
  254.     }
  255.     /**
  256.      * Set the value of priority
  257.      *
  258.      * @return  self
  259.      */ 
  260.     public function setPriority($priority)
  261.     {
  262.         $this->priority $priority;
  263.         return $this;
  264.     }
  265.     /**
  266.      * Get the value of author
  267.      */ 
  268.     public function getAuthor()
  269.     {
  270.         return $this->author;
  271.     }
  272.     /**
  273.      * Set the value of author
  274.      *
  275.      * @return  self
  276.      */ 
  277.     public function setAuthor($author)
  278.     {
  279.         $this->author $author;
  280.         return $this;
  281.     }
  282.     /**
  283.      * Get the value of publishedFrom
  284.      */ 
  285.     public function getPublishedFrom()
  286.     {
  287.         return $this->publishedFrom;
  288.     }
  289.     /**
  290.      * Set the value of publishedFrom
  291.      *
  292.      * @return  self
  293.      */ 
  294.     public function setPublishedFrom($publishedFrom)
  295.     {
  296.         $this->publishedFrom $publishedFrom;
  297.         return $this;
  298.     }
  299.     /**
  300.      * Get the value of publishedTo
  301.      */ 
  302.     public function getPublishedTo()
  303.     {
  304.         return $this->publishedTo;
  305.     }
  306.     /**
  307.      * Set the value of publishedTo
  308.      *
  309.      * @return  self
  310.      */ 
  311.     public function setPublishedTo($publishedTo)
  312.     {
  313.         $this->publishedTo $publishedTo;
  314.         return $this;
  315.     }
  316.     /**
  317.      * Get the value of slug
  318.      */ 
  319.     public function getSlug()
  320.     {
  321.         return $this->slug;
  322.     }
  323.     /**
  324.      * Set the value of slug
  325.      *
  326.      * @return  self
  327.      */ 
  328.     public function setSlug($slug)
  329.     {
  330.         $this->slug $slug;
  331.         return $this;
  332.     }
  333.     /**
  334.      * Get the value of seoTitle
  335.      */ 
  336.     public function getSeoTitle()
  337.     {
  338.         return $this->seoTitle;
  339.     }
  340.     /**
  341.      * Set the value of seoTitle
  342.      *
  343.      * @return  self
  344.      */ 
  345.     public function setSeoTitle($seoTitle)
  346.     {
  347.         $this->seoTitle $seoTitle;
  348.         return $this;
  349.     }
  350.     /**
  351.      * Get the value of metadata
  352.      */ 
  353.     public function getMetadata()
  354.     {
  355.         return $this->metadata;
  356.     }
  357.     /**
  358.      * Set the value of metadata
  359.      *
  360.      * @return  self
  361.      */ 
  362.     public function setMetadata($metadata)
  363.     {
  364.         $this->metadata $metadata;
  365.         return $this;
  366.     }
  367.     /**
  368.      * Get the value of category
  369.      */ 
  370.     public function getCategory()
  371.     {
  372.         return $this->category;
  373.     }
  374.     /**
  375.      * Set the value of category
  376.      *
  377.      * @return  self
  378.      */ 
  379.     public function setCategory($category)
  380.     {
  381.         $this->category $category;
  382.         return $this;
  383.     }
  384.     /**
  385.      * Get the value of site
  386.      */ 
  387.     public function getSite()
  388.     {
  389.         return $this->site;
  390.     }
  391.     /**
  392.      * Set the value of site
  393.      *
  394.      * @return  self
  395.      */ 
  396.     public function setSite($site)
  397.     {
  398.         $this->site $site;
  399.         return $this;
  400.     }
  401.     /**
  402.      * Get the value of statistic
  403.      */ 
  404.     public function getStatistic()
  405.     {
  406.         return $this->statistic;
  407.     }
  408.     /**
  409.      * Set the value of statistic
  410.      *
  411.      * @return  self
  412.      */ 
  413.     public function setStatistic($statistic)
  414.     {
  415.         $this->statistic $statistic;
  416.         return $this;
  417.     }
  418.     /**
  419.      * Get the value of lang
  420.      */ 
  421.     public function getLang()
  422.     {
  423.         return $this->lang;
  424.     }
  425.     /**
  426.      * Set the value of lang
  427.      *
  428.      * @return  self
  429.      */ 
  430.     public function setLang($lang)
  431.     {
  432.         $this->lang $lang;
  433.         return $this;
  434.     }
  435. }