original_string: protected function getResource($service, $resource, $params = [], $payload = null, $checkPermission = true)
      {
          try {
              $result = ServiceManager::handleRequest(
                  $service, Verbs::GET, $resource, $params, [], $payload, null, $checkPermission
              );
              if ($result->getStatusCode() >= 300) {
                  throw ResponseFactory::createExceptionFromResponse($result);
              }
  
              $result = $result->getContent();
              if ($result instanceof Arrayable) {
                  $result = $result->toArray();
              }
  
              if (is_string($result)) {
                  $result = ['value' => $result];
              } elseif (Arr::isAssoc($result) &&
                  config('df.always_wrap_resources') === true &&
                  isset($result[config('df.resources_wrapper')])
              ) {
                  $result = $result[config('df.resources_wrapper')];
              }
  
              // Special response handling
              $rSeg = explode('/', $resource);
              $api = $service . '/' . $rSeg[0];
              if (isset($rSeg[1]) && in_array($api, ['system/custom', 'user/custom'])) {
                  $result = ['name' => $rSeg[1], 'value' => $result];
              } elseif (isset($rSeg[1]) && $api === $service . '/_table') {
                  $result = ['name' => $rSeg[1], 'record' => $result];
              }
  
              if (in_array($api, ['system/user', 'system/admin'])) {
                  $this->setUserPassword($result);
              }
  
              return $result;
          } catch (NotFoundException $e) {
              $e->setMessage('Resource not found for ' . $service . '/' . $resource);
              throw $e;
          }
      }
code: protected function getResource($service, $resource, $params = [], $payload = null, $checkPermission = true)
      {
          try {
              $result = ServiceManager::handleRequest(
                  $service, Verbs::GET, $resource, $params, [], $payload, null, $checkPermission
              );
              if ($result->getStatusCode() >= 300) {
                  throw ResponseFactory::createExceptionFromResponse($result);
              }
  
              $result = $result->getContent();
              if ($result instanceof Arrayable) {
                  $result = $result->toArray();
              }
  
              if (is_string($result)) {
                  $result = ['value' => $result];
              } elseif (Arr::isAssoc($result) &&
                  config('df.always_wrap_resources') === true &&
                  isset($result[config('df.resources_wrapper')])
              ) {
                  $result = $result[config('df.resources_wrapper')];
              }
  
              // Special response handling
              $rSeg = explode('/', $resource);
              $api = $service . '/' . $rSeg[0];
              if (isset($rSeg[1]) && in_array($api, ['system/custom', 'user/custom'])) {
                  $result = ['name' => $rSeg[1], 'value' => $result];
              } elseif (isset($rSeg[1]) && $api === $service . '/_table') {
                  $result = ['name' => $rSeg[1], 'record' => $result];
              }
  
              if (in_array($api, ['system/user', 'system/admin'])) {
                  $this->setUserPassword($result);
              }
  
              return $result;
          } catch (NotFoundException $e) {
              $e->setMessage('Resource not found for ' . $service . '/' . $resource);
              throw $e;
          }
      }
code_tokens: protected function getResource ( $ service , $ resource , $ params = [ ] , $ payload = null , $ checkPermission = true ) { try { $ result = ServiceManager :: handleRequest ( $ service , Verbs :: GET , $ resource , $ params , [ ] , $ payload , null , $ checkPermission ) ; if ( $ result -> getStatusCode ( ) >= 300 ) { throw ResponseFactory :: createExceptionFromResponse ( $ result ) ; } $ result = $ result -> getContent ( ) ; if ( $ result instanceof Arrayable ) { $ result = $ result -> toArray ( ) ; } if ( is_string ( $ result ) ) { $ result = [ 'value' => $ result ] ; } elseif ( Arr :: isAssoc ( $ result ) && config ( 'df.always_wrap_resources' ) === true && isset ( $ result [ config ( 'df.resources_wrapper' ) ] ) ) { $ result = $ result [ config ( 'df.resources_wrapper' ) ] ; } // Special response handling $ rSeg = explode ( '/' , $ resource ) ; $ api = $ service . '/' . $ rSeg [ 0 ] ; if ( isset ( $ rSeg [ 1 ] ) && in_array ( $ api , [ 'system/custom' , 'user/custom' ] ) ) { $ result = [ 'name' => $ rSeg [ 1 ] , 'value' => $ result ] ; } elseif ( isset ( $ rSeg [ 1 ] ) && $ api === $ service . '/_table' ) { $ result = [ 'name' => $ rSeg [ 1 ] , 'record' => $ result ] ; } if ( in_array ( $ api , [ 'system/user' , 'system/admin' ] ) ) { $ this -> setUserPassword ( $ result ) ; } return $ result ; } catch ( NotFoundException $ e ) { $ e -> setMessage ( 'Resource not found for ' . $ service . '/' . $ resource ) ; throw $ e ; } }
docstring: Extracts a resource
  
  @param string $service
  @param string $resource
  @param array  $params
  @param null   $payload
  @param bool   $checkPermission
  
  @return array|\DreamFactory\Core\Contracts\ServiceResponseInterface|mixed
  @throws \DreamFactory\Core\Exceptions\NotFoundException
  @throws \Exception
docstring_tokens: Extracts a resource