. * */ namespace OCA\Contacts\Utils\TemporaryPhoto; use OCA\Contacts\Contact as ContactObject; use OCA\Contacts\Utils\TemporaryPhoto as BaseTemporaryPhoto; use OCP\ICache; /** * This class loads the PHOTO or LOGO property from a contact. */ class Contact extends BaseTemporaryPhoto { /** * The Contact object to load the image from * * @var \OCA\Contacts\Contact */ protected $contact; public function __construct(ICache $cache, $contact) { if (!$contact instanceof ContactObject) { throw new \Exception( __METHOD__ . ' Second argument must be an instance of OCA\\Contacts\\Contact' ); } parent::__construct($cache); $this->contact = $contact; $this->processImage(); } /** * Do what's needed to get the image from storage * depending on the type. */ protected function processImage() { $this->image = $this->contact->getPhoto(); } }