public function findByResource($resource_type, $resource_id, $internal_type = null)
{
$this->lock($resource_type, $resource_id);
if (is_null($internal_type)) {
$internal_type = 'OEModule\\PASAPI\\resources\\' . $resource_type;
}
$record = $this->findByAttributes(array('resource_type' => $resource_type, 'resource_id' => $resource_id));
if (!$record) {
$record = new static();
$record->resource_type = $resource_type;
$record->resource_id = $resource_id;
// assuming all models are in the root namespace at this point
$record->internal_type = '\\' . $internal_type;
}
return $record;
}