Don't understand the error: Unknown method "exists" (CakePHP 3.3)

Hello, I’ve gotten the following piece of code from the internet and I don’t udnerstand why it’s not working:

use Cake\ORM\TableRegistry;

'Other code here

$rights = TableRegistry::get('Rights');
if($rights->exists(['name' => $reqRight]))

I’m getting the error ‘Unknown method “exists”’ and I can’t find anything about this error.

Perhaps check the value of $rights to make sure an actual object of type Table has been returned.

If another type was returned, then it may not have a method called exists().