Features.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. namespace MGProvision\Proxmox\v2\models;
  3. class Features extends AbstractObject
  4. {
  5. const ID = 'features';
  6. private $keyctl;
  7. private $nesting;
  8. private $mount;
  9. private $fuse;
  10. private $mknod;
  11. /**
  12. * Features constructor.
  13. */
  14. public function __construct($config=null)
  15. {
  16. if ($config) {
  17. $config = self::asArray($config);
  18. $this->setAttributes($config);
  19. }
  20. }
  21. /**
  22. * @param mixed $keyctl
  23. * @return Features
  24. */
  25. public function setKeyctl($keyctl)
  26. {
  27. $this->keyctl = $keyctl;
  28. return $this;
  29. }
  30. /**
  31. * @param mixed $nesting
  32. * @return Features
  33. */
  34. public function setNesting($nesting)
  35. {
  36. $this->nesting = $nesting;
  37. return $this;
  38. }
  39. /**
  40. * @param mixed $mount
  41. * @return Features
  42. */
  43. public function setMount($mount)
  44. {
  45. $this->mount = $mount;
  46. return $this;
  47. }
  48. /**
  49. * @param mixed $fuse
  50. * @return Features
  51. */
  52. public function setFuse($fuse)
  53. {
  54. $this->fuse = $fuse;
  55. return $this;
  56. }
  57. /**
  58. * @param mixed $mknod
  59. * @return Features
  60. */
  61. public function setMknod($mknod)
  62. {
  63. $this->mknod = $mknod;
  64. return $this;
  65. }
  66. /**
  67. * @return mixed
  68. */
  69. public function getKeyctl()
  70. {
  71. return $this->keyctl;
  72. }
  73. /**
  74. * @return mixed
  75. */
  76. public function getNesting()
  77. {
  78. return $this->nesting;
  79. }
  80. /**
  81. * @return mixed
  82. */
  83. public function getMount()
  84. {
  85. return $this->mount;
  86. }
  87. /**
  88. * @return mixed
  89. */
  90. public function getFuse()
  91. {
  92. return $this->fuse;
  93. }
  94. /**
  95. * @return mixed
  96. */
  97. public function getMknod()
  98. {
  99. return $this->mknod;
  100. }
  101. public function addNfs(){
  102. if(is_null($this->mount)){
  103. $this->mount = 'nfs';
  104. }else if(!preg_match("/nfs/", $this->mount)){
  105. $this->mount .= ';nfs';
  106. }
  107. return $this;
  108. }
  109. public function addCifs(){
  110. if(is_null($this->mount)){
  111. $this->mount = 'cifs';
  112. }else if(!preg_match("/cifs/", $this->mount)){
  113. $this->mount .= ';cifs';
  114. }
  115. return $this;
  116. }
  117. public function isEmpty(){
  118. return is_null($this->keyctl) && is_null($this->nesting) && is_null($this->mount) &&
  119. is_null($this->fuse) && is_null($this->mknod);
  120. }
  121. public function asConfig(){
  122. $filable=[];
  123. if($this->keyctl){
  124. $filable[] = 'keyctl';
  125. }
  126. if($this->nesting){
  127. $filable[] = 'nesting';
  128. }
  129. if($this->mount){
  130. $filable[] = 'mount';
  131. }
  132. if($this->fuse){
  133. $filable[] = 'fuse';
  134. }
  135. if($this->mknod){
  136. $filable[] = 'mknod';
  137. }
  138. $config = [];
  139. $this->toConfig($filable, $config);
  140. return implode(",", $config);
  141. }
  142. }