Changeset 2308051
- Timestamp:
- 05/19/2020 02:11:17 PM (6 years ago)
- Location:
- wp-bullhorn-staffing
- Files:
-
- 5 edited
- 9 copied
-
tags/0.0.5 (copied) (copied from wp-bullhorn-staffing/trunk)
-
tags/0.0.5/bootstrap.php (copied) (copied from wp-bullhorn-staffing/trunk/bootstrap.php) (1 diff)
-
tags/0.0.5/composer.json (copied) (copied from wp-bullhorn-staffing/trunk/composer.json)
-
tags/0.0.5/composer.lock (copied) (copied from wp-bullhorn-staffing/trunk/composer.lock)
-
tags/0.0.5/index.php (copied) (copied from wp-bullhorn-staffing/trunk/index.php)
-
tags/0.0.5/readme.txt (copied) (copied from wp-bullhorn-staffing/trunk/readme.txt)
-
tags/0.0.5/src (copied) (copied from wp-bullhorn-staffing/trunk/src)
-
tags/0.0.5/src/Domain/Entities/AbstractBhEntity.php (modified) (1 diff)
-
tags/0.0.5/src/Domain/Entities/CandidateFiles.php (copied) (copied from wp-bullhorn-staffing/trunk/src/Domain/Entities/CandidateFiles.php)
-
tags/0.0.5/src/Domain/Options/AbstractOptions.php (modified) (3 diffs)
-
tags/0.0.5/vendor (copied) (copied from wp-bullhorn-staffing/trunk/vendor)
-
trunk/bootstrap.php (modified) (1 diff)
-
trunk/src/Domain/Entities/AbstractBhEntity.php (modified) (1 diff)
-
trunk/src/Domain/Options/AbstractOptions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-bullhorn-staffing/tags/0.0.5/bootstrap.php
r2307897 r2308051 4 4 * Plugin URI: 5 5 * Description: Bullhorn Staffing synchronisation plugin 6 * Version: 0.0. 46 * Version: 0.0.5 7 7 * Author: Think studio 8 8 * Author URI: https://think.studio/ -
wp-bullhorn-staffing/tags/0.0.5/src/Domain/Entities/AbstractBhEntity.php
r2307839 r2308051 35 35 { 36 36 return 'wpbstaff_entity_' . substr(strrchr(static::class, "\\"), 1) . '_' . $id; 37 } 38 39 /** 40 * @see https://bullhorn.github.io/rest-api-docs/#get-search 41 * @param array $query 42 * @return |null 43 */ 44 public static function search(array $query = []) 45 { 46 $obj = new static(); 47 $response = \WPBullhornStaffing::instance()->request( 48 'GET', 49 'search/' . $obj->getEntityType(), 50 [ 51 'query' => array_merge([ 52 'query' => 'isDeleted:0', 53 'fields' => implode(',', array_merge( 54 $obj->fields, 55 array_keys($obj->fieldsMap) 56 )) 57 ], $query) 58 ] 59 ); 60 if (is_wp_error($response)) { 61 error_log($response->get_error_message()); 62 return null; 63 } 64 65 return $response->data; 37 66 } 38 67 -
wp-bullhorn-staffing/tags/0.0.5/src/Domain/Options/AbstractOptions.php
r2307839 r2308051 25 25 26 26 27 protected function getPaginatedIdList( ): array27 protected function getPaginatedIdList($query = []): array 28 28 { 29 29 $data = []; … … 34 34 'options/' . $this->getOptionsType(), 35 35 [ 36 'query' => [ 37 'fields' => '*', 38 'meta' => 'full', 36 'query' => array_merge($query, [ 39 37 'count' => 300, 40 38 'start' => $start 41 ] 39 ]) 42 40 ] 43 41 ); … … 57 55 abstract public function getOptionsType(): string; 58 56 59 public function getOptions( ): array57 public function getOptions($forceFetch = false, $cacheTime = DAY_IN_SECONDS): array 60 58 { 61 59 $transientName = 'wpbstaff_options_' . $this->getOptionsType(); 60 $data = null; 62 61 63 $data = get_transient( $transientName ); 62 if(!$forceFetch) { 63 $data = get_transient($transientName); 64 } 64 65 65 66 if(!$data) { 66 67 $data = $this->getPaginatedIdList(); 67 68 if($data && !empty($data)) { 68 set_transient($transientName, $data, DAY_IN_SECONDS);69 set_transient($transientName, $data, $cacheTime); 69 70 } 70 71 } -
wp-bullhorn-staffing/trunk/bootstrap.php
r2307897 r2308051 4 4 * Plugin URI: 5 5 * Description: Bullhorn Staffing synchronisation plugin 6 * Version: 0.0. 46 * Version: 0.0.5 7 7 * Author: Think studio 8 8 * Author URI: https://think.studio/ -
wp-bullhorn-staffing/trunk/src/Domain/Entities/AbstractBhEntity.php
r2307839 r2308051 35 35 { 36 36 return 'wpbstaff_entity_' . substr(strrchr(static::class, "\\"), 1) . '_' . $id; 37 } 38 39 /** 40 * @see https://bullhorn.github.io/rest-api-docs/#get-search 41 * @param array $query 42 * @return |null 43 */ 44 public static function search(array $query = []) 45 { 46 $obj = new static(); 47 $response = \WPBullhornStaffing::instance()->request( 48 'GET', 49 'search/' . $obj->getEntityType(), 50 [ 51 'query' => array_merge([ 52 'query' => 'isDeleted:0', 53 'fields' => implode(',', array_merge( 54 $obj->fields, 55 array_keys($obj->fieldsMap) 56 )) 57 ], $query) 58 ] 59 ); 60 if (is_wp_error($response)) { 61 error_log($response->get_error_message()); 62 return null; 63 } 64 65 return $response->data; 37 66 } 38 67 -
wp-bullhorn-staffing/trunk/src/Domain/Options/AbstractOptions.php
r2307839 r2308051 25 25 26 26 27 protected function getPaginatedIdList( ): array27 protected function getPaginatedIdList($query = []): array 28 28 { 29 29 $data = []; … … 34 34 'options/' . $this->getOptionsType(), 35 35 [ 36 'query' => [ 37 'fields' => '*', 38 'meta' => 'full', 36 'query' => array_merge($query, [ 39 37 'count' => 300, 40 38 'start' => $start 41 ] 39 ]) 42 40 ] 43 41 ); … … 57 55 abstract public function getOptionsType(): string; 58 56 59 public function getOptions( ): array57 public function getOptions($forceFetch = false, $cacheTime = DAY_IN_SECONDS): array 60 58 { 61 59 $transientName = 'wpbstaff_options_' . $this->getOptionsType(); 60 $data = null; 62 61 63 $data = get_transient( $transientName ); 62 if(!$forceFetch) { 63 $data = get_transient($transientName); 64 } 64 65 65 66 if(!$data) { 66 67 $data = $this->getPaginatedIdList(); 67 68 if($data && !empty($data)) { 68 set_transient($transientName, $data, DAY_IN_SECONDS);69 set_transient($transientName, $data, $cacheTime); 69 70 } 70 71 }
Note: See TracChangeset
for help on using the changeset viewer.