Changeset 2786914
- Timestamp:
- 09/19/2022 11:39:41 AM (3 years ago)
- Location:
- pmpr-ir
- Files:
-
- 4 edited
-
tags/1.2.1/src/Pmpr/Plugin/Pmpr/Ajax.php (modified) (1 diff)
-
tags/1.2.1/src/Pmpr/Plugin/Pmpr/Component/Item.php (modified) (7 diffs)
-
trunk/src/Pmpr/Plugin/Pmpr/Ajax.php (modified) (1 diff)
-
trunk/src/Pmpr/Plugin/Pmpr/Component/Item.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pmpr-ir/tags/1.2.1/src/Pmpr/Plugin/Pmpr/Ajax.php
r2784464 r2786914 178 178 case 'update': 179 179 180 $this->fetchCommonComponents(true); 180 181 $fetched = API::getInstance()->getComponent($name); 181 182 if ($fetched && !is_wp_error($fetched) -
pmpr-ir/tags/1.2.1/src/Pmpr/Plugin/Pmpr/Component/Item.php
r2784023 r2786914 3 3 namespace Pmpr\Plugin\Pmpr\Component; 4 4 5 use Exception; 5 6 use Pmpr\Plugin\Pmpr\Interfaces\ConstantInterface; 6 7 use Pmpr\Plugin\Pmpr\Manipulate; … … 19 20 20 21 /** 22 * @var array|object 23 */ 24 protected $composer = []; 25 26 /** 21 27 * @var int|string|null 22 28 */ … … 126 132 } 127 133 } 134 135 $composerPath = trailingslashit(Manipulate::getComponentsRootPath($this->getTypeSlug())) . trailingslashit($this->getName()) . 'composer.json'; 136 if (file_exists($composerPath)) { 137 138 $fields = wp_json_file_decode($composerPath); 139 if (is_array($fields) || is_object($fields)) { 140 141 $this->composer = (array)$fields; 142 } 143 } 128 144 } 129 145 } … … 132 148 * @return array|object 133 149 */ 150 public function getComposer() 151 { 152 return $this->composer; 153 } 154 155 /** 156 * @param $key 157 * @param $default 158 * 159 * @return mixed 160 */ 161 public function getComposerField($key, $default = null) 162 { 163 return Manipulate::getArrayItem($this->getComposer(), $key, $default); 164 } 165 166 /** 167 * @return array|object 168 */ 134 169 public function getData() 135 170 { … … 166 201 public function getVersion(): ?string 167 202 { 168 return $this-> version;203 return $this->getComposerField(self::VERSION, $this->version); 169 204 } 170 205 … … 242 277 243 278 /** 244 * @return string |null245 */ 246 public function get Slug(): ?string279 * @return string 280 */ 281 public function getTypeSlug(): string 247 282 { 248 283 $type = ''; … … 261 296 break; 262 297 } 263 298 return $type; 299 } 300 301 /** 302 * @return string|null 303 */ 304 public function getSlug(): ?string 305 { 306 $type = $this->getTypeSlug(); 264 307 $name = str_replace("wp-{$type}-", '', $this->getName()); 265 308 return "pr__{$type}__" . str_replace('-', '_', $name); -
pmpr-ir/trunk/src/Pmpr/Plugin/Pmpr/Ajax.php
r2784464 r2786914 178 178 case 'update': 179 179 180 $this->fetchCommonComponents(true); 180 181 $fetched = API::getInstance()->getComponent($name); 181 182 if ($fetched && !is_wp_error($fetched) -
pmpr-ir/trunk/src/Pmpr/Plugin/Pmpr/Component/Item.php
r2784023 r2786914 3 3 namespace Pmpr\Plugin\Pmpr\Component; 4 4 5 use Exception; 5 6 use Pmpr\Plugin\Pmpr\Interfaces\ConstantInterface; 6 7 use Pmpr\Plugin\Pmpr\Manipulate; … … 19 20 20 21 /** 22 * @var array|object 23 */ 24 protected $composer = []; 25 26 /** 21 27 * @var int|string|null 22 28 */ … … 126 132 } 127 133 } 134 135 $composerPath = trailingslashit(Manipulate::getComponentsRootPath($this->getTypeSlug())) . trailingslashit($this->getName()) . 'composer.json'; 136 if (file_exists($composerPath)) { 137 138 $fields = wp_json_file_decode($composerPath); 139 if (is_array($fields) || is_object($fields)) { 140 141 $this->composer = (array)$fields; 142 } 143 } 128 144 } 129 145 } … … 132 148 * @return array|object 133 149 */ 150 public function getComposer() 151 { 152 return $this->composer; 153 } 154 155 /** 156 * @param $key 157 * @param $default 158 * 159 * @return mixed 160 */ 161 public function getComposerField($key, $default = null) 162 { 163 return Manipulate::getArrayItem($this->getComposer(), $key, $default); 164 } 165 166 /** 167 * @return array|object 168 */ 134 169 public function getData() 135 170 { … … 166 201 public function getVersion(): ?string 167 202 { 168 return $this-> version;203 return $this->getComposerField(self::VERSION, $this->version); 169 204 } 170 205 … … 242 277 243 278 /** 244 * @return string |null245 */ 246 public function get Slug(): ?string279 * @return string 280 */ 281 public function getTypeSlug(): string 247 282 { 248 283 $type = ''; … … 261 296 break; 262 297 } 263 298 return $type; 299 } 300 301 /** 302 * @return string|null 303 */ 304 public function getSlug(): ?string 305 { 306 $type = $this->getTypeSlug(); 264 307 $name = str_replace("wp-{$type}-", '', $this->getName()); 265 308 return "pr__{$type}__" . str_replace('-', '_', $name);
Note: See TracChangeset
for help on using the changeset viewer.