Reputation: 313
I've written several placeholder functions in my User model. All I want them to do is throw the NotImplementedException()
provided by CakePHP. The function is nice and simple and I have tried it several different ways.
public function canConvert() {
throw new NotImplementedException();
}
Error:Class 'App\Model\Entity\NotImplementedException' not found
public function canConvert() {
throw new \NotImplementedException();
}
Error:Class 'NotImplementedException' not found
The only way I could find to do this was this way.
public function canConvert() {
throw new \Cake\Network\Exception\NotImplementedException();
}
I tried to do a use Cake\Network\Exception;
and the top and just throw a NotImplementedException()
but that didn't work.
Upvotes: 3
Views: 1563
Reputation: 13635
If you just do
use Cake\Network\Exception;
you've only imported the namespace, not the classes under it. To reference a class under that namespace, you would then need to do:
throw new Exception\NotImplementedException();
PHP doesn't automatically import all classes under a namespace.
Read more in the manual: http://php.net/manual/en/language.namespaces.importing.php
Upvotes: 8