api; } /** * @param Api $api */ public function setApi($api) { $this->api = $api; } /** * @return ApiScope[] */ public function getScopes() { return $this->scopes; } /** * @param ApiScope[] $scopes */ public function setScopes($scopes) { $this->scopes = $scopes; } /** * @return string */ public function getName() { return $this->name; } /** * @param string $name */ public function setName($name) { $this->name = $name; } /** * @return string */ public function getDescription() { return $this->description; } /** * @param string $description */ public function setDescription($description) { $this->description = $description; } /** * @return boolean */ public function isActive() { return $this->active; } /** * @param boolean $active */ public function setActive($active) { $this->active = $active; } /** * @return boolean */ public function isAllowCors() { return $this->allow_cors; } /** * @param boolean $allow_cors */ public function setAllowCors($allow_cors) { $this->allow_cors = $allow_cors; } /** * @return boolean */ public function isAllowCredentials() { return $this->allow_credentials; } /** * @param boolean $allow_credentials */ public function setAllowCredentials($allow_credentials) { $this->allow_credentials = $allow_credentials; } /** * @return string */ public function getRoute() { return $this->route; } /** * @param string $route */ public function setRoute($route) { $this->route = $route; } /** * @return string */ public function getHttpMethod() { return $this->http_method; } /** * @param string $http_method */ public function setHttpMethod($http_method) { $this->http_method = $http_method; } /** * @ORM\ManyToOne(targetEntity="Api", cascade={"persist"}, inversedBy="endpoints") * @ORM\JoinColumn(name="api_id", referencedColumnName="id") * @var Api */ private $api; /** * @ORM\ManyToMany(targetEntity="ApiScope") * @ORM\JoinTable(name="endpoint_api_scopes", * joinColumns={@ORM\JoinColumn(name="api_endpoint_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")} * ) * @var ApiScope[] */ private $scopes; /** * @ORM\Column(name="name", type="string") * @var string */ private $name; /** * @ORM\Column(name="description", type="string") * @var string */ private $description; /** * @ORM\Column(name="active", type="boolean") * @var bool */ private $active; /** * @ORM\Column(name="allow_cors", type="boolean") * @var bool */ private $allow_cors; /** * @ORM\Column(name="allow_credentials", type="boolean") * @var bool */ private $allow_credentials; /** * @ORM\Column(name="route", type="string") * @var string */ private $route; /** * @ORM\Column(name="http_method", type="string") * @var string */ private $http_method; /** * @ORM\Column(name="rate_limit", type="integer") * @var int */ private $rate_limit; /** * @ORM\Column(name="rate_limit_decay", type="integer") * @var int */ private $rate_limit_decay; /** * ApiEndpoint constructor. */ public function __construct() { parent::__construct(); $this->rate_limit = 0; $this->rate_limit_decay = 0; $this->scopes = new ArrayCollection(); } /** * @return string */ public function getScope() { return CacheFacade::remember ( 'endpoint_scopes_'.$this->id, Config::get("cache_regions.region_api_scopes_lifetime", 1140), function() { $scope = ''; foreach ($this->scopes as $s) { if (!$s->isActive()) { continue; } $scope = $scope . $s->getName() . ' '; } $scope = trim($scope); return $scope; } ); } /** * @param IApiScope $scope */ public function addScope(IApiScope $scope){ $this->scopes->add($scope); } /** * @return int */ public function getRateLimit() { return $this->rate_limit; } /** * @param int $rate_limit */ public function setRateLimit($rate_limit) { $this->rate_limit = $rate_limit; } /** * @return int */ public function getRateLimitDecay() { return $this->rate_limit_decay; } /** * @param int $rate_limit_decay */ public function setRateLimitDecay($rate_limit_decay) { $this->rate_limit_decay = $rate_limit_decay; } }