Created
July 11, 2017 16:30
-
-
Save tai-sho/b2fa936ca7749e93fc99fa4f38a341dd to your computer and use it in GitHub Desktop.
QRコードを出力するHelper #cakephp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* QRコード出力 | |
*/ | |
class QRHelper extends AppHelper { | |
/** | |
* QRコードを扱うAPIのURL | |
* @var string | |
*/ | |
protected $_apiUrl = ' https://api.qrserver.com/v1/create-qr-code/'; | |
/** | |
* QRコードのURLを出力します。 | |
* @param string $data QRコードに埋め込むデータ | |
* @param array $options 設定 | |
* @return string | |
*/ | |
public function create($data, array $options = array()) { | |
$default = array( | |
'size' => array(100, 100), | |
'bgcolor' => null, | |
'color' => null, | |
'format' => 'png' | |
); | |
$options = Hash::merge($default, $options); | |
$options['data'] = $data; | |
$options['size'] = implode('x', $options['size']); | |
return $this->_apiUrl. Router::queryString($options, array(), true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment